Skip to main content

机翻引擎

Project description

快速上手

# 导入翻译类
from mt_engines import MTTranslator
# 初始化翻译引擎
'''
translator = MTTranslator('Google')
translator = MTTranslator('Deepl', key='***')
translator = MTTranslator('Tencent', id='***', key='***', region='***')
'''
translator = MTTranslator('Google')
# 查看翻译引擎支持的语种名称
translator.support_languages
# 单个文本翻译
result = translator.translate('待翻文本','zh-CN','en')
# 多个待翻译文本
result = translator.pool_translate(['待翻文本1','待翻文本2','待翻文本3'],'zh-CN','en')
# 导入待翻译文件
translator.load_file('翻译表.xlsx')
# 翻译加载的文件,第3个参数为元组,输入待翻译文件的起始行,终止行,原文列,译文列
translator.translate_file('zh-CN','en',(1,'auto',1,2))
# 启用均衡算法进行批量机翻
result = translator.compress_translate(    ['待翻文本1','待翻文本2','待翻文本3'],    'zh-CN',    'en',     thread_num=3,     max_words=2000)
# 在文件翻译中启用均衡算法
result = translator.translate_file('zh-CN','en',(1,'auto',1,2),compress=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mt_engines-2.0.0-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page