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

Side by Side Diff: components/translate/core/language_detection/language_detection_util.cc

Issue 2359793003: Modifying language detection code (Closed)
Patch Set: Extending the comment about xx-Latn languages Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | extensions/renderer/i18n_custom_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/translate/core/language_detection/language_detection_util.h " 5 #include "components/translate/core/language_detection/language_detection_util.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 pred_lang_hash); 190 pred_lang_hash);
191 if (predicted_language != chrome_lang_id::NNetLanguageIdentifier::kUnknown) { 191 if (predicted_language != chrome_lang_id::NNetLanguageIdentifier::kUnknown) {
192 UMA_HISTOGRAM_PERCENTAGE("Translate.CLD3.LanguagePercentage", 192 UMA_HISTOGRAM_PERCENTAGE("Translate.CLD3.LanguagePercentage",
193 static_cast<int>(100 * lang_id_result.proportion)); 193 static_cast<int>(100 * lang_id_result.proportion));
194 } 194 }
195 195
196 if (is_cld_reliable != NULL) { 196 if (is_cld_reliable != NULL) {
197 *is_cld_reliable = prediction_reliable; 197 *is_cld_reliable = prediction_reliable;
198 } 198 }
199 199
200 // Ignore unreliable, "unknown", and xx-Latn predictions that are currently
201 // not supported.
200 if (prediction_reliable && 202 if (prediction_reliable &&
203 predicted_language != "bg-Latn" &&
204 predicted_language != "el-Latn" &&
205 predicted_language != "ja-Latn" &&
206 predicted_language != "ru-Latn" &&
207 predicted_language != "zh-Latn" &&
201 predicted_language != 208 predicted_language !=
202 chrome_lang_id::NNetLanguageIdentifier::kUnknown) { 209 chrome_lang_id::NNetLanguageIdentifier::kUnknown) {
203 // CLD3 returns 'zh' for Chinese but Translate doesn't accept it. Thus, 210 // CLD3 returns 'zh' for Chinese but Translate doesn't accept it. Thus,
204 // analogously to CLD2, 'zh-CN' is returned instead. 211 // analogously to CLD2, 'zh-CN' is returned instead.
205 if (predicted_language == "zh") { 212 if (predicted_language == "zh") {
206 language = "zh-CN"; 213 language = "zh-CN";
207 } else { 214 } else {
208 language = predicted_language; 215 language = predicted_language;
209 } 216 }
210 } 217 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 // distinguish from English, and the language is one of well-known languages 425 // distinguish from English, and the language is one of well-known languages
419 // which often provide "en-*" meta information mistakenly. 426 // which often provide "en-*" meta information mistakenly.
420 for (size_t i = 0; i < arraysize(kWellKnownCodesOnWrongConfiguration); ++i) { 427 for (size_t i = 0; i < arraysize(kWellKnownCodesOnWrongConfiguration); ++i) {
421 if (cld_language == kWellKnownCodesOnWrongConfiguration[i]) 428 if (cld_language == kWellKnownCodesOnWrongConfiguration[i])
422 return true; 429 return true;
423 } 430 }
424 return false; 431 return false;
425 } 432 }
426 433
427 } // namespace translate 434 } // namespace translate
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/i18n_custom_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698