krukid-cld 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. data/LICENSE +27 -0
  2. data/Manifest +106 -0
  3. data/README.rdoc +173 -0
  4. data/Rakefile +15 -0
  5. data/base/basictypes.h +348 -0
  6. data/base/build_config.h +115 -0
  7. data/base/casts.h +156 -0
  8. data/base/commandlineflags.h +443 -0
  9. data/base/crash.h +41 -0
  10. data/base/dynamic_annotations.h +358 -0
  11. data/base/global_strip_options.h +59 -0
  12. data/base/log_severity.h +46 -0
  13. data/base/logging.h +1403 -0
  14. data/base/macros.h +243 -0
  15. data/base/port.h +54 -0
  16. data/base/scoped_ptr.h +428 -0
  17. data/base/stl_decl.h +0 -0
  18. data/base/stl_decl_msvc.h +107 -0
  19. data/base/string_util.h +29 -0
  20. data/base/strtoint.h +93 -0
  21. data/base/template_util.h +96 -0
  22. data/base/type_traits.h +198 -0
  23. data/base/vlog_is_on.h +143 -0
  24. data/build.sh +48 -0
  25. data/build.win.cmd +28 -0
  26. data/cld.gemspec +33 -0
  27. data/cld_encodings.h +95 -0
  28. data/encodings/compact_lang_det/#cldutil.cc# +905 -0
  29. data/encodings/compact_lang_det/#cldutil.h# +1205 -0
  30. data/encodings/compact_lang_det/#compact_lang_det_impl.h# +171 -0
  31. data/encodings/compact_lang_det/#ext_lang_enc.cc# +545 -0
  32. data/encodings/compact_lang_det/#ext_lang_enc.h# +119 -0
  33. data/encodings/compact_lang_det/#getonescriptspan.cc# +570 -0
  34. data/encodings/compact_lang_det/#getonescriptspan.h# +131 -0
  35. data/encodings/compact_lang_det/#tote.cc# +299 -0
  36. data/encodings/compact_lang_det/#tote.h# +89 -0
  37. data/encodings/compact_lang_det/cldutil.cc +905 -0
  38. data/encodings/compact_lang_det/cldutil.h +1205 -0
  39. data/encodings/compact_lang_det/cldutil_dbg.h +76 -0
  40. data/encodings/compact_lang_det/cldutil_dbg_empty.cc +76 -0
  41. data/encodings/compact_lang_det/compact_lang_det.cc +62 -0
  42. data/encodings/compact_lang_det/compact_lang_det.h +145 -0
  43. data/encodings/compact_lang_det/compact_lang_det_impl.cc +2574 -0
  44. data/encodings/compact_lang_det/compact_lang_det_impl.h +173 -0
  45. data/encodings/compact_lang_det/compact_lang_det_unittest_small.cc +406 -0
  46. data/encodings/compact_lang_det/compile.cmd +1 -0
  47. data/encodings/compact_lang_det/ext_lang_enc.cc +545 -0
  48. data/encodings/compact_lang_det/ext_lang_enc.h +119 -0
  49. data/encodings/compact_lang_det/generated/cld_generated_score_deltaoctachrome_0406.cc +380 -0
  50. data/encodings/compact_lang_det/generated/cld_generated_score_quadchrome_0406.cc +382 -0
  51. data/encodings/compact_lang_det/generated/compact_lang_det_generated_cjkbis_0.cc +49 -0
  52. data/encodings/compact_lang_det/generated/compact_lang_det_generated_ctjkvz.cc +7119 -0
  53. data/encodings/compact_lang_det/generated/compact_lang_det_generated_ctjkvz_0.cc +61 -0
  54. data/encodings/compact_lang_det/generated/compact_lang_det_generated_deltaoctachrome.cc +1263 -0
  55. data/encodings/compact_lang_det/generated/compact_lang_det_generated_longwords8_0.cc +53 -0
  56. data/encodings/compact_lang_det/generated/compact_lang_det_generated_meanscore.h +10 -0
  57. data/encodings/compact_lang_det/generated/compact_lang_det_generated_quads_0.cc +50 -0
  58. data/encodings/compact_lang_det/generated/compact_lang_det_generated_quadschrome.cc +70935 -0
  59. data/encodings/compact_lang_det/getonescriptspan.cc +570 -0
  60. data/encodings/compact_lang_det/getonescriptspan.h +131 -0
  61. data/encodings/compact_lang_det/letterscript_enum.cc +117 -0
  62. data/encodings/compact_lang_det/letterscript_enum.h +99 -0
  63. data/encodings/compact_lang_det/subsetsequence.cc +259 -0
  64. data/encodings/compact_lang_det/subsetsequence.h +44 -0
  65. data/encodings/compact_lang_det/subsetsequence_unittest.cc +99 -0
  66. data/encodings/compact_lang_det/tote.cc +299 -0
  67. data/encodings/compact_lang_det/tote.h +89 -0
  68. data/encodings/compact_lang_det/unittest_data.h +193 -0
  69. data/encodings/compact_lang_det/utf8propjustletter.h +1162 -0
  70. data/encodings/compact_lang_det/utf8propletterscriptnum.h +1222 -0
  71. data/encodings/compact_lang_det/utf8scannotjustletterspecial.h +1185 -0
  72. data/encodings/compact_lang_det/win/#cld_unilib_windows.cc# +29 -0
  73. data/encodings/compact_lang_det/win/cld_basictypes.h +10 -0
  74. data/encodings/compact_lang_det/win/cld_commandlineflags.h +28 -0
  75. data/encodings/compact_lang_det/win/cld_google.h +18 -0
  76. data/encodings/compact_lang_det/win/cld_htmlutils.h +13 -0
  77. data/encodings/compact_lang_det/win/cld_htmlutils_google3.cc +32 -0
  78. data/encodings/compact_lang_det/win/cld_htmlutils_windows.cc +29 -0
  79. data/encodings/compact_lang_det/win/cld_logging.h +21 -0
  80. data/encodings/compact_lang_det/win/cld_macros.h +19 -0
  81. data/encodings/compact_lang_det/win/cld_strtoint.h +26 -0
  82. data/encodings/compact_lang_det/win/cld_unicodetext.cc +84 -0
  83. data/encodings/compact_lang_det/win/cld_unicodetext.h +40 -0
  84. data/encodings/compact_lang_det/win/cld_unilib.h +15 -0
  85. data/encodings/compact_lang_det/win/cld_unilib_google3.cc +18 -0
  86. data/encodings/compact_lang_det/win/cld_unilib_windows.cc +29 -0
  87. data/encodings/compact_lang_det/win/cld_utf.h +24 -0
  88. data/encodings/compact_lang_det/win/cld_utf8statetable.cc +224 -0
  89. data/encodings/compact_lang_det/win/cld_utf8statetable.h +141 -0
  90. data/encodings/compact_lang_det/win/cld_utf8utils.h +22 -0
  91. data/encodings/compact_lang_det/win/cld_utf8utils_google3.cc +18 -0
  92. data/encodings/compact_lang_det/win/cld_utf8utils_windows.cc +17 -0
  93. data/encodings/compact_lang_det/win/normalizedunicodetext.cc +172 -0
  94. data/encodings/compact_lang_det/win/normalizedunicodetext.h +67 -0
  95. data/encodings/internal/encodings.cc +12 -0
  96. data/encodings/lang_enc.h +254 -0
  97. data/encodings/proto/encodings.pb.h +169 -0
  98. data/encodings/public/encodings.h +301 -0
  99. data/ext/cld/extconf.rb +8 -0
  100. data/krukid-cld.gemspec +33 -0
  101. data/languages/internal/#languages.cc# +337 -0
  102. data/languages/internal/languages.cc +337 -0
  103. data/languages/proto/languages.pb.h +179 -0
  104. data/languages/public/languages.h +379 -0
  105. data/lib/cld.rb +12 -0
  106. data/test/test.rb +570 -0
  107. data/thunk.cc +131 -0
  108. metadata +196 -0
