Skip to content

Commit

Permalink
Avoid a crash in a specific circumstance with a new language, and add…
Browse files Browse the repository at this point in the history
… a note on how to develop a new language's Pipeline. Related to #1360
  • Loading branch information
AngledLuffa authored and Jemoka committed Jul 16, 2024
1 parent 64727bc commit fab0c74
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stanza/pipeline/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit fab0c74

Please sign in to comment.