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"; |