Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARNING: Language de package default expects mwt, which has been added #371

Open
milahu opened this issue Oct 15, 2023 · 0 comments
Open

Comments

@milahu
Copy link
Contributor

milahu commented Oct 15, 2023

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant