Skip to content

Commit

Permalink
Slightly improved language detection from cld3.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Dec 8, 2022
1 parent 95d14bb commit 68e0b6f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions spellcheck/third_party/language_cld3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ RecognitionResult Recognize(QStringView text) {
const auto string = std::string(text.toUtf8().constData());
const auto results = lang_id.FindTopNMostFreqLangs(string, kMaxLangs);

auto maxProbability = 0.;
auto maxRatio = 0.;
auto final = NNetLanguageIdentifier::Result();
for (const auto &result : results) {
if (result.probability > maxProbability) {
maxProbability = result.probability;
const auto ratio = result.probability * result.proportion;
if (ratio > maxRatio) {
maxRatio = ratio;
final = result;
}
}
Expand Down

0 comments on commit 68e0b6f

Please sign in to comment.