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

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

Issue 1847713002: Add histograms to measure CLD2 language detection as well as the accuracy of the chosen detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asvitkine comment 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 | tools/metrics/histograms/histograms.xml » ('j') | 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 3b8bda76735e02b4023709e7775f60e0bd7432f3..ddd8a9f91667f8760adb6db565ea859bce63472d 100644
--- a/components/translate/core/language_detection/language_detection_util.cc
+++ b/components/translate/core/language_detection/language_detection_util.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -136,6 +137,12 @@ std::string DetermineTextLanguage(const base::string16& text,
// Choose top language.
cld_language = language3[0];
+ UMA_HISTOGRAM_ENUMERATION("Translate.CLD2.LanguageDetected",
+ cld_language, CLD2::NUM_LANGUAGES);
+ if (is_valid_language)
+ UMA_HISTOGRAM_PERCENTAGE("Translate.CLD2.LanguageAccuracy", percent3[0]);
+
+
#else
# error "CLD_VERSION must be 1 or 2"
#endif
@@ -152,7 +159,7 @@ std::string DetermineTextLanguage(const base::string16& text,
if (is_reliable && num_bytes_evaluated >= 100 && is_valid_language) {
// We should not use LanguageCode_ISO_639_1 because it does not cover all
// the languages CLD can detect. As a result, it'll return the invalid
- // language code for tradtional Chinese among others.
+ // language code for traditional Chinese among others.
// |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and
// 'other' tables to do the 'right' thing. In addition, it'll return zh-CN
// for Simplified Chinese.
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698