SethRobinson / UGT

Universal Game Translator - Uses Google's Cloud Vision to read and speak dialog from any image/game in any language
https://www.codedojo.com/?p=2426
Other
120 stars 24 forks source link

Multi detectedLanguage prefers last entry #31

Closed Meerkov closed 3 years ago

Meerkov commented 3 years ago
cJSON_ArrayForEach(detectedLanguage, detectedLanguages)
  {
    const cJSON *languageCode = cJSON_GetObjectItemCaseSensitive(detectedLanguage, "languageCode");
    textArea.language = languageCode->valuestring;
    //LogMsg("Found language %s", languageCode->valuestring);
  }

This code iterates over the detected languages, and chooses the language code that is the last entry.

I've seen for example, both a ja and no detected as languages with equal confidence. I'm not sure if multiple languages can appear with unequal confidence, but if so, it should preserve the most likely language. In the case of a tie, I think it should prefer the first entry.

Meerkov commented 3 years ago

Worth noting: I don't actually know if this causes any bugs, I just happened to notice it.

SethRobinson commented 3 years ago

Sounds good, changed so it breaks after the first language instead of the last