Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: components/translate/core/language_detection/language_detection_util.cc

Issue 1849323002: Adjusted to check language3[0] only and ignore the summary return. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/translate/core/language_detection/language_detection_util.cc
diff --git a/components/translate/core/language_detection/language_detection_util.cc b/components/translate/core/language_detection/language_detection_util.cc
index ddd8a9f91667f8760adb6db565ea859bce63472d..2204a134a9003f496f9baa7c85b54c47c7297de4 100644
--- a/components/translate/core/language_detection/language_detection_util.cc
+++ b/components/translate/core/language_detection/language_detection_util.cc
@@ -115,28 +115,29 @@ std::string DetermineTextLanguage(const base::string16& text,
CLD2::CLDHints cldhints = {code.c_str(), tld_hint, encoding_hint,
language_hint};
- cld_language = CLD2::ExtDetectLanguageSummaryCheckUTF8(
+ CLD2::ExtDetectLanguageSummaryCheckUTF8(
raw_utf8_bytes, num_utf8_bytes, is_plain_text, &cldhints, flags,
language3, percent3, normalized_score3,
nullptr /* No ResultChunkVector used */, &text_bytes, &is_reliable,
&num_bytes_evaluated);
if (num_bytes_evaluated < num_utf8_bytes &&
- cld_language == CLD2::UNKNOWN_LANGUAGE) {
+ language3[0] == CLD2::UNKNOWN_LANGUAGE) {
// Invalid UTF8 encountered, see bug http://crbug.com/444258.
// Retry using only the valid characters. This time the check for valid
// UTF8 can be skipped since the precise number of valid bytes is known.
- cld_language = CLD2::ExtDetectLanguageSummary(
+ CLD2::ExtDetectLanguageSummary(
raw_utf8_bytes, num_utf8_bytes, is_plain_text, &cldhints, flags,
language3, percent3, normalized_score3,
nullptr /* No ResultChunkVector used */, &text_bytes, &is_reliable);
}
+ // Choose top language.
+ cld_language = language3[0];
+
is_valid_language = cld_language != CLD2::NUM_LANGUAGES &&
cld_language != CLD2::UNKNOWN_LANGUAGE &&
cld_language != CLD2::TG_UNKNOWN_LANGUAGE;
- // Choose top language.
- cld_language = language3[0];
UMA_HISTOGRAM_ENUMERATION("Translate.CLD2.LanguageDetected",
cld_language, CLD2::NUM_LANGUAGES);
if (is_valid_language)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698