/src/runtime/full_text/stemmer/src_c/stem_UTF_8_norwegian.c

https://github.com/cezarfx/zorba · C · 299 lines · 273 code · 24 blank · 2 comment · 44 complexity · f4f59f9514b202f95917ba3b9afaec45 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 norwegian_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 * norwegian_UTF_8_create_env(void);
  18. extern void norwegian_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[1] = { 'e' };
  24. static const symbol s_0_2[3] = { 'e', 'd', 'e' };
  25. static const symbol s_0_3[4] = { 'a', 'n', 'd', 'e' };
  26. static const symbol s_0_4[4] = { 'e', 'n', 'd', 'e' };
  27. static const symbol s_0_5[3] = { 'a', 'n', 'e' };
  28. static const symbol s_0_6[3] = { 'e', 'n', 'e' };
  29. static const symbol s_0_7[6] = { 'h', 'e', 't', 'e', 'n', 'e' };
  30. static const symbol s_0_8[4] = { 'e', 'r', 't', 'e' };
  31. static const symbol s_0_9[2] = { 'e', 'n' };
  32. static const symbol s_0_10[5] = { 'h', 'e', 't', 'e', 'n' };
  33. static const symbol s_0_11[2] = { 'a', 'r' };
  34. static const symbol s_0_12[2] = { 'e', 'r' };
  35. static const symbol s_0_13[5] = { 'h', 'e', 't', 'e', 'r' };
  36. static const symbol s_0_14[1] = { 's' };
  37. static const symbol s_0_15[2] = { 'a', 's' };
  38. static const symbol s_0_16[2] = { 'e', 's' };
  39. static const symbol s_0_17[4] = { 'e', 'd', 'e', 's' };
  40. static const symbol s_0_18[5] = { 'e', 'n', 'd', 'e', 's' };
  41. static const symbol s_0_19[4] = { 'e', 'n', 'e', 's' };
  42. static const symbol s_0_20[7] = { 'h', 'e', 't', 'e', 'n', 'e', 's' };
  43. static const symbol s_0_21[3] = { 'e', 'n', 's' };
  44. static const symbol s_0_22[6] = { 'h', 'e', 't', 'e', 'n', 's' };
  45. static const symbol s_0_23[3] = { 'e', 'r', 's' };
  46. static const symbol s_0_24[3] = { 'e', 't', 's' };
  47. static const symbol s_0_25[2] = { 'e', 't' };
  48. static const symbol s_0_26[3] = { 'h', 'e', 't' };
  49. static const symbol s_0_27[3] = { 'e', 'r', 't' };
  50. static const symbol s_0_28[3] = { 'a', 's', 't' };
  51. static const struct among a_0[29] =
  52. {
  53. /* 0 */ { 1, s_0_0, -1, 1, 0},
  54. /* 1 */ { 1, s_0_1, -1, 1, 0},
  55. /* 2 */ { 3, s_0_2, 1, 1, 0},
  56. /* 3 */ { 4, s_0_3, 1, 1, 0},
  57. /* 4 */ { 4, s_0_4, 1, 1, 0},
  58. /* 5 */ { 3, s_0_5, 1, 1, 0},
  59. /* 6 */ { 3, s_0_6, 1, 1, 0},
  60. /* 7 */ { 6, s_0_7, 6, 1, 0},
  61. /* 8 */ { 4, s_0_8, 1, 3, 0},
  62. /* 9 */ { 2, s_0_9, -1, 1, 0},
  63. /* 10 */ { 5, s_0_10, 9, 1, 0},
  64. /* 11 */ { 2, s_0_11, -1, 1, 0},
  65. /* 12 */ { 2, s_0_12, -1, 1, 0},
  66. /* 13 */ { 5, s_0_13, 12, 1, 0},
  67. /* 14 */ { 1, s_0_14, -1, 2, 0},
  68. /* 15 */ { 2, s_0_15, 14, 1, 0},
  69. /* 16 */ { 2, s_0_16, 14, 1, 0},
  70. /* 17 */ { 4, s_0_17, 16, 1, 0},
  71. /* 18 */ { 5, s_0_18, 16, 1, 0},
  72. /* 19 */ { 4, s_0_19, 16, 1, 0},
  73. /* 20 */ { 7, s_0_20, 19, 1, 0},
  74. /* 21 */ { 3, s_0_21, 14, 1, 0},
  75. /* 22 */ { 6, s_0_22, 21, 1, 0},
  76. /* 23 */ { 3, s_0_23, 14, 1, 0},
  77. /* 24 */ { 3, s_0_24, 14, 1, 0},
  78. /* 25 */ { 2, s_0_25, -1, 1, 0},
  79. /* 26 */ { 3, s_0_26, 25, 1, 0},
  80. /* 27 */ { 3, s_0_27, -1, 3, 0},
  81. /* 28 */ { 3, s_0_28, -1, 1, 0}
  82. };
  83. static const symbol s_1_0[2] = { 'd', 't' };
  84. static const symbol s_1_1[2] = { 'v', 't' };
  85. static const struct among a_1[2] =
  86. {
  87. /* 0 */ { 2, s_1_0, -1, -1, 0},
  88. /* 1 */ { 2, s_1_1, -1, -1, 0}
  89. };
  90. static const symbol s_2_0[3] = { 'l', 'e', 'g' };
  91. static const symbol s_2_1[4] = { 'e', 'l', 'e', 'g' };
  92. static const symbol s_2_2[2] = { 'i', 'g' };
  93. static const symbol s_2_3[3] = { 'e', 'i', 'g' };
  94. static const symbol s_2_4[3] = { 'l', 'i', 'g' };
  95. static const symbol s_2_5[4] = { 'e', 'l', 'i', 'g' };
  96. static const symbol s_2_6[3] = { 'e', 'l', 's' };
  97. static const symbol s_2_7[3] = { 'l', 'o', 'v' };
  98. static const symbol s_2_8[4] = { 'e', 'l', 'o', 'v' };
  99. static const symbol s_2_9[4] = { 's', 'l', 'o', 'v' };
  100. static const symbol s_2_10[7] = { 'h', 'e', 't', 's', 'l', 'o', 'v' };
  101. static const struct among a_2[11] =
  102. {
  103. /* 0 */ { 3, s_2_0, -1, 1, 0},
  104. /* 1 */ { 4, s_2_1, 0, 1, 0},
  105. /* 2 */ { 2, s_2_2, -1, 1, 0},
  106. /* 3 */ { 3, s_2_3, 2, 1, 0},
  107. /* 4 */ { 3, s_2_4, 2, 1, 0},
  108. /* 5 */ { 4, s_2_5, 4, 1, 0},
  109. /* 6 */ { 3, s_2_6, -1, 1, 0},
  110. /* 7 */ { 3, s_2_7, -1, 1, 0},
  111. /* 8 */ { 4, s_2_8, 7, 1, 0},
  112. /* 9 */ { 4, s_2_9, 7, 1, 0},
  113. /* 10 */ { 7, s_2_10, 9, 1, 0}
  114. };
  115. static const unsigned char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 128 };
  116. static const unsigned char g_s_ending[] = { 119, 125, 149, 1 };
  117. static const symbol s_0[] = { 'k' };
  118. static const symbol s_1[] = { 'e', 'r' };
  119. static int r_mark_regions(struct SN_env * z) {
  120. z->I[0] = z->l;
  121. { int c_test = z->c; /* test, line 30 */
  122. { int ret = skip_utf8(z->p, z->c, 0, z->l, + 3);
  123. if (ret < 0) return 0;
  124. z->c = ret; /* hop, line 30 */
  125. }
  126. z->I[1] = z->c; /* setmark x, line 30 */
  127. z->c = c_test;
  128. }
  129. if (out_grouping_U(z, g_v, 97, 248, 1) < 0) return 0; /* goto */ /* grouping v, line 31 */
  130. { /* gopast */ /* non v, line 31 */
  131. int ret = in_grouping_U(z, g_v, 97, 248, 1);
  132. if (ret < 0) return 0;
  133. z->c += ret;
  134. }
  135. z->I[0] = z->c; /* setmark p1, line 31 */
  136. /* try, line 32 */
  137. if (!(z->I[0] < z->I[1])) goto lab0;
  138. z->I[0] = z->I[1];
  139. lab0:
  140. return 1;
  141. }
  142. static int r_main_suffix(struct SN_env * z) {
  143. int among_var;
  144. { int mlimit; /* setlimit, line 38 */
  145. int m1 = z->l - z->c; (void)m1;
  146. if (z->c < z->I[0]) return 0;
  147. z->c = z->I[0]; /* tomark, line 38 */
  148. mlimit = z->lb; z->lb = z->c;
  149. z->c = z->l - m1;
  150. z->ket = z->c; /* [, line 38 */
  151. if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1851426 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = mlimit; return 0; }
  152. among_var = find_among_b(z, a_0, 29); /* substring, line 38 */
  153. if (!(among_var)) { z->lb = mlimit; return 0; }
  154. z->bra = z->c; /* ], line 38 */
  155. z->lb = mlimit;
  156. }
  157. switch(among_var) {
  158. case 0: return 0;
  159. case 1:
  160. { int ret = slice_del(z); /* delete, line 44 */
  161. if (ret < 0) return ret;
  162. }
  163. break;
  164. case 2:
  165. { int m2 = z->l - z->c; (void)m2; /* or, line 46 */
  166. if (in_grouping_b_U(z, g_s_ending, 98, 122, 0)) goto lab1;
  167. goto lab0;
  168. lab1:
  169. z->c = z->l - m2;
  170. if (!(eq_s_b(z, 1, s_0))) return 0;
  171. if (out_grouping_b_U(z, g_v, 97, 248, 0)) return 0;
  172. }
  173. lab0:
  174. { int ret = slice_del(z); /* delete, line 46 */
  175. if (ret < 0) return ret;
  176. }
  177. break;
  178. case 3:
  179. { int ret = slice_from_s(z, 2, s_1); /* <-, line 48 */
  180. if (ret < 0) return ret;
  181. }
  182. break;
  183. }
  184. return 1;
  185. }
  186. static int r_consonant_pair(struct SN_env * z) {
  187. { int m_test = z->l - z->c; /* test, line 53 */
  188. { int mlimit; /* setlimit, line 54 */
  189. int m1 = z->l - z->c; (void)m1;
  190. if (z->c < z->I[0]) return 0;
  191. z->c = z->I[0]; /* tomark, line 54 */
  192. mlimit = z->lb; z->lb = z->c;
  193. z->c = z->l - m1;
  194. z->ket = z->c; /* [, line 54 */
  195. if (z->c - 1 <= z->lb || z->p[z->c - 1] != 116) { z->lb = mlimit; return 0; }
  196. if (!(find_among_b(z, a_1, 2))) { z->lb = mlimit; return 0; } /* substring, line 54 */
  197. z->bra = z->c; /* ], line 54 */
  198. z->lb = mlimit;
  199. }
  200. z->c = z->l - m_test;
  201. }
  202. { int ret = skip_utf8(z->p, z->c, z->lb, 0, -1);
  203. if (ret < 0) return 0;
  204. z->c = ret; /* next, line 59 */
  205. }
  206. z->bra = z->c; /* ], line 59 */
  207. { int ret = slice_del(z); /* delete, line 59 */
  208. if (ret < 0) return ret;
  209. }
  210. return 1;
  211. }
  212. static int r_other_suffix(struct SN_env * z) {
  213. int among_var;
  214. { int mlimit; /* setlimit, line 63 */
  215. int m1 = z->l - z->c; (void)m1;
  216. if (z->c < z->I[0]) return 0;
  217. z->c = z->I[0]; /* tomark, line 63 */
  218. mlimit = z->lb; z->lb = z->c;
  219. z->c = z->l - m1;
  220. z->ket = z->c; /* [, line 63 */
  221. if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((4718720 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = mlimit; return 0; }
  222. among_var = find_among_b(z, a_2, 11); /* substring, line 63 */
  223. if (!(among_var)) { z->lb = mlimit; return 0; }
  224. z->bra = z->c; /* ], line 63 */
  225. z->lb = mlimit;
  226. }
  227. switch(among_var) {
  228. case 0: return 0;
  229. case 1:
  230. { int ret = slice_del(z); /* delete, line 67 */
  231. if (ret < 0) return ret;
  232. }
  233. break;
  234. }
  235. return 1;
  236. }
  237. extern int norwegian_UTF_8_stem(struct SN_env * z) {
  238. { int c1 = z->c; /* do, line 74 */
  239. { int ret = r_mark_regions(z);
  240. if (ret == 0) goto lab0; /* call mark_regions, line 74 */
  241. if (ret < 0) return ret;
  242. }
  243. lab0:
  244. z->c = c1;
  245. }
  246. z->lb = z->c; z->c = z->l; /* backwards, line 75 */
  247. { int m2 = z->l - z->c; (void)m2; /* do, line 76 */
  248. { int ret = r_main_suffix(z);
  249. if (ret == 0) goto lab1; /* call main_suffix, line 76 */
  250. if (ret < 0) return ret;
  251. }
  252. lab1:
  253. z->c = z->l - m2;
  254. }
  255. { int m3 = z->l - z->c; (void)m3; /* do, line 77 */
  256. { int ret = r_consonant_pair(z);
  257. if (ret == 0) goto lab2; /* call consonant_pair, line 77 */
  258. if (ret < 0) return ret;
  259. }
  260. lab2:
  261. z->c = z->l - m3;
  262. }
  263. { int m4 = z->l - z->c; (void)m4; /* do, line 78 */
  264. { int ret = r_other_suffix(z);
  265. if (ret == 0) goto lab3; /* call other_suffix, line 78 */
  266. if (ret < 0) return ret;
  267. }
  268. lab3:
  269. z->c = z->l - m4;
  270. }
  271. z->c = z->lb;
  272. return 1;
  273. }
  274. extern struct SN_env * norwegian_UTF_8_create_env(void) { return SN_create_env(0, 2, 0); }
  275. extern void norwegian_UTF_8_close_env(struct SN_env * z) { SN_close_env(z, 0); }