Changeset View
Changeset View
Standalone View
Standalone View
src/core/guesslanguage.cpp
Show First 20 Lines • Show All 562 Lines • ▼ Show 20 Line(s) | 560 | for (const QString &suggestion : suggestionsListIn) { | |||
---|---|---|---|---|---|
563 | } | 563 | } | ||
564 | } | 564 | } | ||
565 | 565 | | |||
566 | // Load the model on demand | 566 | // Load the model on demand | ||
567 | if (d->s_knownModels.isEmpty()) { | 567 | if (d->s_knownModels.isEmpty()) { | ||
568 | d->loadModels(); | 568 | d->loadModels(); | ||
569 | } | 569 | } | ||
570 | 570 | | |||
571 | QStringList candidateLanguages = d->identify(text, d->findRuns(text)); | 571 | const QList<QChar::Script> scriptsList = d->findRuns(text); | ||
572 | | ||||
573 | QStringList candidateLanguages = d->identify(text, scriptsList); | ||||
apol: Shouldn't identify be taking care of the scripts already? | |||||
identify() fails if a certain language is not present in the trigrams. waqar:
`identify()` fails if a certain language is not present in the trigrams. | |||||
Why did you handle it here rather than in identify then? is it a problem doing it there? I see that identify is being used elsewhere too. It will be wrong there. apol: Why did you handle it here rather than in identify then? is it a problem doing it there? I see… | |||||
Initially I handled it in identify () but then @mludwig suggested that I do it here instead waqar: Initially I handled it in identify () but then @mludwig suggested that I do it here instead | |||||
574 | | ||||
575 | //if guessing from trigrams fail | ||||
576 | for (const QChar::Script script : scriptsList) { | ||||
Couldn't this if-statement can be dropped? I guess one can argue that sometimes there may be a language without trigrams that would even be a better language guess? mludwig: Couldn't this if-statement can be dropped? I guess one can argue that sometimes there may be a… | |||||
waqar: Yeah, I think so too | |||||
577 | const auto languagesList = d->s_scriptLanguages.values(script); | ||||
578 | for (const QString &lang : languagesList) { | ||||
579 | if (!d->s_knownModels.contains(lang)) | ||||
580 | candidateLanguages.append(lang); | ||||
581 | } | ||||
582 | } | ||||
572 | 583 | | |||
573 | // Hack for some bad dictionary names | 584 | // Hack for some bad dictionary names | ||
574 | for (int i = 0; i < candidateLanguages.count(); i++) { | 585 | for (int i = 0; i < candidateLanguages.count(); i++) { | ||
575 | if (d->s_dictionaryNameMap.contains(candidateLanguages[i])) { | 586 | if (d->s_dictionaryNameMap.contains(candidateLanguages[i])) { | ||
576 | candidateLanguages[i] = d->s_dictionaryNameMap.value(candidateLanguages[i]); | 587 | candidateLanguages[i] = d->s_dictionaryNameMap.value(candidateLanguages[i]); | ||
577 | } | 588 | } | ||
578 | } | 589 | } | ||
579 | 590 | | |||
▲ Show 20 Lines • Show All 261 Lines • Show Last 20 Lines |
Shouldn't identify be taking care of the scripts already?