feature: format detection outputs (#207)
* feature: format detection output * feature: format detection outputs * feature: format detection outputs
This commit is contained in:
parent
e5c9505559
commit
0e1c9d1d52
@ -259,8 +259,12 @@ class Translator:
|
||||
src = ''
|
||||
confidence = 0.0
|
||||
try:
|
||||
src = ''.join(data[8][0])
|
||||
confidence = data[8][-2][0]
|
||||
if len(data[8][0]) > 1:
|
||||
src = data[8][0]
|
||||
confidence = data[8][-2]
|
||||
else:
|
||||
src = ''.join(data[8][0])
|
||||
confidence = data[8][-2][0]
|
||||
except Exception: # pragma: nocover
|
||||
pass
|
||||
result = Detected(lang=src, confidence=confidence)
|
||||
|
@ -84,18 +84,21 @@ def test_translate_list(translator):
|
||||
def test_detect_language(translator):
|
||||
ko = translator.detect(u'한국어')
|
||||
en = translator.detect('English')
|
||||
|
||||
rubg = translator.detect('тест')
|
||||
|
||||
assert ko.lang == 'ko'
|
||||
assert en.lang == 'en'
|
||||
assert rubg.lang == ['ru', 'bg']
|
||||
|
||||
|
||||
def test_detect_list(translator):
|
||||
items = [u'한국어', ' English']
|
||||
items = [u'한국어', ' English', 'тест']
|
||||
|
||||
result = translator.detect(items)
|
||||
|
||||
assert result[0].lang == 'ko'
|
||||
assert result[1].lang == 'en'
|
||||
assert result[2].lang == ['ru', 'bg']
|
||||
|
||||
|
||||
def test_src_in_special_cases(translator):
|
||||
|
Loading…
Reference in New Issue
Block a user