PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/snowball/src/stemmer/src_c/stem_UTF_8_swedish.c

https://gitlab.com/lishaomin/firtex2
C | 330 lines | 304 code | 24 blank | 2 comment | 44 complexity | fef5f76694a400b89908f53b73349bc9 MD5 | raw file
  1. /* This file was generated automatically by the Snowball to ANSI C compiler */
  2. #include "../runtime/header.h"
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. extern int swedish_UTF_8_stem(struct SN_env * z);
  7. #ifdef __cplusplus
  8. }
  9. #endif
  10. static int r_other_suffix(struct SN_env * z);
  11. static int r_consonant_pair(struct SN_env * z);
  12. static int r_main_suffix(struct SN_env * z);
  13. static int r_mark_regions(struct SN_env * z);
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. extern struct SN_env * swedish_UTF_8_create_env(void);
  18. extern void swedish_UTF_8_close_env(struct SN_env * z);
  19. #ifdef __cplusplus
  20. }
  21. #endif
  22. static const symbol s_0_0[1] = { 'a' };
  23. static const symbol s_0_1[4] = { 'a', 'r', 'n', 'a' };
  24. static const symbol s_0_2[4] = { 'e', 'r', 'n', 'a' };
  25. static const symbol s_0_3[7] = { 'h', 'e', 't', 'e', 'r', 'n', 'a' };
  26. static const symbol s_0_4[4] = { 'o', 'r', 'n', 'a' };
  27. static const symbol s_0_5[2] = { 'a', 'd' };
  28. static const symbol s_0_6[1] = { 'e' };
  29. static const symbol s_0_7[3] = { 'a', 'd', 'e' };
  30. static const symbol s_0_8[4] = { 'a', 'n', 'd', 'e' };
  31. static const symbol s_0_9[4] = { 'a', 'r', 'n', 'e' };
  32. static const symbol s_0_10[3] = { 'a', 'r', 'e' };
  33. static const symbol s_0_11[4] = { 'a', 's', 't', 'e' };
  34. static const symbol s_0_12[2] = { 'e', 'n' };
  35. static const symbol s_0_13[5] = { 'a', 'n', 'd', 'e', 'n' };
  36. static const symbol s_0_14[4] = { 'a', 'r', 'e', 'n' };
  37. static const symbol s_0_15[5] = { 'h', 'e', 't', 'e', 'n' };
  38. static const symbol s_0_16[3] = { 'e', 'r', 'n' };
  39. static const symbol s_0_17[2] = { 'a', 'r' };
  40. static const symbol s_0_18[2] = { 'e', 'r' };
  41. static const symbol s_0_19[5] = { 'h', 'e', 't', 'e', 'r' };
  42. static const symbol s_0_20[2] = { 'o', 'r' };
  43. static const symbol s_0_21[1] = { 's' };
  44. static const symbol s_0_22[2] = { 'a', 's' };
  45. static const symbol s_0_23[5] = { 'a', 'r', 'n', 'a', 's' };
  46. static const symbol s_0_24[5] = { 'e', 'r', 'n', 'a', 's' };
  47. static const symbol s_0_25[5] = { 'o', 'r', 'n', 'a', 's' };
  48. static const symbol s_0_26[2] = { 'e', 's' };
  49. static const symbol s_0_27[4] = { 'a', 'd', 'e', 's' };
  50. static const symbol s_0_28[5] = { 'a', 'n', 'd', 'e', 's' };
  51. static const symbol s_0_29[3] = { 'e', 'n', 's' };
  52. static const symbol s_0_30[5] = { 'a', 'r', 'e', 'n', 's' };
  53. static const symbol s_0_31[6] = { 'h', 'e', 't', 'e', 'n', 's' };
  54. static const symbol s_0_32[4] = { 'e', 'r', 'n', 's' };
  55. static const symbol s_0_33[2] = { 'a', 't' };
  56. static const symbol s_0_34[5] = { 'a', 'n', 'd', 'e', 't' };
  57. static const symbol s_0_35[3] = { 'h', 'e', 't' };
  58. static const symbol s_0_36[3] = { 'a', 's', 't' };
  59. static const struct among a_0[37] =
  60. {
  61. /* 0 */ { 1, s_0_0, -1, 1, 0},
  62. /* 1 */ { 4, s_0_1, 0, 1, 0},
  63. /* 2 */ { 4, s_0_2, 0, 1, 0},
  64. /* 3 */ { 7, s_0_3, 2, 1, 0},
  65. /* 4 */ { 4, s_0_4, 0, 1, 0},
  66. /* 5 */ { 2, s_0_5, -1, 1, 0},
  67. /* 6 */ { 1, s_0_6, -1, 1, 0},
  68. /* 7 */ { 3, s_0_7, 6, 1, 0},
  69. /* 8 */ { 4, s_0_8, 6, 1, 0},
  70. /* 9 */ { 4, s_0_9, 6, 1, 0},
  71. /* 10 */ { 3, s_0_10, 6, 1, 0},
  72. /* 11 */ { 4, s_0_11, 6, 1, 0},
  73. /* 12 */ { 2, s_0_12, -1, 1, 0},
  74. /* 13 */ { 5, s_0_13, 12, 1, 0},
  75. /* 14 */ { 4, s_0_14, 12, 1, 0},
  76. /* 15 */ { 5, s_0_15, 12, 1, 0},
  77. /* 16 */ { 3, s_0_16, -1, 1, 0},
  78. /* 17 */ { 2, s_0_17, -1, 1, 0},
  79. /* 18 */ { 2, s_0_18, -1, 1, 0},
  80. /* 19 */ { 5, s_0_19, 18, 1, 0},
  81. /* 20 */ { 2, s_0_20, -1, 1, 0},
  82. /* 21 */ { 1, s_0_21, -1, 2, 0},
  83. /* 22 */ { 2, s_0_22, 21, 1, 0},
  84. /* 23 */ { 5, s_0_23, 22, 1, 0},
  85. /* 24 */ { 5, s_0_24, 22, 1, 0},
  86. /* 25 */ { 5, s_0_25, 22, 1, 0},
  87. /* 26 */ { 2, s_0_26, 21, 1, 0},
  88. /* 27 */ { 4, s_0_27, 26, 1, 0},
  89. /* 28 */ { 5, s_0_28, 26, 1, 0},
  90. /* 29 */ { 3, s_0_29, 21, 1, 0},
  91. /* 30 */ { 5, s_0_30, 29, 1, 0},
  92. /* 31 */ { 6, s_0_31, 29, 1, 0},
  93. /* 32 */ { 4, s_0_32, 21, 1, 0},
  94. /* 33 */ { 2, s_0_33, -1, 1, 0},
  95. /* 34 */ { 5, s_0_34, -1, 1, 0},
  96. /* 35 */ { 3, s_0_35, -1, 1, 0},
  97. /* 36 */ { 3, s_0_36, -1, 1, 0}
  98. };
  99. static const symbol s_1_0[2] = { 'd', 'd' };
  100. static const symbol s_1_1[2] = { 'g', 'd' };
  101. static const symbol s_1_2[2] = { 'n', 'n' };
  102. static const symbol s_1_3[2] = { 'd', 't' };
  103. static const symbol s_1_4[2] = { 'g', 't' };
  104. static const symbol s_1_5[2] = { 'k', 't' };
  105. static const symbol s_1_6[2] = { 't', 't' };
  106. static const struct among a_1[7] =
  107. {
  108. /* 0 */ { 2, s_1_0, -1, -1, 0},
  109. /* 1 */ { 2, s_1_1, -1, -1, 0},
  110. /* 2 */ { 2, s_1_2, -1, -1, 0},
  111. /* 3 */ { 2, s_1_3, -1, -1, 0},
  112. /* 4 */ { 2, s_1_4, -1, -1, 0},
  113. /* 5 */ { 2, s_1_5, -1, -1, 0},
  114. /* 6 */ { 2, s_1_6, -1, -1, 0}
  115. };
  116. static const symbol s_2_0[2] = { 'i', 'g' };
  117. static const symbol s_2_1[3] = { 'l', 'i', 'g' };
  118. static const symbol s_2_2[3] = { 'e', 'l', 's' };
  119. static const symbol s_2_3[5] = { 'f', 'u', 'l', 'l', 't' };
  120. static const symbol s_2_4[5] = { 'l', 0xC3, 0xB6, 's', 't' };
  121. static const struct among a_2[5] =
  122. {
  123. /* 0 */ { 2, s_2_0, -1, 1, 0},
  124. /* 1 */ { 3, s_2_1, 0, 1, 0},
  125. /* 2 */ { 3, s_2_2, -1, 1, 0},
  126. /* 3 */ { 5, s_2_3, -1, 3, 0},
  127. /* 4 */ { 5, s_2_4, -1, 2, 0}
  128. };
  129. static const unsigned char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 32 };
  130. static const unsigned char g_s_ending[] = { 119, 127, 149 };
  131. static const symbol s_0[] = { 'l', 0xC3, 0xB6, 's' };
  132. static const symbol s_1[] = { 'f', 'u', 'l', 'l' };
  133. static int r_mark_regions(struct SN_env * z) {
  134. z->I[0] = z->l;
  135. { int c_test = z->c; /* test, line 29 */
  136. { int c = skip_utf8(z->p, z->c, 0, z->l, + 3);
  137. if (c < 0) return 0;
  138. z->c = c; /* hop, line 29 */
  139. }
  140. z->I[1] = z->c; /* setmark x, line 29 */
  141. z->c = c_test;
  142. }
  143. while(1) { /* goto, line 30 */
  144. int c = z->c;
  145. if (!(in_grouping_U(z, g_v, 97, 246))) goto lab0;
  146. z->c = c;
  147. break;
  148. lab0:
  149. z->c = c;
  150. { int c = skip_utf8(z->p, z->c, 0, z->l, 1);
  151. if (c < 0) return 0;
  152. z->c = c; /* goto, line 30 */
  153. }
  154. }
  155. while(1) { /* gopast, line 30 */
  156. if (!(out_grouping_U(z, g_v, 97, 246))) goto lab1;
  157. break;
  158. lab1:
  159. { int c = skip_utf8(z->p, z->c, 0, z->l, 1);
  160. if (c < 0) return 0;
  161. z->c = c; /* gopast, line 30 */
  162. }
  163. }
  164. z->I[0] = z->c; /* setmark p1, line 30 */
  165. /* try, line 31 */
  166. if (!(z->I[0] < z->I[1])) goto lab2;
  167. z->I[0] = z->I[1];
  168. lab2:
  169. return 1;
  170. }
  171. static int r_main_suffix(struct SN_env * z) {
  172. int among_var;
  173. { int m3; /* setlimit, line 37 */
  174. int m = z->l - z->c; (void) m;
  175. if (z->c < z->I[0]) return 0;
  176. z->c = z->I[0]; /* tomark, line 37 */
  177. m3 = z->lb; z->lb = z->c;
  178. z->c = z->l - m;
  179. z->ket = z->c; /* [, line 37 */
  180. if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1851442 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = m3; return 0; }
  181. among_var = find_among_b(z, a_0, 37); /* substring, line 37 */
  182. if (!(among_var)) { z->lb = m3; return 0; }
  183. z->bra = z->c; /* ], line 37 */
  184. z->lb = m3;
  185. }
  186. switch(among_var) {
  187. case 0: return 0;
  188. case 1:
  189. { int ret;
  190. ret = slice_del(z); /* delete, line 44 */
  191. if (ret < 0) return ret;
  192. }
  193. break;
  194. case 2:
  195. if (!(in_grouping_b_U(z, g_s_ending, 98, 121))) return 0;
  196. { int ret;
  197. ret = slice_del(z); /* delete, line 46 */
  198. if (ret < 0) return ret;
  199. }
  200. break;
  201. }
  202. return 1;
  203. }
  204. static int r_consonant_pair(struct SN_env * z) {
  205. { int m3; /* setlimit, line 50 */
  206. int m = z->l - z->c; (void) m;
  207. if (z->c < z->I[0]) return 0;
  208. z->c = z->I[0]; /* tomark, line 50 */
  209. m3 = z->lb; z->lb = z->c;
  210. z->c = z->l - m;
  211. { int m = z->l - z->c; (void) m; /* and, line 52 */
  212. if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1064976 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = m3; return 0; }
  213. if (!(find_among_b(z, a_1, 7))) { z->lb = m3; return 0; } /* among, line 51 */
  214. z->c = z->l - m;
  215. z->ket = z->c; /* [, line 52 */
  216. { int c = skip_utf8(z->p, z->c, z->lb, 0, -1);
  217. if (c < 0) { z->lb = m3; return 0; }
  218. z->c = c; /* next, line 52 */
  219. }
  220. z->bra = z->c; /* ], line 52 */
  221. { int ret;
  222. ret = slice_del(z); /* delete, line 52 */
  223. if (ret < 0) return ret;
  224. }
  225. }
  226. z->lb = m3;
  227. }
  228. return 1;
  229. }
  230. static int r_other_suffix(struct SN_env * z) {
  231. int among_var;
  232. { int m3; /* setlimit, line 55 */
  233. int m = z->l - z->c; (void) m;
  234. if (z->c < z->I[0]) return 0;
  235. z->c = z->I[0]; /* tomark, line 55 */
  236. m3 = z->lb; z->lb = z->c;
  237. z->c = z->l - m;
  238. z->ket = z->c; /* [, line 56 */
  239. if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1572992 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = m3; return 0; }
  240. among_var = find_among_b(z, a_2, 5); /* substring, line 56 */
  241. if (!(among_var)) { z->lb = m3; return 0; }
  242. z->bra = z->c; /* ], line 56 */
  243. switch(among_var) {
  244. case 0: { z->lb = m3; return 0; }
  245. case 1:
  246. { int ret;
  247. ret = slice_del(z); /* delete, line 57 */
  248. if (ret < 0) return ret;
  249. }
  250. break;
  251. case 2:
  252. { int ret;
  253. ret = slice_from_s(z, 4, s_0); /* <-, line 58 */
  254. if (ret < 0) return ret;
  255. }
  256. break;
  257. case 3:
  258. { int ret;
  259. ret = slice_from_s(z, 4, s_1); /* <-, line 59 */
  260. if (ret < 0) return ret;
  261. }
  262. break;
  263. }
  264. z->lb = m3;
  265. }
  266. return 1;
  267. }
  268. extern int swedish_UTF_8_stem(struct SN_env * z) {
  269. { int c = z->c; /* do, line 66 */
  270. { int ret = r_mark_regions(z);
  271. if (ret == 0) goto lab0; /* call mark_regions, line 66 */
  272. if (ret < 0) return ret;
  273. }
  274. lab0:
  275. z->c = c;
  276. }
  277. z->lb = z->c; z->c = z->l; /* backwards, line 67 */
  278. { int m = z->l - z->c; (void) m; /* do, line 68 */
  279. { int ret = r_main_suffix(z);
  280. if (ret == 0) goto lab1; /* call main_suffix, line 68 */
  281. if (ret < 0) return ret;
  282. }
  283. lab1:
  284. z->c = z->l - m;
  285. }
  286. { int m = z->l - z->c; (void) m; /* do, line 69 */
  287. { int ret = r_consonant_pair(z);
  288. if (ret == 0) goto lab2; /* call consonant_pair, line 69 */
  289. if (ret < 0) return ret;
  290. }
  291. lab2:
  292. z->c = z->l - m;
  293. }
  294. { int m = z->l - z->c; (void) m; /* do, line 70 */
  295. { int ret = r_other_suffix(z);
  296. if (ret == 0) goto lab3; /* call other_suffix, line 70 */
  297. if (ret < 0) return ret;
  298. }
  299. lab3:
  300. z->c = z->l - m;
  301. }
  302. z->c = z->lb;
  303. return 1;
  304. }
  305. extern struct SN_env * swedish_UTF_8_create_env(void) { return SN_create_env(0, 2, 0); }
  306. extern void swedish_UTF_8_close_env(struct SN_env * z) { SN_close_env(z, 0); }