OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "encodings/compact_lang_det/win/cld_unicodetext.h" | 5 #include "encodings/compact_lang_det/win/cld_unicodetext.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> // to compile bar/common/component.h | 8 #include <vector> // to compile bar/common/component.h |
9 | 9 |
10 #include "encodings/compact_lang_det/compact_lang_det.h" | 10 #include "encodings/compact_lang_det/compact_lang_det.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 utf8_encoded.c_str(), | 65 utf8_encoded.c_str(), |
66 utf8_encoded.length(), | 66 utf8_encoded.length(), |
67 is_plain_text, language3, percent3, | 67 is_plain_text, language3, percent3, |
68 &text_bytes_tmp, is_reliable); | 68 &text_bytes_tmp, is_reliable); |
69 | 69 |
70 // Calcualte a number of languages detected in more than 20% of the text. | 70 // Calcualte a number of languages detected in more than 20% of the text. |
71 const int kMinTextPercentToCountLanguage = 20; | 71 const int kMinTextPercentToCountLanguage = 20; |
72 *num_languages = 0; | 72 *num_languages = 0; |
73 if (text_bytes) | 73 if (text_bytes) |
74 *text_bytes = text_bytes_tmp; | 74 *text_bytes = text_bytes_tmp; |
75 COMPILE_ASSERT(arraysize(language3) == arraysize(percent3), | |
76 language3_and_percent3_should_be_of_the_same_size); | |
77 for (int i = 0; i < arraysize(language3); ++i) { | 75 for (int i = 0; i < arraysize(language3); ++i) { |
78 if (IsValidLanguage(language3[i]) && !IS_LANGUAGE_UNKNOWN(language3[i]) && | 76 if (IsValidLanguage(language3[i]) && !IS_LANGUAGE_UNKNOWN(language3[i]) && |
79 percent3[i] >= kMinTextPercentToCountLanguage) { | 77 percent3[i] >= kMinTextPercentToCountLanguage) { |
80 ++*num_languages; | 78 ++*num_languages; |
81 } | 79 } |
82 } | 80 } |
83 | 81 |
84 return language3[0]; | 82 return language3[0]; |
85 } | 83 } |
OLD | NEW |