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

Innacurate source language detection #57

Open
LuisC360 opened this issue Dec 20, 2024 · 0 comments
Open

Innacurate source language detection #57

LuisC360 opened this issue Dec 20, 2024 · 0 comments

Comments

@LuisC360
Copy link

I don't know why this happens, but when I try to get the source language of a small snippet of text, it always gives me an innacurate source language code.

To Reproduce

const { Translator } = require('deepl-node');

const apiKey = process.env.DEEPL_API_KEY;
const translator = apiKey ? new Translator(apiKey) : null;

// Assume text === "Paso uno", source language is Spanish ('es')
async function getSourceLanguage(text) {
   if (!translator) {
      return 'en';
   }

  try {
    const translation = await translator.translateText(text, null, target_lang='EN-GB');
    return translation.detectedSourceLang; // Got Italian ('it') as the detected source language
  } catch (error) {
    console.error('DeepL API error: ', error);
  }
}

Expected behavior
The function should return 'es' for the assumed input

Additional context
Library version "^1.14.0"

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