[languages] Earlier exit on finding ambiguous script spans

This commit is contained in:
Al
2015-08-24 03:07:45 -04:00
parent 90f333b16c
commit fa7b855ecb
2 changed files with 5 additions and 5 deletions

View File

@@ -208,13 +208,13 @@ def disambiguate_language(text, languages):
elif len(valid_default) == 1:
current_lang = valid_default[0]
if any((current_lang not in langs for script, langs in script_langs.iteritems())):
return AMBIGUOUS_LANGUAGE
seen_languages.update(valid)
if current_lang is not None:
if not any((current_lang not in langs for script, langs in script_langs.iteritems())):
return current_lang
else:
return AMBIGUOUS_LANGUAGE
return current_lang
elif possible_lang is not None:
if not any((possible_lang not in langs for script, langs in script_langs.iteritems())):
return possible_lang