word2word
1.0.0
3,564对语言对的易于使用的单词翻译。
这是我们LREC 2020纸的官方代码。
首先,使用pip安装软件包:
pip install word2word或者
git clone https://github.com/kakaobrain/word2word
python setup.py install然后,在Python中,下载模型并将任何给定单词的前5个单词翻译检索到所需的语言:
from word2word import Word2word
en2fr = Word2word ( "en" , "fr" )
print ( en2fr ( "apple" ))
# out: ['pomme', 'pommes', 'pommier', 'tartes', 'fleurs'] 
我们在OpenSubtitles2018的所有可用对中提供顶级的单词对单词翻译。这相当于62种独特语言的总共3,564对语言对。
完整列表在此处提供。
我们的方法基于平行语料库中的跨语性单词对之间的共发生统计数据计算顶级单词翻译。我们还引入了一个更正术语,该术语可以控制同一句子中其他源词产生的任何混杂效应。最终的方法是一种有效且可扩展的方法,它使我们能够从任何给定的平行语料库中构造大型双语词典。
有关更多详细信息,请参见我们论文的方法部分。
word2word软件包还提供了使用不同的平行语料库构建自定义双语词典的接口。在这里,我们展示了一个从Medline英语 - 法国数据集中构建的示例:
from word2word import Word2word
# custom parallel data: data/pubmed.en-fr.en, data/pubmed.en-fr.fr
my_en2fr = Word2word . make ( "en" , "fr" , "data/pubmed.en-fr" )
# ...building...
print ( my_en2fr ( "mitochondrial" ))
# out: ['mitochondriale', 'mitochondriales', 'mitochondrial',
# 'cytopathies', 'mitochondriaux']从源头构建时,双语词典也可以从命令行构造,如下所示:
python make.py --lang1 en --lang2 fr --datapref data/pubmed.en-fr在这两种情况下,可以在Python中重新加载自定义词典(默认情况下保存到datapref/ ):
from word2word import Word2word
my_en2fr = Word2word . load ( "en" , "fr" , "data/pubmed.en-fr" )
# Loaded word2word custom bilingual lexicon from data/pubmed.en-fr/en-fr.pkl在Python接口和命令行界面中,默认情况下,用16个CPU make多处理。可以通过设置num_workers=N (python)或--num_workers N (命令行)来调整CPU工人的数量。
如果您使用Word2word进行研究,请引用我们的论文:
@inproceedings { choe2020word2word ,
author = { Yo Joong Choe and Kyubyong Park and Dongwoo Kim } ,
title = { word2word: A Collection of Bilingual Lexicons for 3,564 Language Pairs } ,
booktitle = { Proceedings of the 12th International Conference on Language Resources and Evaluation (LREC 2020) } ,
year = { 2020 }
}我们所有预计的双语词典都是由公开可用的opensubtitles2018数据集构建的:
@inproceedings { lison-etal-2018-opensubtitles2018 ,
title = " {O}pen{S}ubtitles2018: Statistical Rescoring of Sentence Alignments in Large, Noisy Parallel Corpora " ,
author = { Lison, Pierre and
Tiedemann, J{"o}rg and
Kouylekov, Milen } ,
booktitle = " Proceedings of the Eleventh International Conference on Language Resources and Evaluation ({LREC} 2018) " ,
month = may,
year = " 2018 " ,
address = " Miyazaki, Japan " ,
publisher = " European Language Resources Association (ELRA) " ,
url = " https://www.aclweb.org/anthology/L18-1275 " ,
}Kyubyong Park,Dongwoo Kim和YJ Choe