From 381736f8fb9b60a929002cc750bd0df3d7dad03a Mon Sep 17 00:00:00 2001 From: John Bauer Date: Sat, 2 Mar 2024 13:52:19 -0800 Subject: [PATCH] Avoid a crash in a specific circumstance with a new language, and add a note on how to develop a new language's Pipeline. Related to https://github.com/stanfordnlp/stanza/issues/1360 --- stanza/pipeline/core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stanza/pipeline/core.py b/stanza/pipeline/core.py index 6d2775efae..f9d0cfad03 100644 --- a/stanza/pipeline/core.py +++ b/stanza/pipeline/core.py @@ -230,8 +230,12 @@ def __init__(self, logger.info(f'"{lang}" is an alias for "{resources[lang]["alias"]}"') lang = resources[lang]['alias'] lang_name = resources[lang]['lang_name'] if 'lang_name' in resources[lang] else '' + elif allow_unknown_language: + logger.warning("Trying to create pipeline for unsupported language: %s", lang) + lang_name = langcode_to_lang(lang) else: - logger.warning(f'Unsupported language: {lang}.') + logger.warning("Unsupported language: %s If trying to add a new language, consider using allow_unknown_language=True", lang) + lang_name = langcode_to_lang(lang) # Maintain load list if lang in resources: @@ -255,7 +259,6 @@ def __init__(self, elif allow_unknown_language: self.load_list = [(proc, [ModelSpecification(processor=proc, package='default', dependencies=None)]) for proc in list(processors.keys())] - lang_name = langcode_to_lang(lang) else: self.load_list = [] self.load_list = self.update_kwargs(kwargs, self.load_list)