data/test/test.rb ADDED
@@ -0,0 +1,570 @@
1
+ # Copyright (c) 2009 The Chromium Authors. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ require "test/unit"
6
+ require "ccld"
7
+
8
+ VERBOSE = False
9
+
10
+ # MKM: ported from FullTests in compact_lang_det_unittest_small.cc
11
+
12
+ class TestCLD(unittest.TestCase):
13
+
14
+ langsSeen = set()
15
+
16
+ def runOne(self, expectedLangName, s):
17
+ if VERBOSE:
18
+ print
19
+ print 'Test: %s [%d bytes]' % (expectedLangName, len(s))
20
+ detectedLangName, detectedLangCode, isReliable, textBytesFound, details = cld.detect(s, pickSummaryLanguage=True)
21
+ if VERBOSE:
22
+ print ' detected: %s' % detectedLangName
23
+ print ' reliable: %s' % (isReliable != 0)
24
+ print ' textBytes: %s' % textBytesFound
25
+ print ' details: %s' % str(details)
26
+ self.langsSeen.add(expectedLangName)
27
+ print ' %d langs' % len(self.langsSeen)
28
+ self.assertEquals(expectedLangName, detectedLangName)
29
+ self.assertTrue(isReliable)
30
+
31
+ def testAFRIKAANS(self):
32
+ self.runOne('AFRIKAANS', kTeststr_af_Latn)
33
+
34
+ # def testAFAR(self):
35
+ # self.runOne('AFAR', kTeststr_aa_Latn)
36
+
37
+ # def testABKHAZIAN(self):
38
+ # self.runOne('ABKHAZIAN', kTeststr_ab_Cyrl)
39
+
40
+ def testAFRIKAANS(self):
41
+ self.runOne('AFRIKAANS', kTeststr_af_Latn)
42
+
43
+ # def testAMHARIC(self):
44
+ # self.runOne('AMHARIC', kTeststr_am_Ethi)
45
+
46
+ def testARABIC(self):
47
+ self.runOne('ARABIC', kTeststr_ar_Arab)
48
+
49
+ # def testASSAMESE(self):
50
+ # self.runOne('ASSAMESE', kTeststr_as_Beng)
51
+
52
+ # def testAYMARA(self):
53
+ # self.runOne('AYMARA', kTeststr_ay_Latn)
54
+
55
+ # AZERBAIJANI Arab & Cyrl removed 2008.05.27. Just AZERBAIJANI Latn left
56
+ # def testAZERBAIJANI(self):
57
+ # self.runOne('AZERBAIJANI', kTeststr_az_Arab)
58
+
59
+ # Missing data: az-Cyrl
60
+ # def testAZERBAIJANI(self):
61
+ # self.runOne('AZERBAIJANI', kTeststr_az_Latn)
62
+
63
+ # def testBASHKIR(self):
64
+ # self.runOne('BASHKIR', kTeststr_ba_Cyrl)
65
+
66
+ def testBELARUSIAN(self):
67
+ self.runOne('BELARUSIAN', kTeststr_be_Cyrl)
68
+
69
+ def testBULGARIAN(self):
70
+ self.runOne('BULGARIAN', kTeststr_bg_Cyrl)
71
+
72
+ # def testBIHARI(self):
73
+ # self.runOne('BIHARI', kTeststr_bh_Deva)
74
+
75
+ # def testBISLAMA(self):
76
+ # self.runOne('BISLAMA', kTeststr_bi_Latn)
77
+
78
+ # def testBENGALI(self):
79
+ # self.runOne('BENGALI', kTeststr_bn_Beng)
80
+
81
+ # def testTIBETAN(self):
82
+ # self.runOne('TIBETAN', kTeststr_bo_Tibt)
83
+
84
+ # def testBRETON(self):
85
+ # self.runOne('BRETON', kTeststr_br_Latn)
86
+
87
+ def testSERBIAN(self):
88
+ self.runOne('SERBIAN', kTeststr_bs_Cyrl) # NOTE: Not BOSNIAN
89
+
90
+ # def testCROATIAN(self):
91
+ # self.runOne('CROATIAN', kTeststr_bs_Latn) # NOTE: Not BOSNIAN
92
+
93
+ def testCATALAN(self):
94
+ self.runOne('CATALAN', kTeststr_ca_Latn)
95
+
96
+ def testCHEROKEE(self):
97
+ self.runOne('CHEROKEE', kTeststr_chr_Cher)
98
+
99
+ # def testCORSICAN(self):
100
+ # self.runOne('CORSICAN', kTeststr_co_Latn)
101
+
102
+ # No CREOLES_AND_PIDGINS_ENGLISH_BASED
103
+ # No CREOLES_AND_PIDGINS_FRENCH_BASED
104
+ # No CREOLES_AND_PIDGINS_OTHER
105
+ # No CREOLES_AND_PIDGINS_PORTUGUESE_BASED
106
+ def testCZECH(self):
107
+ self.runOne('CZECH', kTeststr_cs_Latn)
108
+
109
+ def testWELSH(self):
110
+ self.runOne('WELSH', kTeststr_cy_Latn)
111
+
112
+ def testDANISH(self):
113
+ self.runOne('DANISH', kTeststr_da_Latn)
114
+
115
+ def testGERMAN(self):
116
+ self.runOne('GERMAN', kTeststr_de_Latn)
117
+
118
+ def testDHIVEHI(self):
119
+ self.runOne('DHIVEHI', kTeststr_dv_Thaa)
120
+
121
+ # def testDZONGKHA(self):
122
+ # self.runOne('DZONGKHA', kTeststr_dz_Tibt)
123
+
124
+ def testGREEK(self):
125
+ self.runOne('GREEK', kTeststr_el_Grek)
126
+
127
+ def testENGLISH(self):
128
+ self.runOne('ENGLISH', kTeststr_en_Latn)
129
+
130
+ def testENGLISH(self):
131
+ self.runOne('ENGLISH', kTeststr_en)
132
+
133
+ # def testESPERANTO(self):
134
+ # self.runOne('ESPERANTO', kTeststr_eo_Latn)
135
+
136
+ def testSPANISH(self):
137
+ self.runOne('SPANISH', kTeststr_es_Latn)
138
+
139
+ def testESTONIAN(self):
140
+ self.runOne('ESTONIAN', kTeststr_et_Latn)
141
+
142
+ # def testBASQUE(self):
143
+ # self.runOne('BASQUE', kTeststr_eu_Latn)
144
+
145
+ def testPERSIAN(self):
146
+ self.runOne('PERSIAN', kTeststr_fa_Arab)
147
+
148
+ def testFINNISH(self):
149
+ self.runOne('FINNISH', kTeststr_fi_Latn)
150
+
151
+ # def testFIJIAN(self):
152
+ # self.runOne('FIJIAN', kTeststr_fj_Latn)
153
+
154
+ # def testFAROESE(self):
155
+ # self.runOne('FAROESE', kTeststr_fo_Latn)
156
+
157
+ def testFRENCH(self):
158
+ self.runOne('FRENCH', kTeststr_fr_Latn)
159
+
160
+ # def testFRISIAN(self):
161
+ # self.runOne('FRISIAN', kTeststr_fy_Latn)
162
+
163
+ def testIRISH(self):
164
+ self.runOne('IRISH', kTeststr_ga_Latn)
165
+
166
+ # def testSCOTS_GAELIC(self):
167
+ # self.runOne('SCOTS_GAELIC', kTeststr_gd_Latn)
168
+
169
+ # def testGALICIAN(self):
170
+ # self.runOne('GALICIAN', kTeststr_gl_Latn)
171
+
172
+ # def testGUARANI(self):
173
+ # self.runOne('GUARANI', kTeststr_gn_Latn)
174
+
175
+ def testGUJARATI(self):
176
+ self.runOne('GUJARATI', kTeststr_gu_Gujr)
177
+
178
+ # def testMANX(self):
179
+ # self.runOne('MANX', kTeststr_gv_Latn)
180
+
181
+ # def testHAUSA(self):
182
+ # self.runOne('HAUSA', kTeststr_ha_Latn)
183
+
184
+ def testHINDI(self):
185
+ self.runOne('HINDI', kTeststr_hi_Deva)
186
+
187
+ def testHINDI2(self):
188
+ self.runOne('HINDI', kTeststr_ks)
189
+
190
+ def testCROATIAN(self):
191
+ self.runOne('CROATIAN', kTeststr_hr_Latn) # NOTE: now CROATIAN
192
+
193
+ # def testHAITIAN_CREOLE(self):
194
+ # self.runOne('HAITIAN_CREOLE', kTeststr_ht_Latn)
195
+
196
+ def testHUNGARIAN(self):
197
+ self.runOne('HUNGARIAN', kTeststr_hu_Latn)
198
+
199
+ def testARMENIAN(self):
200
+ self.runOne('ARMENIAN', kTeststr_hy_Armn)
201
+
202
+ # def testINTERLINGUA(self):
203
+ # self.runOne('INTERLINGUA', kTeststr_ia_Latn)
204
+
205
+ def testMALAY(self):
206
+ self.runOne('MALAY', kTeststr_id_Latn)
207
+
208
+ # def testINTERLINGUE(self):
209
+ # self.runOne('INTERLINGUE', kTeststr_ie_Latn)
210
+
211
+ # def testINUPIAK(self):
212
+ # self.runOne('INUPIAK', kTeststr_ik_Latn)
213
+
214
+ def testICELANDIC(self):
215
+ self.runOne('ICELANDIC', kTeststr_is_Latn)
216
+
217
+ def testITALIAN(self):
218
+ self.runOne('ITALIAN', kTeststr_it_Latn)
219
+
220
+ def testINUKTITUT(self):
221
+ self.runOne('INUKTITUT', kTeststr_iu_Cans)
222
+
223
+ def testHEBREW(self):
224
+ self.runOne('HEBREW', kTeststr_iw_Hebr)
225
+
226
+ def testJAPANESE(self):
227
+ self.runOne('Japanese', kTeststr_ja_Hani)
228
+
229
+ # def testJAVANESE(self):
230
+ # self.runOne('JAVANESE', kTeststr_jw_Latn)
231
+
232
+ def testGEORGIAN(self):
233
+ self.runOne('GEORGIAN', kTeststr_ka_Geor)
234
+
235
+ # def testKHASI(self):
236
+ # self.runOne('KHASI', kTeststr_kha_Latn)
237
+
238
+ # def testKAZAKH(self):
239
+ # self.runOne('KAZAKH', kTeststr_kk_Arab)
240
+
241
+ # def testKAZAKH(self):
242
+ # self.runOne('KAZAKH', kTeststr_kk_Cyrl)
243
+
244
+ # def testKAZAKH(self):
245
+ # self.runOne('KAZAKH', kTeststr_kk_Latn)
246
+
247
+ # def testGREENLANDIC(self):
248
+ # self.runOne('GREENLANDIC', kTeststr_kl_Latn)
249
+
250
+ def testKHMER(self):
251
+ self.runOne('KHMER', kTeststr_km_Khmr)
252
+
253
+ def testKANNADA(self):
254
+ self.runOne('KANNADA', kTeststr_kn_Knda)
255
+
256
+ def testKOREAN(self):
257
+ self.runOne('Korean', kTeststr_ko_Hani)
258
+
259
+ # def testKASHMIRI(self):
260
+ # self.runOne('KASHMIRI', kTeststr_ks_Deva)
261
+
262
+ # KURDISH Latn removed 2008.05.27. Just KURDISH Arab left
263
+ # def testKURDISH(self):
264
+ # self.runOne('KURDISH', kTeststr_ku_Arab)
265
+
266
+ # def testKURDISH(self):
267
+ # self.runOne('KURDISH', kTeststr_ku_Latn)
268
+
269
+ # def testKYRGYZ(self):
270
+ # self.runOne('KYRGYZ', kTeststr_ky_Arab)
271
+
272
+ # def testKYRGYZ(self):
273
+ # self.runOne('KYRGYZ', kTeststr_ky_Cyrl)
274
+
275
+
276
+ # def testLATIN(self):
277
+ # self.runOne('LATIN', kTeststr_la_Latn)
278
+
279
+ # def testLUXEMBOURGISH(self):
280
+ # self.runOne('LUXEMBOURGISH', kTeststr_lb_Latn)
281
+
282
+ # def testGANDA(self):
283
+ # self.runOne('GANDA', kTeststr_lg_Latn)
284
+
285
+ # def testLINGALA(self):
286
+ # self.runOne('LINGALA', kTeststr_ln_Latn)
287
+
288
+ def testLAOTHIAN(self):
289
+ self.runOne('LAOTHIAN', kTeststr_lo_Laoo)
290
+
291
+ def testLITHUANIAN(self):
292
+ self.runOne('LITHUANIAN', kTeststr_lt_Latn)
293
+
294
+ def testLATVIAN(self):
295
+ self.runOne('LATVIAN', kTeststr_lv_Latn)
296
+
297
+ # def testMALAGASY(self):
298
+ # self.runOne('MALAGASY', kTeststr_mg_Latn)
299
+
300
+ # def testMAORI(self):
301
+ # self.runOne('MAORI', kTeststr_mi_Latn)
302
+
303
+ def testMACEDONIAN(self):
304
+ self.runOne('MACEDONIAN', kTeststr_mk_Cyrl)
305
+
306
+ def testMALAYALAM(self):
307
+ self.runOne('MALAYALAM', kTeststr_ml_Mlym)
308
+
309
+ # def testMONGOLIAN(self):
310
+ # self.runOne('MONGOLIAN', kTeststr_mn_Cyrl)
311
+
312
+ # def testMOLDAVIAN(self):
313
+ # self.runOne('MOLDAVIAN', kTeststr_mo_Cyrl)
314
+
315
+ # def testMARATHI(self):
316
+ # self.runOne('MARATHI', kTeststr_mr_Deva)
317
+
318
+ def testMALAY(self):
319
+ self.runOne('MALAY', kTeststr_ms_Latn)
320
+
321
+ # def testMALAY(self):
322
+ # self.runOne('MALAY', kTeststr_ms_Latn2)
323
+
324
+ def testMALAY(self):
325
+ self.runOne('MALAY', kTeststr_ms_Latn3)
326
+
327
+ # def testMALTESE(self):
328
+ # self.runOne('MALTESE', kTeststr_mt_Latn)
329
+
330
+ # def testBURMESE(self):
331
+ # self.runOne('BURMESE', kTeststr_my_Latn)
332
+
333
+ # def testBURMESE(self):
334
+ # self.runOne('BURMESE', kTeststr_my_Mymr)
335
+
336
+ # def testNAURU(self):
337
+ # self.runOne('NAURU', kTeststr_na_Latn)
338
+
339
+ # def testNEPALI(self):
340
+ # self.runOne('NEPALI', kTeststr_ne_Deva)
341
+
342
+ def testDUTCH(self):
343
+ self.runOne('DUTCH', kTeststr_nl_Latn)
344
+
345
+ # def testNORWEGIAN_N(self):
346
+ # self.runOne('NORWEGIAN_N', kTeststr_nn_Latn)
347
+
348
+ def testNORWEGIAN(self):
349
+ self.runOne('NORWEGIAN', kTeststr_no_Latn)
350
+
351
+
352
+ # def testOCCITAN(self):
353
+ # self.runOne('OCCITAN', kTeststr_oc_Latn)
354
+
355
+ # def testOROMO(self):
356
+ # self.runOne('OROMO', kTeststr_om_Latn)
357
+
358
+ def testORIYA(self):
359
+ self.runOne('ORIYA', kTeststr_or_Orya)
360
+
361
+ def testPUNJABI(self):
362
+ self.runOne('PUNJABI', kTeststr_pa_Guru)
363
+
364
+ def testPOLISH(self):
365
+ self.runOne('POLISH', kTeststr_pl_Latn)
366
+
367
+ # def testPASHTO(self):
368
+ # self.runOne('PASHTO', kTeststr_ps_Arab)
369
+
370
+ def testPORTUGUESE(self):
371
+ self.runOne('PORTUGUESE', kTeststr_pt_BR) # NOTE: not PORTUGUESE_B
372
+ # nor PORTUGUESE_P
373
+
374
+ # def testQUECHUA(self):
375
+ # self.runOne('QUECHUA', kTeststr_qu_Latn)
376
+
377
+ # def testRHAETO_ROMANCE(self):
378
+ # self.runOne('RHAETO_ROMANCE', kTeststr_rm_Latn)
379
+
380
+ # def testRUNDI(self):
381
+ # self.runOne('RUNDI', kTeststr_rn_Latn)
382
+
383
+ def testROMANIAN(self):
384
+ self.runOne('ROMANIAN', kTeststr_ro_Latn)
385
+
386
+ def testRUSSIAN(self):
387
+ self.runOne('RUSSIAN', kTeststr_ru_Cyrl)
388
+
389
+ # def testKINYARWANDA(self):
390
+ # self.runOne('KINYARWANDA', kTeststr_rw_Latn)
391
+
392
+ # def testSANSKRIT(self):
393
+ # self.runOne('SANSKRIT', kTeststr_sa_Deva)
394
+
395
+ # def testSANSKRIT(self):
396
+ # self.runOne('SANSKRIT', kTeststr_sa_Latn)
397
+
398
+ # def testSCOTS(self):
399
+ # self.runOne('SCOTS', kTeststr_sco_Latn)
400
+
401
+ # def testSINDHI(self):
402
+ # self.runOne('SINDHI', kTeststr_sd_Arab)
403
+
404
+ # def testSANGO(self):
405
+ # self.runOne('SANGO', kTeststr_sg_Latn)
406
+
407
+ # No SERBO_CROATIAN (sh)
408
+ def testSINHALESE(self):
409
+ self.runOne('SINHALESE', kTeststr_si_Sinh)
410
+
411
+ # def testLIMBU(self):
412
+ # self.runOne('LIMBU', kTeststr_sit_NP)
413
+
414
+ def testSLOVAK(self):
415
+ self.runOne('SLOVAK', kTeststr_sk_Latn)
416
+
417
+ def testSLOVENIAN(self):
418
+ self.runOne('SLOVENIAN', kTeststr_sl_Latn)
419
+
420
+ # def testSAMOAN(self):
421
+ # self.runOne('SAMOAN', kTeststr_sm_Latn)
422
+
423
+ # def testSHONA(self):
424
+ # self.runOne('SHONA', kTeststr_sn_Latn)
425
+
426
+ # def testSOMALI(self):
427
+ # self.runOne('SOMALI', kTeststr_so_Latn)
428
+
429
+ # def testALBANIAN(self):
430
+ # self.runOne('ALBANIAN', kTeststr_sq_Latn)
431
+
432
+ def testSERBIAN(self):
433
+ self.runOne('SERBIAN', kTeststr_sr_Cyrl) # NOTE: now SERBIAN
434
+
435
+ def testCROATIAN(self):
436
+ self.runOne('CROATIAN', kTeststr_sr_Latn) # NOTE: Not SERBIAN
437
+
438
+ def testCROATIAN(self):
439
+ self.runOne('CROATIAN', kTeststr_sr_ME_Latn) # NOTE: not SERBIAN nor MONTENEGRIN
440
+
441
+ # def testSISWANT(self):
442
+ # self.runOne('SISWANT', kTeststr_ss_Latn)
443
+
444
+ # def testSESOTHO(self):
445
+ # self.runOne('SESOTHO', kTeststr_st_Latn)
446
+
447
+ # def testSUNDANESE(self):
448
+ # self.runOne('SUNDANESE', kTeststr_su_Latn)
449
+
450
+ def testSWEDISH(self):
451
+ self.runOne('SWEDISH', kTeststr_sv_Latn)
452
+
453
+ def testSWAHILI(self):
454
+ self.runOne('SWAHILI', kTeststr_sw_Latn)
455
+
456
+ def testSYRIAC(self):
457
+ self.runOne('SYRIAC', kTeststr_syr_Syrc)
458
+
459
+ def testTAMIL(self):
460
+ self.runOne('TAMIL', kTeststr_ta_Taml)
461
+
462
+ def testTELUGU(self):
463
+ self.runOne('TELUGU', kTeststr_te_Telu)
464
+
465
+ # Tajik Arab removed 2008.05.27. Just Tajik Cyrl left
466
+ # def testTAJIK(self):
467
+ # self.runOne('TAJIK', kTeststr_tg_Arab)
468
+
469
+ # def testTAJIK(self):
470
+ # self.runOne('TAJIK', kTeststr_tg_Cyrl)
471
+
472
+ def testTHAI(self):
473
+ self.runOne('THAI', kTeststr_th_Thai)
474
+
475
+ # def testTIGRINYA(self):
476
+ # self.runOne('TIGRINYA', kTeststr_ti_Ethi)
477
+
478
+ # def testTURKMEN(self):
479
+ # self.runOne('TURKMEN', kTeststr_tk_Cyrl)
480
+
481
+ # def testTURKMEN(self):
482
+ # self.runOne('TURKMEN', kTeststr_tk_Latn)
483
+
484
+ def testTAGALOG(self):
485
+ self.runOne('TAGALOG', kTeststr_tl_Latn)
486
+
487
+ # def testTSWANA(self):
488
+ # self.runOne('TSWANA', kTeststr_tn_Latn)
489
+
490
+ # def testTONGA(self):
491
+ # self.runOne('TONGA', kTeststr_to_Latn)
492
+
493
+ def testTURKISH(self):
494
+ self.runOne('TURKISH', kTeststr_tr_Latn)
495
+
496
+ # def testTSONGA(self):
497
+ # self.runOne('TSONGA', kTeststr_ts_Latn)
498
+
499
+ # def testTATAR(self):
500
+ # self.runOne('TATAR', kTeststr_tt_Cyrl)
501
+
502
+ # def testTATAR(self):
503
+ # self.runOne('TATAR', kTeststr_tt_Latn)
504
+
505
+ # def testTWI(self):
506
+ # self.runOne('TWI', kTeststr_tw_Latn)
507
+
508
+ # def testUIGHUR(self):
509
+ # self.runOne('UIGHUR', kTeststr_ug_Arab)
510
+
511
+ # def testUIGHUR(self):
512
+ # self.runOne('UIGHUR', kTeststr_ug_Cyrl)
513
+
514
+ # def testUIGHUR(self):
515
+ # self.runOne('UIGHUR', kTeststr_ug_Latn)
516
+
517
+ def testUKRAINIAN(self):
518
+ self.runOne('UKRAINIAN', kTeststr_uk_Cyrl)
519
+
520
+ # def testURDU(self):
521
+ # self.runOne('URDU', kTeststr_ur_Arab)
522
+
523
+ # def testUZBEK(self):
524
+ # self.runOne('UZBEK', kTeststr_uz_Arab)
525
+
526
+ # def testUZBEK(self):
527
+ # self.runOne('UZBEK', kTeststr_uz_Cyrl)
528
+
529
+ # def testUZBEK(self):
530
+ # self.runOne('UZBEK', kTeststr_uz_Latn)
531
+
532
+ def testVIETNAMESE(self):
533
+ self.runOne('VIETNAMESE', kTeststr_vi_Latn)
534
+
535
+ # def testVOLAPUK(self):
536
+ # self.runOne('VOLAPUK', kTeststr_vo_Latn)
537
+
538
+ # def testWOLOF(self):
539
+ # self.runOne('WOLOF', kTeststr_wo_Latn)
540
+
541
+ # def testXHOSA(self):
542
+ # self.runOne('XHOSA', kTeststr_xh_Latn)
543
+
544
+ def testYIDDISH(self):
545
+ self.runOne('YIDDISH', kTeststr_yi_Hebr)
546
+
547
+ # def testYORUBA(self):
548
+ # self.runOne('YORUBA', kTeststr_yo_Latn)
549
+
550
+ # Zhuang Hani removed 2008.05.13. Just Zhuang Latn left
551
+ # def testZHUANG(self):
552
+ # self.runOne('ZHUANG', kTeststr_za_Hani)
553
+
554
+ # def testZHUANG(self):
555
+ # self.runOne('ZHUANG', kTeststr_za_Latn)
556
+
557
+ def testCHINESE(self):
558
+ self.runOne('Chinese', kTeststr_zh_Hani)
559
+
560
+ def testCHINESE_T(self):
561
+ self.runOne('ChineseT', kTeststr_zh_TW)
562
+
563
+ # def testZULU(self):
564
+ # self.runOne('ZULU', kTeststr_zu_Latn)
565
+
566
+ # No TG_UNKNOWN_LANGUAGE
567
+ # No UNKNOWN_LANGUAGE
568
+
569
+ if __name__ == '__main__':
570
+ unittest.main()
data/thunk.cc ADDED
@@ -0,0 +1,131 @@
1
+ #include <stdio.h>
2
+ #include "encodings/compact_lang_det/compact_lang_det.h"
3
+ #include "encodings/compact_lang_det/ext_lang_enc.h"
4
+ #include "encodings/compact_lang_det/unittest_data.h"
5
+ #include "encodings/proto/encodings.pb.h"
6
+
7
+
8
+ extern "C" {
9
+ int detectLanguageThunkInt(const char * src) {
10
+ bool is_plain_text = true;
11
+ bool do_allow_extended_languages = true;
12
+ bool do_pick_summary_language = false;
13
+ bool do_remove_weak_matches = false;
14
+ bool is_reliable;
15
+ Language plus_one = UNKNOWN_LANGUAGE;
16
+ const char* tld_hint = NULL;
17
+ int encoding_hint = UNKNOWN_ENCODING;
18
+ Language language_hint = UNKNOWN_LANGUAGE;
19
+
20
+ double normalized_score3[3];
21
+ Language language3[3];
22
+ int percent3[3];
23
+ int text_bytes;
24
+
25
+ Language lang;
26
+ lang = CompactLangDet::DetectLanguage(0,
27
+ src, strlen(src),
28
+ is_plain_text,
29
+ do_allow_extended_languages,
30
+ do_pick_summary_language,
31
+ do_remove_weak_matches,
32
+ tld_hint,
33
+ encoding_hint,
34
+ language_hint,
35
+ language3,
36
+ percent3,
37
+ normalized_score3,
38
+ &text_bytes,
39
+ &is_reliable);
40
+ return lang;
41
+ }
42
+ /*
43
+ char * detectLanguageThunkString(const char * src) {
44
+ bool is_plain_text = true;
45
+ bool do_allow_extended_languages = true;
46
+ bool do_pick_summary_language = false;
47
+ bool do_remove_weak_matches = false;
48
+ bool is_reliable;
49
+ Language plus_one = UNKNOWN_LANGUAGE;
50
+ const char* tld_hint = NULL;
51
+ int encoding_hint = UNKNOWN_ENCODING;
52
+ Language language_hint = UNKNOWN_LANGUAGE;
53
+
54
+ double normalized_score3[3];
55
+ Language language3[3];
56
+ int percent3[3];
57
+ int text_bytes;
58
+
59
+ Language lang;
60
+ lang = CompactLangDet::DetectLanguage(0,
61
+ src, strlen(src),
62
+ is_plain_text,
63
+ do_allow_extended_languages,
64
+ do_pick_summary_language,
65
+ do_remove_weak_matches,
66
+ tld_hint,
67
+ encoding_hint,
68
+ language_hint,
69
+ language3,
70
+ percent3,
71
+ normalized_score3,
72
+ &text_bytes,
73
+ &is_reliable);
74
+ return LanguageName(lang);
75
+ }
76
+ */
77
+ }
78
+
79
+ int main(int argc, char **argv) {
80
+ /*
81
+ bool is_plain_text = true;
82
+ bool do_allow_extended_languages = true;
83
+ bool do_pick_summary_language = false;
84
+ bool do_remove_weak_matches = false;
85
+ bool is_reliable;
86
+ Language plus_one = UNKNOWN_LANGUAGE;
87
+ const char* tld_hint = NULL;
88
+ int encoding_hint = UNKNOWN_ENCODING;
89
+ Language language_hint = UNKNOWN_LANGUAGE;
90
+
91
+ double normalized_score3[3];
92
+ Language language3[3];
93
+ int percent3[3];
94
+ int text_bytes;
95
+
96
+ const char* src = kTeststr_en;
97
+ Language lang;
98
+ lang = CompactLangDet::DetectLanguage(0,
99
+ src, strlen(src),
100
+ is_plain_text,
101
+ do_allow_extended_languages,
102
+ do_pick_summary_language,
103
+ do_remove_weak_matches,
104
+ tld_hint,
105
+ encoding_hint,
106
+ language_hint,
107
+ language3,
108
+ percent3,
109
+ normalized_score3,
110
+ &text_bytes,
111
+ &is_reliable);
112
+ printf("LANG=%s\n", LanguageName(lang));
113
+
114
+ src = kTeststr_ks;
115
+ lang = CompactLangDet::DetectLanguage(0,
116
+ src, strlen(src),
117
+ is_plain_text,
118
+ do_allow_extended_languages,
119
+ do_pick_summary_language,
120
+ do_remove_weak_matches,
121
+ tld_hint,
122
+ encoding_hint,
123
+ language_hint,
124
+ language3,
125
+ percent3,
126
+ normalized_score3,
127
+ &text_bytes,
128
+ &is_reliable);
129
+ printf("LANG=%s\n", LanguageName(lang));
130
+ */
131
+ }