-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Normalized translation return object/dict #139
Comments
Good advice. |
(Also answering your comment on #140) I see your point (especially dropping is_detail_result which is useless since the output is unpredictable), but then again the language detection of other services/libraries is probably by far not as good in as the available translation services, which are most like based on deep recurrent neural networks, which do an excellent job at precisely this task. I am not sure how you extract the translated text, but if it is a hardcoded accessor adding the detected source language wouldnt be that much of a hassle, if it is there at all, but I assume that most tranlators provide it. Some thoughs on the proposed return data:
As you can see there is a need.
Regards |
Expect to happened
It would be very useful if there was a way to get a normalized return object/dict from a translation request.
I like that translate_text() returns a dict of the raw data from the translator.
The problem is that each translator returns a dict that is vastly different from every other translator's dict format.
Bing returns:
Google returns:
This makes it very difficult to parse the returned value of translate_text() if you switch translators, or if they decide to change their return format.
As the project's goal is to make translation agnostic of which translator I use, it would be nice if the the project's API provided me with a consistently formatted return value (either via translate_text() or a new function ). The API could parse and map the translator's returned dict into a normalized dict.
What I am looking for is translate_text() to return a dict, regardless of what translation engine was used, with the following keys
Maybe make a new function call that does this. So, that translate_text() remains backwards compatible. Or, put in an input parameter in the **kwargs (e.g., :param if_normalize_dict: bool, default False) that changes the returned dict from the current type to the normalized type.
Another option is a host of functions that provide the same information atomically from the last time translate_text() was run.
For example, detectLanugage(), translatedText(), translatorUsed(), etc.
Thank you
Expected APP Version
next newest version
Expected Python Version
Expected Runtime Environment
NoArch (Default)
Country/Region
Denmark
Expected Output
Code of Conduct
The text was updated successfully, but these errors were encountered: