Skip to content

The example function in YandexTranslate without translation #101

@AlexK-1

Description

@AlexK-1

To get examples of sentences with a word in English, I use the YandexTranslate class function example. This function has the parameters destination_language and source_language and when they are equal, the error ParameterValueError: Parameter source_language cannot be equal to the destination_language parameter appears. Although in the documentation
Yandex API
says that you can use a language pair with the same languages.

To get around this error, I have to translate the word I need, and then specify the translation back to the source language in the example function. This leads to incorrect results.

The Yandex API allows (if you believe the documentation) not to translate the word to search for suggestions, but the library returns an error.

Is it possible to search for example Yandex sentences through your library without translating the word?

The code I'm using now:

from translatepy.translators import YandexTranslate

translator = YandexTranslate()

word = "regale"

translated_word = translator.translate(word, "ru", "en")  # forced translation of a word from English
examples = translator.example(translated_word.result, "en", "ru")  # none of the sentences contain the word 'regale'

print(examples.result)

The code that I would like to use, but which returns an error:

from translatepy.translators import YandexTranslate

translator = YandexTranslate()

word = "regale"

examples = translator.example(word, "en", "en")  # ParameterValueError: Parameter source_language cannot be equal to the destination_language parameter

print(examples.result)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions