About the dictionary
, example
and alternative
methods
#62
Replies: 2 comments 6 replies
-
@ZhymabekRoman what do you think about this ? |
Beta Was this translation helpful? Give feedback.
-
I thought about implementing class ExampleResultList:
def __init__(self, service, source, source_language, destination_language, results):
self.service = service
self.source = str(source)
self.source_language = Language(source_language)
self.destination_language = Language(destination_language)
self.results = results # results = [ExampleResult(...), ExampleResult(...)]
class ExampleResult:
source_result: # Hello, how are you
destination_result: # Hola, ¿cómo estás?
reference: # The source from which the example was taken. Can be None, because not all translators provide this parameter (for example Bing and Microsoft), and even if they do, they vary greatly (for example Reverso and Yandex). I think it would be better if each translator returned a own `ReferenceResponse` model.
# And i think 'refernce' model field can be renamed to 'source', but i am not sure
# Supported by translate service, but not implemented by translatepy example method: DeepL, Google At the moment I can't say anything definite about the dictionary, I haven't even started to look at what the translation services return, I'm afraid they will have to sweat to bring all the translators into a unified response model
It's great idea, really necessary and useful functionality, all translators support it. With Lazy-load mechanism using property would be awesome By the way, someone decided to make a port of translatepy in C#, the logic of all translators is very similar to what is implemented |
Beta Was this translation helpful? Give feedback.
-
The
dictionary
andexample
methods are now too unstable/variable to be used.Indeed, the values returned varies from one translator to another.
I wonder if it shouldn't be better to modify those methods :
example
should output a list of examples to use the given word. I also wonder what we should do with translators also returning the position of the word in the resulting sentences (maybe we should make a special “Result” class which holds the data and having the attributes storing the position of the word as nullable)dictionary
should output a list of definitions of the given word, as expected of a dictionary. It might also give some features (etymology, gender, etc.).alternative
should be a new method which outputs a list of alternative translations. We should maybe add a python property to theTranslationResult
model, which holds aAlternativeResult
model if already given when translating by the translator, or which fetches alternatives if it doesn't.Beta Was this translation helpful? Give feedback.
All reactions