pythainlp.translate

The pythainlp.translate for machine translation.

Modules

class pythainlp.translate.Translate(src_lang: str, target_lang: str)[source]

Machine Translation

Parameters
  • src_lang (str) – source language

  • target_lang (str) – target language

Options for source & target language
  • th - en - Thai to English

  • en - th - English to Thai

  • th - zh - Thai to Chinese

  • zh - th - Chinese to Thai

  • th - fr - Thai to French

Example

Translate text from Thai to English:

from pythainlp.translate import Translate
th2en = Translate('th', 'en')

th2en.translate("ฉันรักแมว")
# output: I love cat.
translate(text) str[source]

Translate text

Parameters

text (str) – input text in source language

Returns

translated text in target language

Return type

str

pythainlp.translate.en_th.download_model_all() None[source]

Download all translation models in advanced

class pythainlp.translate.en_th.EnThTranslator[source]

English-Thai Machine Translation

from VISTEC-depa Thailand Artificial Intelligence Research Institute

Website: https://airesearch.in.th/releases/machine-translation-models/

class pythainlp.translate.en_th.ThEnTranslator[source]

Thai-English Machine Translation

from VISTEC-depa Thailand Artificial Intelligence Research Institute

Website: https://airesearch.in.th/releases/machine-translation-models/

class pythainlp.translate.zh_th.ThZhTranslator(pretrained: str = 'Lalita/marianmt-th-zh_cn')[source]

Thai-Chinese Machine Translation

from Lalita @ AI builder

class pythainlp.translate.zh_th.ZhThTranslator(pretrained: str = 'Lalita/marianmt-zh_cn-th')[source]

Chinese-Thai Machine Translation

from Lalita @ AI builder

class pythainlp.translate.th_fr.ThFrTranslator(pretrained: str = 'Helsinki-NLP/opus-mt-th-fr')[source]

Thai-French Machine Translation

Trained by OPUS Corpus

Model from Language Technology Research Group at the University of Helsinki

BLEU 20.4