Word Translation

Word Translation related modeling class

class pororo.tasks.word_translation.PororoWordTranslationFactory(task: str, lang: str, model: Optional[str], tgt: str)[source]

Bases: pororo.tasks.utils.base.PororoFactoryBase

Conduct cross-word translation tasks

See also

word2word: A Collection of Bilingual Lexicons for 3,564 Language Pairs (https://arxiv.org/abs/1911.12019)

Multi (word2word)

  • dataset: word2word (Choe et al. 2019)

  • metric: N/A

Parameters

word (str) – input word to be translated

Returns

word translation candidates

Return type

List[str]

Examples

>>> wt = Pororo(task="word_translation", lang="en", tgt="fr")
>>> wt("apple")
['pomme', 'pommier', 'pommes', 'tombe', 'yeux']
>>> wt = Pororo(task="word_translation", lang="ja", tgt="ko")
>>> wt("リンゴ")
['선악과', '사과', '에덴', '링고', '귀하']
>>> wt = Pororo(task="word_translation", lang="ko", tgt="en")
>>> wt("사과")
['apologize', 'apology', 'apple', 'apologies', 'apologizing']
load(device: str)[source]

Load user-selected task-specific model

Parameters

device (str) – device information

Returns

User-selected task-specific model

Return type

object

class pororo.tasks.word_translation.PororoWord2Word(model, config)[source]

Bases: pororo.tasks.utils.base.PororoSimpleBase

predict(word: str, **kwargs)[source]

Conduct word-to-word translation

Parameters

word (str) – input word to be translated

Returns

word translation candidates

Return type

List[str]