Skip to content

Installing Moses Decoder on Ubuntu

January 17, 2014
  1. Get the source from here https://github.com/moses-smt/mosesdecoder
  2. Installing some dependencies
    sudo apt-get install libboost-all-dev
    sudo apt-get install zlib1g-dev
    sudo apt-get install libbz2-dev

    ————————
    bzip2 library manual installation

    wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
    tar xzvf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6/
    
    make
    make install
    cp libbz2.a /usr/lib
    
    make clean
    make -f Makefile-libbz2_so
    cp libbz2.so.* /usr/lib
    ln -sf libbz2.so.1.0 /usr/lib/libbz2.so
  3. Extracting
    mkdir -p /usr/local/src/mosesdecoder
    sudo chown ubuntu /usr/local/src/mosesdecoder/
    
    unzip mosesdecoder-master.zip -d /usr/local/src/mosesdecoder/
  4. Edit some RandLM header files if required
    ————
    RandLMQuantizer.h

    static const float kFloatErr = 0.00001f;

    to

    static constexpr float kFloatErr = 0.00001f;

    ————-
    RandLM.h

    static const float kNullLogProb = -1000000;
    static const float kUnknownLogProb = 1000000;

    to

    static constexpr float kNullLogProb = -1000000;
    static constexpr float kUnknownLogProb = 1000000;

    ————
    RandLMTypes.h

    #define iterate(c,i) for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)

    to

    #define iterate(c,i) for(__typeof__(c.begin()) i = c.begin(); i != c.end(); i++)
  5. Compiling
    ./bjam --prefix=/usr/local/lib/mosesdecoder --with-irstlm=/usr/local/lib/irstlm --with-randlm=/usr/local/lib/randlm -j4 --debug-configuration -d2 >build.log
  6. Linking some files
    cp -r scripts /usr/local/lib/mosesdecoder
    
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/CreateOnDiskPt /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/build_binary /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/query /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/extractor /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/mert /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/processLexicalTable /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/processPhraseTable /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/queryLexicalTable /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/queryPhraseTable /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/moses_chart /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/moses /usr/local/bin
    sudo ln -sfn /usr/local/lib/mosesdecoder/bin/lmbrgrid /usr/local/bin
    
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/analysis/sentence-by-sentence.pl /usr/local/bin/sentence-by-sentence.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/experiment.perl /usr/local/bin/experiment.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/analysis.perl /usr/local/bin/analysis.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/berkeley-process.sh /usr/local/bin/berkeley-process.sh
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/berkeley-train.sh /usr/local/bin/berkeley-train.sh
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/consolidate-training-data.perl /usr/local/bin/consolidate-training-data.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/generic-multicore-parallelizer.perl /usr/local/bin/generic-multicore-parallelizer.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/generic-parallelizer.perl /usr/local/bin/generic-parallelizer.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/input-from-sgm.perl /usr/local/bin/input-from-sgm.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/interpolate-lm.perl /usr/local/bin/interpolate-lm.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/reference-from-sgm.perl /usr/local/bin/reference-from-sgm.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/remove-segmenation-markup.perl /usr/local/bin/remove-segmenation-markup.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/report-experiment-scores.perl /usr/local/bin/report-experiment-scores.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/reuse-weights.perl /usr/local/bin/reuse-weights.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/run-command-on-multiple-refsets.perl /usr/local/bin/run-command-on-multiple-refsets.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/ems/support/wrap-xml.perl /usr/local/bin/wrap-xml.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/generic/compound-splitter.perl /usr/local/bin/compound-splitter.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/generic/extract-factors.pl /usr/local/bin/extract-factors.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/generic/lopar2pos.pl /usr/local/bin/lopar2pos.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/generic/moses-parallel.pl /usr/local/bin/moses-parallel.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/generic/mteval-v12.pl /usr/local/bin/mteval-v12.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/generic/multi-bleu.perl /usr/local/bin/multi-bleu.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/generic/qsub-wrapper.pl /usr/local/bin/qsub-wrapper.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/tokenizer/detokenizer.perl /usr/local/bin/detokenizer.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/tokenizer/tokenizer.perl /usr/local/bin/tokenizer.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/tokenizer/lowercase.perl /usr/local/bin/lowercase.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/absolutize_moses_model.pl /usr/local/bin/absolutize_moses_model.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/build-generation-table.perl /usr/local/bin/build-generation-table.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/clean-corpus-n.perl /usr/local/bin/clean-corpus-n.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/clone_moses_model.pl /usr/local/bin/clone_moses_model.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/mbr/mbr /usr/local/bin/mbr
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/filter-model-given-input.pl /usr/local/bin/filter-model-given-input.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/filter-rule-table.py /usr/local/bin/filter-rule-table.py
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/lexical-reordering/score /usr/local/bin/score
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/memscore/memscore /usr/local/bin/memscore
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/zmert-moses.pl /usr/local/bin/zmert-moses.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/mert-moses.pl /usr/local/bin/mert-moses.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/phrase-extract/extract /usr/local/bin/extract
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/phrase-extract/extract-rules /usr/local/bin/extract-rules
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/phrase-extract/score /usr/local/bin/score
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/phrase-extract/consolidate /usr/local/bin/consolidate
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/postprocess-lopar.perl /usr/local/bin/postprocess-lopar.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/reduce_combine.pl /usr/local/bin/reduce_combine.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/combine_factors.pl /usr/local/bin/combine_factors.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/train-model.perl /usr/local/bin/train-model.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/symal/symal /usr/local/bin/symal
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/symal/giza2bal.pl /usr/local/bin/giza2bal.pl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/wrappers/parse-de-bitpar.perl /usr/local/bin/parse-de-bitpar.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/wrappers/parse-en-collins.perl /usr/local/bin/parse-en-collins.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/wrappers/make-factor-en-pos.mxpost.perl /usr/local/bin/make-factor-en-pos.mxpost.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/wrappers/make-factor-pos.tree-tagger.perl /usr/local/bin/make-factor-pos.tree-tagger.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/training/wrappers/make-factor-stem.perl /usr/local/bin/make-factor-stem.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/recaser/train-recaser.perl /usr/local/bin/train-recaser.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/recaser/recase.perl /usr/local/bin/recase.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/recaser/truecase.perl /usr/local/bin/truecase.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/recaser/detruecase.perl /usr/local/bin/detruecase.perl
    sudo ln -sfn /usr/local/lib/mosesdecoder/scripts/recaser/train-truecaser.perl /usr/local/bin/train-truecaser.perl

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: