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