2020-06-08 12:09:24 +02:00
|
|
|
class Translated:
|
2017-03-15 13:42:54 +01:00
|
|
|
"""Translate result object
|
2015-06-06 07:44:15 +02:00
|
|
|
|
|
|
|
:param src: source langauge (default: auto)
|
|
|
|
:param dest: destination language (default: en)
|
|
|
|
:param origin: original text
|
|
|
|
:param text: translated text
|
2017-03-15 13:42:54 +01:00
|
|
|
:param pronunciation: pronunciation
|
2015-06-06 07:44:15 +02:00
|
|
|
"""
|
2018-05-06 14:14:06 +02:00
|
|
|
def __init__(self, src, dest, origin, text, pronunciation, extra_data=None):
|
2015-06-06 07:44:15 +02:00
|
|
|
self.src = src
|
|
|
|
self.dest = dest
|
|
|
|
self.origin = origin
|
|
|
|
self.text = text
|
|
|
|
self.pronunciation = pronunciation
|
2018-05-06 14:14:06 +02:00
|
|
|
self.extra_data = extra_data
|
2015-06-06 07:44:15 +02:00
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
def __str__(self): # pragma: nocover
|
2015-06-06 07:44:15 +02:00
|
|
|
return self.__unicode__()
|
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
def __unicode__(self): # pragma: nocover
|
2020-06-08 12:09:24 +02:00
|
|
|
return (
|
|
|
|
u'Translated(src={src}, dest={dest}, text={text}, pronunciation={pronunciation}, '
|
|
|
|
u'extra_data={extra_data})'.format(
|
|
|
|
src=self.src, dest=self.dest, text=self.text,
|
|
|
|
pronunciation=self.pronunciation,
|
|
|
|
extra_data='"' + repr(self.extra_data)[:10] + '..."'
|
|
|
|
)
|
|
|
|
)
|
2015-06-06 07:44:15 +02:00
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
|
2020-06-08 12:09:24 +02:00
|
|
|
class Detected:
|
2017-03-15 13:42:54 +01:00
|
|
|
"""Language detection result object
|
2015-06-06 07:44:15 +02:00
|
|
|
|
|
|
|
:param lang: detected language
|
2017-03-15 13:42:54 +01:00
|
|
|
:param confidence: the confidence of detection result (0.00 to 1.00)
|
2015-06-06 07:44:15 +02:00
|
|
|
"""
|
|
|
|
def __init__(self, lang, confidence):
|
|
|
|
self.lang = lang
|
|
|
|
self.confidence = confidence
|
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
def __str__(self): # pragma: nocover
|
2015-06-06 07:44:15 +02:00
|
|
|
return self.__unicode__()
|
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
def __unicode__(self): # pragma: nocover
|
2017-03-15 13:42:54 +01:00
|
|
|
return u'Detected(lang={lang}, confidence={confidence})'.format(
|
2020-06-08 12:09:24 +02:00
|
|
|
lang=self.lang, confidence=self.confidence)
|