首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >摩西v1.0多语言ini文件

摩西v1.0多语言ini文件
EN

Stack Overflow用户
提问于 2013-11-13 15:01:48
回答 1查看 620关注 0票数 2

我使用的是mosesserver0.91,一切都很好,但是现在有了1.0版,没有任何东西和以前一样。

以下是我的情况:

我想要从阿拉伯语到英语,从英语到阿拉伯语的多语言翻译。我拥有的所有数据和配置文件都可以使用0.91版本的mosesserver。下面是我的配置文件:

代码语言:javascript
复制
-------------------------------------------------
#########################
### MOSES CONFIG FILE ###
#########################

# D - decoding path, R - reordering model, L - language model
[translation-systems]
ar-en D 0 R 0 L 0
en-ar D 1 R 1 L 1

# input factors
[input-factors]
0

# mapping steps
[mapping]
0 T 0
1 T 1

# translation tables: table type (hierarchical(0), textual (0), binary (1)), source-factors, target-factors, number of scores, file 
# OLD FORMAT is still handled for back-compatibility
# OLD FORMAT translation tables: source-factors, target-factors, number of scores, file 
# OLD FORMAT a binary table type (1) is assumed 
[ttable-file]
1 0 0 5 /mnt/models/ar-en/phrase-table/phrase-table
1 0 0 5 /mnt/models/en-ar/phrase-table/phrase-table

# no generation models, no generation-file section

# language models: type(srilm/irstlm), factors, order, file
[lmodel-file]
1 0 5 /mnt/models/ar-en/language-model/en.qblm.mm
1 0 5 /mnt/models/en-ar/language-model/ar.lm.d1.blm.mm


# limit on how many phrase translations e for each phrase f are loaded
# 0 = all elements loaded
[ttable-limit]
20

# distortion (reordering) files
[distortion-file]
0-0 wbe-msd-bidirectional-fe-allff 6 /mnt/models/ar-en/reordering-table/reordering-table.wbe-msd-bidirectional-fe.gz
0-0 wbe-msd-bidirectional-fe-allff 6 /mnt/models/en-ar/reordering-model/reordering-table.wbe-msd-bidirectional-fe.gz

# distortion (reordering) weight
[weight-d]
0.3
0.3

# lexicalised distortion weights
[weight-lr]
0.3
0.3
0.3
0.3
0.3
0.3
0.3
0.3
0.3
0.3
0.3
0.3

# language model weights
[weight-l]
0.5000
0.5000

# translation model weights
[weight-t]
0.2
0.2
0.2
0.2
0.2
0.2
0.2
0.2
0.2
0.2

# no generation models, no weight-generation section

# word penalty
[weight-w]
-1
-1

[distortion-limit]
12
---------------------------------------------------------

所以请有人帮我重写这个配置文件,这样它就可以在1.0版中工作了。我需要一些python的翻译示例代码。我在python和earler中使用xmlrpc,我发送了http请求:

代码语言:javascript
复制
import xmlrpclib

client = xmlrpclib.ServerProxy('http://localhost:8080')
client.translate({'text': 'some text', 'system': 'en-ar'})

但现在似乎没有更多的“系统”参数,摩西总是使用默认设置。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-13 19:09:28

我把它修好。这是新的ini文件:

代码语言:javascript
复制
[input-factors]
 0

 # mapping steps
 [mapping]
 0 T 0
 1 T 1

 [distortion-limit]
 12

 # feature functions
 [feature]
 Distortion
 UnknownWordPenalty
 WordPenalty
 PhraseDictionaryBinary name=TranslationModel0 num-features=5 path=/mnt/models/ar-en/phrase-table/phrase-table input-factor=0 output-factor=0 table-limit=20
 LexicalReordering num-features=6 name=LexicalReordering0 type=wbe-msd-bidirectional-fe-allff input-factor=0 output-factor=0 path=/mnt/models/ar-en/reordering-table/reordering-table.wbe-msd-bidirectional-fe.gz 
 IRSTLM name=LM0 order=5 factor=0 path=/mnt/models/ar-en/language-model/en.qblm.mm
 PhraseDictionaryBinary name=TranslationModel1 num-features=5 path=/mnt/models/en-ar/phrase-table/phrase-table input-factor=0 output-factor=0 table-limit=20
 LexicalReordering num-features=6 name=LexicalReordering1 type=wbe-msd-bidirectional-fe-allff input-factor=0 output-factor=0 path=/mnt/models/en-ar/reordering-model/reordering-table.wbe-msd-bidirectional-fe.gz 
 IRSTLM name=LM1 order=5 factor=0 path=/mnt/models/en-ar/language-model/ar.lm.d1.blm.mm

 # core weights - not used
 [weight]
 Distortion0= 0
 WordPenalty0= 0
 TranslationModel0= 0 0 0 0 0
 LexicalReordering0= 0 0 0 0 0 0
 LM0= 0
 TranslationModel1= 0 0 0 0 0
 LexicalReordering1= 0 0 0 0 0 0
 LM1= 0

 [alternate-weight-setting]
 id=ar-en ignore-ff=LM1,LexicalReordering1 ignore-decoding-path=1
 Distortion0= 0.3
 WordPenalty0= -1
 TranslationModel0= 0.2 0.2 0.2 0.2 0.2
 LexicalReordering0= 0.3 0.3 0.3 0.3 0.3 0.3
 LM0= 0.5
 id=en-ar ignore-ff=LM0,LexicalReordering0 ignore-decoding-path=0
 Distortion0= 0.3
 WordPenalty0= -1
 TranslationModel1= 0.2 0.2 0.2 0.2 0.2
 LexicalReordering1= 0.3 0.3 0.3 0.3 0.3 0.3
 LM1= 0.5

客户端的示例代码是:

代码语言:javascript
复制
import xmlrpclib

client = xmlrpclib.ServerProxy('http://localhost:8080')
client.translate({'text': '<seg weight-setting="%s">%s</seg>' % ('en-ar', some_text)})

其中,"en-ar“是翻译系统,在我的例子中,从英语翻译到阿拉伯语(我还有其他翻译系统"ar-en”(从阿拉伯语到英语),正如您从ini文件中看到的那样)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19957078

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档