LangCyrillicModel.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is Mozilla Universal charset detector code.
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Netscape Communications Corporation.
  18. * Portions created by the Initial Developer are Copyright (C) 2001
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * Shy Shalom <shooshX@gmail.com>
  23. * Rudi Pettazzi <rudi.pettazzi@gmail.com> (C# port)
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. namespace UniversalDetector.Core
  39. {
  40. public abstract class CyrillicModel : SequenceModel
  41. {
  42. // Model Table:
  43. // total sequences: 100%
  44. // first 512 sequences: 97.6601%
  45. // first 1024 sequences: 2.3389%
  46. // rest sequences: 0.1237%
  47. // negative sequences: 0.0009%
  48. protected readonly static byte[] RUSSIAN_LANG_MODEL = {
  49. 0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,1,3,3,3,2,3,2,3,3,
  50. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,2,2,2,2,2,0,0,2,
  51. 3,3,3,2,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,2,3,2,0,
  52. 0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  53. 3,3,3,2,2,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,2,3,3,1,0,
  54. 0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  55. 3,2,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1,
  56. 0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  57. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1,
  58. 0,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  59. 3,3,3,3,3,3,3,3,2,2,2,3,1,3,3,1,3,3,3,3,2,2,3,0,2,2,2,3,3,2,1,0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,0,0,1,1,
  164. 0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
  165. 1,0,2,1,2,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,
  166. 0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,
  167. 1,0,0,0,0,2,0,1,2,1,0,1,1,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,
  168. 0,0,0,0,0,1,0,0,1,1,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,
  169. 2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
  170. 1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,
  171. 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
  172. 1,1,1,0,1,0,1,0,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,
  173. 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
  174. 1,1,0,1,1,0,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,
  175. 0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  176. 0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
  177. };
  178. public CyrillicModel(byte[] charToOrderMap, string name)
  179. : base(charToOrderMap, RUSSIAN_LANG_MODEL, 0.976601f, false, name)
  180. {
  181. }
  182. }
  183. public class Koi8rModel : CyrillicModel
  184. {
  185. private readonly static byte[] KOI8R_CHAR_TO_ORDER_MAP = {
  186. 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00
  187. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10
  188. +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20
  189. 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30
  190. 253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40
  191. 155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50
  192. 253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60
  193. 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70
  194. 191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, //80
  195. 207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, //90
  196. 223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, //a0
  197. 238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, //b0
  198. 27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, //c0
  199. 15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, //d0
  200. 59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, //e0
  201. 35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, //f0
  202. };
  203. public Koi8rModel() : base(KOI8R_CHAR_TO_ORDER_MAP, "KOI8-R")
  204. {
  205. }
  206. }
  207. public class Win1251Model : CyrillicModel
  208. {
  209. private readonly static byte[] WIN1251_CHAR_TO_ORDER_MAP = {
  210. 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00
  211. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10
  212. +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20
  213. 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30
  214. 253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40
  215. 155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50
  216. 253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60
  217. 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70
  218. 191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
  219. 207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
  220. 223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
  221. 239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253,
  222. 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
  223. 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
  224. 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
  225. 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
  226. };
  227. public Win1251Model() : base(WIN1251_CHAR_TO_ORDER_MAP, "windows-1251")
  228. {
  229. }
  230. }
  231. public class Latin5Model : CyrillicModel
  232. {
  233. private readonly static byte[] LATIN5_CHAR_TO_ORDER_MAP = {
  234. 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00
  235. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10
  236. +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20
  237. 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30
  238. 253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40
  239. 155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50
  240. 253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60
  241. 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70
  242. 191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
  243. 207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
  244. 223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
  245. 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
  246. 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
  247. 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
  248. 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
  249. 239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,
  250. };
  251. public Latin5Model() : base(LATIN5_CHAR_TO_ORDER_MAP, "ISO-8859-5")
  252. {
  253. }
  254. }
  255. public class MacCyrillicModel : CyrillicModel
  256. {
  257. private readonly static byte[] MACCYRILLIC_CHAR_TO_ORDER_MAP = {
  258. 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00
  259. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10
  260. +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20
  261. 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30
  262. 253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40
  263. 155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50
  264. 253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60
  265. 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70
  266. 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
  267. 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
  268. 191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
  269. 207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
  270. 223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
  271. 239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16,
  272. 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
  273. 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255,
  274. };
  275. public MacCyrillicModel() : base(MACCYRILLIC_CHAR_TO_ORDER_MAP,
  276. "x-mac-cyrillic")
  277. {
  278. }
  279. }
  280. public class Ibm855Model : CyrillicModel
  281. {
  282. private readonly static byte[] IBM855_BYTE_TO_ORDER_MAP = {
  283. 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00
  284. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10
  285. +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20
  286. 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30
  287. 253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40
  288. 155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50
  289. 253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60
  290. 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70
  291. 191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205,
  292. 206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70,
  293. 3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219,
  294. 220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229,
  295. 230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243,
  296. 8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248,
  297. 43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249,
  298. 250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255,
  299. };
  300. public Ibm855Model() : base(IBM855_BYTE_TO_ORDER_MAP, "IBM855")
  301. {
  302. }
  303. }
  304. public class Ibm866Model : CyrillicModel
  305. {
  306. private readonly static byte[] IBM866_CHAR_TO_ORDER_MAP = {
  307. 255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, //00
  308. 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, //10
  309. +253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, //20
  310. 252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, //30
  311. 253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, //40
  312. 155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, //50
  313. 253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, //60
  314. 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, //70
  315. 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
  316. 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
  317. 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
  318. 191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
  319. 207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
  320. 223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
  321. 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
  322. 239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,
  323. };
  324. public Ibm866Model() : base(IBM866_CHAR_TO_ORDER_MAP, "IBM866")
  325. {
  326. }
  327. }
  328. }