当前位置:   article > 正文

机器翻译——mosesdecoder

mosesdecoder

1.moses

  • moses是由英国爱丁堡大学、德国亚琛工业大学等8家单位联合开发的一个基于短语的统计机器翻译系统。

本文主要介绍 mosesdecoder 中的 tokenizer
github地址

2.安装及使用

2.1 安装

直接 clone 上面 github

git clone https://github.com/moses-smt/mosesdecoder.git
  • 1

2.2 tokenizer 使用

进入tokenizer.perl所在目录

cd mosesdecoder/scripts/tokenizer/
  • 1

tokenizer.perl 参数如下:

Usage ./tokenizer.perl (-l [en|de|...]) (-threads 4) < textfile > tokenizedfile
Options:
  -q     ... quiet.
  -a     ... aggressive hyphen splitting.
  -b     ... disable Perl buffering.
  -time  ... enable processing time calculation.
  -penn  ... use Penn treebank-like tokenization.
  -protected FILE  ... specify file with patters to be protected in tokenisation.
  -no-escape ... don't perform HTML escaping on apostrophy, quotes, etc.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

tokenizer 主要将标点与词分开,具体可以查看tokenizer.perl
例如文件 input.en:

Are you sure you want to cancel the upgrade?
Enemy's march trail's color will turn blue (originally red)
Clicking "Change Appearance" will replace your custom avatar with a default avatar.
  • 1
  • 2
  • 3

运行

perl ./tokenizer.perl -l en -no-escape <input.en> tokenizedfile.en
  • 1

得到:

Are you sure you want to cancel the upgrade ?
Enemy 's march trail 's color will turn blue ( originally red )
Clicking " Change Appearance " will replace your custom avatar with a default avatar .
  • 1
  • 2
  • 3

注意:

  • 需要加上 -no-escape,如果不加会得到下图中效果,其中 's " 等都会被转义
  • 参数 -l 传入的语种 为英、德 等,传入 不存在的语种不传 会默认为 en分词

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/783771
推荐阅读
相关标签
  

闽ICP备14008679号