WARNING: Language de package default expects mwt, which has been added
milahu opened this issue · comments
milahu commented
im using argos-translate-html like in the example code
import argostranslate.package, argostranslate.translate
import translatehtml
from_code = "de"
to_code = "en"
with open("input.html", "r") as f:
html_doc = f.read()
# Translate
installed_languages = argostranslate.translate.get_installed_languages()
from_lang = list(filter(lambda x: x.code == from_code, installed_languages))[0]
to_lang = list(filter(lambda x: x.code == to_code, installed_languages))[0]
translation = from_lang.get_translation(to_lang)
# this produces the warnings
translated_soup = translatehtml.translate_html(translation, html_doc)
print(translated_soup)
running the code floods my terminal with
WARNING: Language de package default expects mwt, which has been added
how can i add mwt
to avoid these warnings?
the warnings are produced by stanza
logger = logging.getLogger('stanza')
logger.warning("Language %s package %s expects mwt, which has been added", lang, value)
quickfix:
#!/usr/bin/env python3
import sys
# https://github.com/argosopentech/argos-translate
import argostranslate.translate
# hide warnings: "Language %s package %s expects mwt, which has been added"
import logging
#logging.getLogger("stanza").setLevel(logging.ERROR) # no effect
logging.getLogger("stanza").disabled = True
input_text = sys.stdin.read()
from_code = sys.argv[1]
to_code = sys.argv[2]
translated_text = argostranslate.translate.translate(input_text, from_code, to_code)
sys.stdout.write(translated_text)