From 5c5f8c0a72f43ba2139185786b4e08884096b8fa Mon Sep 17 00:00:00 2001 From: ines Date: Sun, 16 Apr 2017 22:14:38 +0200 Subject: [PATCH] Check if full string is found in lang classes first This allows users to set arbitrary strings. (Otherwise, custom lang class "my_custom_class" would always load Burmese "my" tokenizer if one was available.) --- spacy/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/util.py b/spacy/util.py index 573489682..f807dae9e 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -20,9 +20,11 @@ def set_lang_class(name, cls): def get_lang_class(name): + if name in LANGUAGES: + return LANGUAGES[name] lang = re.split('[^a-zA-Z0-9]', name, 1)[0] if lang not in LANGUAGES: - raise RuntimeError('Language not supported: %s' % lang) + raise RuntimeError('Language not supported: %s' % name) return LANGUAGES[lang]