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

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

Issue 1920853002: Drop support for Compact Language Detector v1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Preserve yfriedman@ comment in chrome/android/chrome_apk.gyp Created 4 years, 8 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 | « components/translate/core/language_detection/BUILD.gn ('k') | extensions/BUILD.gn » ('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 ddd8a9f91667f8760adb6db565ea859bce63472d..7d34c913240263c6e34c68544d577acfdc4a2918 100644
--- a/components/translate/core/language_detection/language_detection_util.cc
+++ b/components/translate/core/language_detection/language_detection_util.cc
@@ -16,16 +16,8 @@
#include "components/translate/core/common/translate_constants.h"
#include "components/translate/core/common/translate_metrics.h"
#include "components/translate/core/common/translate_util.h"
-
-#if CLD_VERSION==1
-#include "third_party/cld/encodings/compact_lang_det/compact_lang_det.h"
-#include "third_party/cld/encodings/compact_lang_det/win/cld_unicodetext.h"
-#endif
-
-#if CLD_VERSION==2
#include "third_party/cld_2/src/public/compact_lang_det.h"
#include "third_party/cld_2/src/public/encodings.h"
-#endif
namespace {
@@ -90,15 +82,6 @@ std::string DetermineTextLanguage(const base::string16& text,
int cld_language = 0;
bool is_valid_language = false;
-#if CLD_VERSION==1
- int num_languages = 0;
- cld_language = DetectLanguageOfUnicodeText(NULL, text.c_str(), is_plain_text,
- &is_reliable, &num_languages, NULL,
- &num_bytes_evaluated);
- is_valid_language = cld_language != NUM_LANGUAGES &&
- cld_language != UNKNOWN_LANGUAGE &&
- cld_language != TG_UNKNOWN_LANGUAGE;
-#elif CLD_VERSION==2
const std::string utf8_text(base::UTF16ToUTF8(text));
const int num_utf8_bytes = static_cast<int>(utf8_text.size());
const char* raw_utf8_bytes = utf8_text.c_str();
@@ -142,11 +125,6 @@ std::string DetermineTextLanguage(const base::string16& text,
if (is_valid_language)
UMA_HISTOGRAM_PERCENTAGE("Translate.CLD2.LanguageAccuracy", percent3[0]);
-
-#else
-# error "CLD_VERSION must be 1 or 2"
-#endif
-
if (is_cld_reliable != NULL)
*is_cld_reliable = is_reliable;
@@ -163,9 +141,7 @@ std::string DetermineTextLanguage(const base::string16& text,
// |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.
-#if CLD_VERSION==1
- language = LanguageCodeWithDialects(static_cast<Language>(cld_language));
-#elif CLD_VERSION==2
+ //
// (1) CLD2's LanguageCode returns general Chinese 'zh' for
// CLD2::CHINESE, but Translate server doesn't accept it. This is
// converted to 'zh-CN' in the same way as CLD1's
@@ -181,9 +157,6 @@ std::string DetermineTextLanguage(const base::string16& text,
language = "zh-TW";
else
language = CLD2::LanguageCode(static_cast<CLD2::Language>(cld_language));
-#else
-# error "CLD_VERSION must be 1 or 2"
-#endif
}
VLOG(9) << "Detected lang_id: " << language << ", from Text:\n" << text
<< "\n*************************************\n";
« no previous file with comments | « components/translate/core/language_detection/BUILD.gn ('k') | extensions/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698