[英]How to load multiple XML files of corpora with NLTK and use it as a whole with Text class?
[英]How to use multiple corpora files to use as parallel corpora in Watson Language Translator in Python
Watson語言翻譯文檔說:
“TMX文件,包含源語言和目標語言的並行句子。您可以在一個請求中上傳多個parallel_corpus文件。所有上傳的parallel_corpus文件合並后,您的並行語料庫必須包含至少5,000個並行句子才能成功訓練。”
我有很多語料庫文件,我會用它來訓練我的翻譯模型。 我已經查找了以編程方式執行此操作的可能方法,但沒有成功。
我發現這樣做的唯一方法是將它們手動合並到一個文件中。
有沒有辦法通過API將多個文件作為並行語料庫發送?
你能提供Python或Curl的例子嗎?
謝謝。
唯一正常工作的是手動聚合.TMX文件並只發送一個文件。 我還沒有找到任何方式將多個文件作為parallel_corpora發送
with open("./training/my_corpus_SPA.TMX", "rb") as parallel:
custom_model = language_translation.create_model(
base_model_id = 'en-es',
name = 'en-es-base1xx',
#forced_glossary = glossary,
parallel_corpus = parallel).get_result()
print(json.dumps(custom_model, indent=2))
我想我在這里找到了解決方案
我試過這個似乎工作:
open(corpus_fname1, 'rb')
為parallel1
, open(corpus_fname2, 'rb')
為parallel2
:
custom_model = language_translation.create_model(
base_model_id = base_model_es_en,
name = model01_name,
parallel_corpus = parallel1,
parallel_corpus_filename2 = parallel2,
forced_glossary=None).get_result()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.