Suppose you have an Object class. You instantiate three objects locally:

Object o1, o2, o3;

Then you have a function:

void f(Object o1, Object &o2, Object * o3);

This summarises the three ways you can pass an object to a function: by value, by reference and by reference via a pointer (let’s call it for simplicity call by pointer). Say you call the function like this:

f(o1, o2, &o3);

Inside the function, you may access these objects’ fields like this (note o3):

o1.x += 3;
o2.x += 3;
o3->x += 3;

These are the take home messages:

[Call by value]: o1 is going to be copied inside the function f, then after f returns the copy is going to be destroyed. This means that any changes made by f onto o1 are not going to be visible outside f. In addition to being unsuitable to persist changes, the copy overhead can be very deleterius in certain high-performance applications – however, there is no access overhead.

[Call by reference]: o2 is NOT going to be copied, so any changes made to o2 inside f are going to remain even after f returns. This is very efficient: no copy and methods/fields have no access overhead.

[Call by pointer]: you are actually passing a pointer to o3 to f, so to access the objects’ fields and methods you need to dereferentiate every time (using the -> operator). This makes it averagely efficient: no copy but access overhead.

It’s clear that, even when you don’t actually need to modify an object, call by reference should be your default approach.

I’ve been experimenting a bit with this library and it’s a relief: I don’t have to maintain my own (crappy) one within ZenithMUD.

Easy to use, documented and very efficient, according to benchmarks I’ve found around. One can use the start() method that runs the library in a Thread and takes care of getting data from the connected clients and running user-defined actions on them, or just call the update() function in your own game loop (if you are more of a control freak :))

Added a few things in the About page. I’ve a job in UK, I’m working with Erlang, an amazing language designed and tweaked to deal with extremely concurrent, distributed systems. I love the actor model built in Erlang, and I’m getting used to functional programming (pattern matching is just about the best tool I’ve ever used).

Added some more information about my projects, just explore the menu up there. Nothing too impressive but you may be curious, who knows.

If you want to learn Erlang, start with the book Erlang/OTP in Action. It has a pragmatic approach and helps you write a decent OTP application quickly. If you want to start from the fundamentals, OReilly’s Erlang Programming is very thorough and is also nice to read. I recommend Geany as an editor, if you are GUI-inclined but like simple and efficient stuff (I’ve done a pull request for a few more Erlang-oriented configurations, if they don’t accept it you’ll find info in my own github account).

Intellij-Idea or SublimeText (which sadly is shareware) are more appropriate if you are into fancy GUIs in addition to functionality. There’s also a plugin for Eclipse called Erlide.

For the old and pure, instead, there are good plugins for Emacs and VIM. For the latter, search on github for “vimerl“, that’s the best.

I assume that you use a Unix-like operative system, but this apply to any OS.

Let’s say about a problem: you are in your office, you are waiting for some kind of simulation to end. Everything seems to go well, so you go home, quite confident that the next morning you’ll have some results to analyze.

Unfortunately, it’s unlikely to happen. Ten seconds after your departure, the program ends for a low-frequency bug that you missed.

Luckily, we have a solution for the future. Instead of losing a long night (or even a weekend) of program executions, you can check your office workstation when you are at home, in your warm bed, or everywhere you like to be (with an internet connection, ça va sans dire).

What do you need in your workstation?

You need to install (or ask the sysadmin to install):

the ssh server

a vnc server: x11vnc

Remember to ask the sysadmin:

the public IP of your workstation

the range of unused open ports, if the workstation is behind a router

What do you have to do from home?

Ok, now it’s very simple. You’ll only need to install a vncviewer, but you’ll probably already have one. Let’s say that your workstation username is goofy, the public IP is 1.0.0.1, and the free open port on the workstation is the 5900. Now we need another port, this time a local one (of your home computer), to create the http tunnel. I suggest the port 5901:

ssh -p 42 -L 5901:localhost:5900 goofy@1.0.0.1

You’ll have to insert your workstation password, and then you can explore with the shell your remote operative system. If you want to use it graphically, only execute the command:

x11vnc

Wait for 5-6 seconds, then open another shell without closing the current one, and type the following:

vncviewer localhost::5901

Et voilà! You have to move your mouse on the new black window, and then you’ll see the remote display to appear.

I assume that you are working with a *nix box, and that you use a bash-like shell.

You need the sentence aligned europarl corpora for each language you like to train the word alignment. Please check that the corpora have the same number of lines and that they are correctly aligned.

If you don’t want to do it, you can use the sentence aligned europarl corpora built by Els Lefever. They are raw (no xml tags, but capital letter and words not well separated), so if you want the word alignment you have to follow all of next steps. Note that they are compressed in a tar.gz archive, and that are only six languages: english, italian, french, spanish, german and dutch. If you want to use different languages but you don’t know how to do, please comment this post.

First of all

You want to do a word alignment between two languages. We call the two languages the source language and the target language. This is important in order to correctly do the word alignment, so decide which language will be the source and which the target.

I can help you saying that the word alignment is only one-to-one, NULL-to-one and many-to-one. So if you choose english as source language and french as target, you can have an alignment like this:

Image via Wikipedia

You may want to make a function like this:

that is impossible with the alignment before. In this case you have to use the french as source language, and english as target.

In the next sections, I’ll use for each file name this convention: source = .src and target = .trg

So for example, if you downloaded my raw corpora and you want to do an english (source) to french (target) alignment (like in the image above), you can think raw_corpus.src as raw_corpus.en and raw_corpus.trg as raw_corpus.fr.

Pre-processing

We have to clean up the corpora, set every word in lower case and separate every word from each other (or we can say “tokenizing”). We need the tools of the europarl maintainers, you can download it here:

Now enter the subdirectory tools, and take the script tokenizer.perl and the directory nonbreaking_prefix (they should be in the same directory!).

The nonbreaking_prefix let the tokenizer keep together words like “Mr.”. Normally the tokenizer would have broken it into two words: “Mr” and “.”, but we know that the final dot is useful, not a real punctuation.

Into tools.tgz there aren’t prefixes for every language, so I did my own. You can freely use it, and if you correct it please contact me.

Making class and cooccurrence

They are equals, but MGIZA is multi-threaded, GIZA not. My advice is to choose MGIZA, but if you have to align lot of languages you can execute multiple times GIZA for each language, so it’s your choice. I’ll write explicitly when an option if for MGIZA only.

After you have downloaded, built and installed your favourite tool, we can go forward.

Finally aligning!

You only need, now, a configuration file for MGIZA or GIZA. I use this, you only have to change “.src” and “.trg” with the correct language strings: “it”, “en”, “fr”, etc.

If you use GIZA, you have to delete the line “ncpus” from this config file. Otherwise, with MGIZA, set it to the number of cpu/core that you have. Remember that if you have a cpu with hyperthreading, you can multiply the number of core by two (I’ve an Intel i740 quad-core, so I’ve “ncpus 8”).

Cross your fingers and type:

mgiza configfile

After many hours, you’ll get as many output files as “ncpus”, in this format:

Little script for lazy ones

I did a simple script that does the things I said before, you only need to adapt it to your languages. Now it makes five word alignments, from “italian/dutch/french/german/spanish” languages to “english”. You can freely use it if you want.