Skip to content
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

Problem with alignment information. #23

Open
skharenko-DS opened this issue Dec 6, 2021 · 0 comments
Open

Problem with alignment information. #23

skharenko-DS opened this issue Dec 6, 2021 · 0 comments

Comments

@skharenko-DS
Copy link

skharenko-DS commented Dec 6, 2021

I have next code:

def translate(
        from_lang: str,
        to_lang: str,
        texts: List[str],
        include_alignment: bool = True
    ) -> List[JSONType]:
        constructed_url = "https://api.cognitive.microsofttranslator.com/translate"
        params = {
            "api-version": "3.0",
            "from": from_lang,
            "to": to_lang,
            "includeAlignment": include_alignment,
            "includeSentenceLength": True,
        }
        headers = {
            "Ocp-Apim-Subscription-Key": "*******",
            "Ocp-Apim-Subscription-Region": "GLOBAL",
            "Content-type": "application/json",
            "X-ClientTraceId": str(uuid.uuid4()),
        }
        body = [{"text": text} for text in texts]
        request = requests.post(
            constructed_url, params=params, headers=headers, json=body
        )
        resp = request.json()
        return resp
result = translate("de", "en", ["Artikelnummer des Kunden"])

and i have a result
{'translations': [{'text': "Customer's item number", 'to': 'en', 'alignment': {'proj': '0:12-11:14 0:12-16:21 14:16-0:9'}, 'sentLen': {'srcSentLen': [24], 'transSentLen': [22]}}]}
so if we look at result:
Original: Artikelnummer des Kunden
Translation: Customer's item number
we see that we have no alignment for the original word "Kunden".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant