
MAXSIM version 1.01
===================
28-04-2010

Papers that report the use of MAXSIM code should give a citation to the following paper:

Yee Seng Chan, & Hwee Tou Ng (2008). MAXSIM: A Maximum Similarity Metric for Machine Translation Evaluation. Proceedings of the 46th Annual Meeting of the Association for Computational Linguistics (ACL 2008). (pp. 55-62). Columbus, Ohio, USA.


MAXSIM calculates a similarity score between a pair of English system-reference sentences by comparing information items such as n-grams across the sentence pair.
However, unlike most metrics which do binary matching, MAXSIM computes a similarity score between items.
To find a maximum weight matching that matches each system item to at most one reference item, the items are then modelled as nodes in a bipartite graph.
In our experiments, we found \alpha=0.8 achieved good correlations on the WMT07, WMT08, and MetricsMATR development datasets. You will be able to specify the value of \alpha as a parameter when running MAXSIM, and this indicates the relative weighting between precision and recall.
Processes involved in MAXSIM includes: tokenization, part-of-speech tagging, lemmatization, and use of WordNet synonyms.

This package should preferably be run on linux; alternatively, unix.


---------------
Contents
---------------

1. Installing
   a. POS-tagger
   b. MAXSIM

2. Running MAXSIM (walk-through with example)
   a. Processing the input files
   b. Scoring using MAXSIM

3. Timing



---------------
1. Installing
---------------

I will assume that you are installing the package maxsim-v1.0.tar.gz under your home-dir (e.g. /research/trial/chanys) so that you have:
    /research/trial/chanys/maxsim-v1.0
i.e. ~/maxsim-v1.0 as your base-dir for the package


----------------
1a. POS-tagger
----------------

MAXSIM should work with any POS-tagger that uses the Penn-Treebank tagset. For your convenience of running MAXSIM, we have included the OpenNLP toolkit in this package and trained model files for its POS-tagger.

The toolkit is at: ~/maxsim-v1.0/sw/opennlp-tools-1.4.3/
The trained model files are at: ~/maxsim-v1.0/sw/opennlp-tools-1.4.3/models/english/postag/wsj/
(this is trained from all of WSJ except section 23)

To install the OpenNLP toolkit, it should be as simple as pointing JAVA_HOME to your JVM and then building, e.g.:
export JAVA_HOME=/usr/java/jdk1.6.0_07
./build.sh

For your preference, we have also included the original 1.4.3 distribution of the OpenNLP toolkit at: 
~/maxsim-v1.0/sw/opennlp-tools-1.4.3.tgz
, if you decide to install from scratch using the above, do remember to add the POS-tagger model files into subdir:
~/maxsim-v1.0/sw/opennlp-tools-1.4.3/models/english/postag/wsj/


----------------
1b. MAXSIM
----------------

There are two steps: (a) compiling the lemmatizer
                     (b) compiling MAXSIM

(a) Go into the dir ~/maxsim-v1.0/util/morphword/ , and execute: g++ -O3 morphword.cpp -o morphword

(b) Inside dir ~/maxsim-v1.0/maxsim, type: g++ -O3 maxsim.cpp -o maxsim



----------------------
2. Running MAXSIM
----------------------

Using MAXSIM consists of two steps: 
(a) Performing tokenization, POS-tagging, and lemmaization to produce the input files to MAXSIM
(b) Running MAXSIM on the input files to produce a score for each sentence/segment                    

We will use the WMT-08 evaluation task files (into English) as examples. These are in dir ~/maxsim-v1.0/wmt08/wmt08-humaneval-data
Based on these, I have generated the following: 
  Pre-processed files needed by MAXSIM: ~/maxsim-v1.0/wmt08/processed/p1
    (the .pos POS-tagged files are generated first, followed by the .lem lemma files; MAXSIM only needs the .lem files)
  Actual scores produced by MAXSIM: ~/maxsim-v1.0/wmt08/scores/s1

You might want to save the above 2 dirs in another place, before trying to regenerate them, and then compare that you are getting exactly the same files (and scores). This ensures the installation and running of MAXSIM are done correctly.


--------------------------------
2a. Processing the input files
--------------------------------

Go into dir ~/maxsim-v1.0/wmt08/processed
In file p1.bash, ensure the dir for (export CLASSPATH, maxsim_dir, exp_basedir) are changed according to where you've installed MAXSIM.
Then simply execute:
  cat filelist|./p1.bash

The processed files will be stored inside ~/maxsim-v1.0/wmt08/processed/p1
Although each (submission) input file produces two output files, MAXSIM will only use the .lem file


----------------------------
2b. Scoring using MAXSIM
----------------------------

Now, inside the dir ~/maxsim-v1.0/wmt08/scores , do:
  cat test.filelist |./s1_test.bash

The results (scores) will be stored inside ~/maxsim-v1.0/wmt08/scores/s1

Since there's only 1 reference-text, there is only 1 score per segment. 
In general, if we have multiple (e.g. 4 references), each row is then:
  <running-index>\t<score-1>\t<score-2>\t<score-3>\t<score-4>
, i.e. tab separated fields

Running MAXSIM is simple. Your input file should be 1 sentence/segment per line in plain text.

The file ~/maxsim-v1.0/wmt08/processed/p1.bash demonstrates how to use the script "to_lem.pl" to generate the .lem (lemmatized) file that MAXSIM uses. Assume your system file is "sys01" and your reference file is "ref01". Then the general syntax is:
  perl to_lem.pl <basedir_of_this_package> sys01
  perl to_lem.pl <basedir_of_this_package> ref01
These files will be created in the same dir of (sys01, ref01): sys01.pos sys01.lem ref01.pos ref01.lem

The file ~/maxsim-v1.0/wmt08/scores/s1_test.bash demonstrates how to perform scoring using MAXSIM. E.g.:
  maxsim -lemmafile lemma_set.allpos -pr 0.8 -uniwgt 1 -biwgt 1 -triwgt 1 -sys sys01.lem -ref ref01.lem
If you want a "system-level" single score, just average (arithmetic mean) the segment-level scores.
  There's also a simple script specifically for WMT-08 that does this; just run: perl scores.pl
  The system-level scores are stored in /s1_sysscores dir

MAXSIM will give a score for each segment. If you have multiple (say 4 references), then:
  maxsim -lemmafile lemma_set.allpos -pr 0.8 -uniwgt 1 -biwgt 1 -triwgt 1 -sys sys01.lem -ref ref01.lem ref02.lem ref03.lem ref04.lem

Currently in our ACL08 paper, to get a single score for each segment, I have just averaged the scores from the multiple references. 

The -pr parameter indicates the precision/recall ratio (the \alpha). A value higher than 0.5 gives more weight to recall.
The three parameters (-uniwgt -biwgt -triwgt) indicates the weight for unigram matching, bigram matching, trigram matching. Specifying '1' for all of them indicates their original scores are not changed and this is what we've done so far. You can think of this as equally weighting them if you like.


-----------------------------
3. Timing
-----------------------------

On average, for each WMT-08 submission file, producing its .pos and .lem files in the processed/p1 dir should take about 15-20 secs. Then, running MAXSIM on each of the .lem file should take about 15 secs. Taken together, that's less than 40 secs for each WMT-08 submission, where each submission contains about 2,000 segments.

This is based on a linux machine with dual-core AMD 2.2GHz, and 2GB ram.


Any questions should be directed to Yee Seng Chan at: chanys.nlp@gmail.com

