From aad26000ddab54dc25356a52679dc000409839f5 Mon Sep 17 00:00:00 2001 From: John Lambert Date: Mon, 20 Nov 2023 12:45:11 -0500 Subject: [PATCH] Better error messages for #62 --- .../translation/huggingface/hugging_face_nmt_engine.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/machine/translation/huggingface/hugging_face_nmt_engine.py b/machine/translation/huggingface/hugging_face_nmt_engine.py index e730d16..8191075 100644 --- a/machine/translation/huggingface/hugging_face_nmt_engine.py +++ b/machine/translation/huggingface/hugging_face_nmt_engine.py @@ -47,14 +47,18 @@ def __init__( and src_lang not in cast(Any, self._tokenizer).lang_code_to_id and src_lang not in additional_special_tokens ): - raise ValueError(f"'{src_lang}' is not a valid language code.") + raise ValueError( + f"'{src_lang}' is not a valid language code. This error can happen when there is no matching training data and the language code is not in the NLLB-200." + ) if ( tgt_lang is not None and tgt_lang not in cast(Any, self._tokenizer).lang_code_to_id and tgt_lang not in additional_special_tokens ): - raise ValueError(f"'{tgt_lang}' is not a valid language code.") + raise ValueError( + f"'{tgt_lang}' is not a valid language code. This error can happen when there is no matching training data and the language code is not in the NLLB-200." + ) self._pipeline = _TranslationPipeline( model=model,