00001
00002
00003
00004 #include "header.h"
00005
00006 #ifdef __cplusplus
00007 extern "C" {
00008 #endif
00009 extern int swedish_UTF_8_stem(struct SN_env * z);
00010 #ifdef __cplusplus
00011 }
00012 #endif
00013 static int r_other_suffix(struct SN_env * z);
00014 static int r_consonant_pair(struct SN_env * z);
00015 static int r_main_suffix(struct SN_env * z);
00016 static int r_mark_regions(struct SN_env * z);
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020
00021
00022 extern struct SN_env * swedish_UTF_8_create_env(void);
00023 extern void swedish_UTF_8_close_env(struct SN_env * z);
00024
00025
00026 #ifdef __cplusplus
00027 }
00028 #endif
00029 static const symbol s_0_0[1] = { 'a' };
00030 static const symbol s_0_1[4] = { 'a', 'r', 'n', 'a' };
00031 static const symbol s_0_2[4] = { 'e', 'r', 'n', 'a' };
00032 static const symbol s_0_3[7] = { 'h', 'e', 't', 'e', 'r', 'n', 'a' };
00033 static const symbol s_0_4[4] = { 'o', 'r', 'n', 'a' };
00034 static const symbol s_0_5[2] = { 'a', 'd' };
00035 static const symbol s_0_6[1] = { 'e' };
00036 static const symbol s_0_7[3] = { 'a', 'd', 'e' };
00037 static const symbol s_0_8[4] = { 'a', 'n', 'd', 'e' };
00038 static const symbol s_0_9[4] = { 'a', 'r', 'n', 'e' };
00039 static const symbol s_0_10[3] = { 'a', 'r', 'e' };
00040 static const symbol s_0_11[4] = { 'a', 's', 't', 'e' };
00041 static const symbol s_0_12[2] = { 'e', 'n' };
00042 static const symbol s_0_13[5] = { 'a', 'n', 'd', 'e', 'n' };
00043 static const symbol s_0_14[4] = { 'a', 'r', 'e', 'n' };
00044 static const symbol s_0_15[5] = { 'h', 'e', 't', 'e', 'n' };
00045 static const symbol s_0_16[3] = { 'e', 'r', 'n' };
00046 static const symbol s_0_17[2] = { 'a', 'r' };
00047 static const symbol s_0_18[2] = { 'e', 'r' };
00048 static const symbol s_0_19[5] = { 'h', 'e', 't', 'e', 'r' };
00049 static const symbol s_0_20[2] = { 'o', 'r' };
00050 static const symbol s_0_21[1] = { 's' };
00051 static const symbol s_0_22[2] = { 'a', 's' };
00052 static const symbol s_0_23[5] = { 'a', 'r', 'n', 'a', 's' };
00053 static const symbol s_0_24[5] = { 'e', 'r', 'n', 'a', 's' };
00054 static const symbol s_0_25[5] = { 'o', 'r', 'n', 'a', 's' };
00055 static const symbol s_0_26[2] = { 'e', 's' };
00056 static const symbol s_0_27[4] = { 'a', 'd', 'e', 's' };
00057 static const symbol s_0_28[5] = { 'a', 'n', 'd', 'e', 's' };
00058 static const symbol s_0_29[3] = { 'e', 'n', 's' };
00059 static const symbol s_0_30[5] = { 'a', 'r', 'e', 'n', 's' };
00060 static const symbol s_0_31[6] = { 'h', 'e', 't', 'e', 'n', 's' };
00061 static const symbol s_0_32[4] = { 'e', 'r', 'n', 's' };
00062 static const symbol s_0_33[2] = { 'a', 't' };
00063 static const symbol s_0_34[5] = { 'a', 'n', 'd', 'e', 't' };
00064 static const symbol s_0_35[3] = { 'h', 'e', 't' };
00065 static const symbol s_0_36[3] = { 'a', 's', 't' };
00066
00067 static const struct among a_0[37] =
00068 {
00069 { 1, s_0_0, -1, 1, 0},
00070 { 4, s_0_1, 0, 1, 0},
00071 { 4, s_0_2, 0, 1, 0},
00072 { 7, s_0_3, 2, 1, 0},
00073 { 4, s_0_4, 0, 1, 0},
00074 { 2, s_0_5, -1, 1, 0},
00075 { 1, s_0_6, -1, 1, 0},
00076 { 3, s_0_7, 6, 1, 0},
00077 { 4, s_0_8, 6, 1, 0},
00078 { 4, s_0_9, 6, 1, 0},
00079 { 3, s_0_10, 6, 1, 0},
00080 { 4, s_0_11, 6, 1, 0},
00081 { 2, s_0_12, -1, 1, 0},
00082 { 5, s_0_13, 12, 1, 0},
00083 { 4, s_0_14, 12, 1, 0},
00084 { 5, s_0_15, 12, 1, 0},
00085 { 3, s_0_16, -1, 1, 0},
00086 { 2, s_0_17, -1, 1, 0},
00087 { 2, s_0_18, -1, 1, 0},
00088 { 5, s_0_19, 18, 1, 0},
00089 { 2, s_0_20, -1, 1, 0},
00090 { 1, s_0_21, -1, 2, 0},
00091 { 2, s_0_22, 21, 1, 0},
00092 { 5, s_0_23, 22, 1, 0},
00093 { 5, s_0_24, 22, 1, 0},
00094 { 5, s_0_25, 22, 1, 0},
00095 { 2, s_0_26, 21, 1, 0},
00096 { 4, s_0_27, 26, 1, 0},
00097 { 5, s_0_28, 26, 1, 0},
00098 { 3, s_0_29, 21, 1, 0},
00099 { 5, s_0_30, 29, 1, 0},
00100 { 6, s_0_31, 29, 1, 0},
00101 { 4, s_0_32, 21, 1, 0},
00102 { 2, s_0_33, -1, 1, 0},
00103 { 5, s_0_34, -1, 1, 0},
00104 { 3, s_0_35, -1, 1, 0},
00105 { 3, s_0_36, -1, 1, 0}
00106 };
00107
00108 static const symbol s_1_0[2] = { 'd', 'd' };
00109 static const symbol s_1_1[2] = { 'g', 'd' };
00110 static const symbol s_1_2[2] = { 'n', 'n' };
00111 static const symbol s_1_3[2] = { 'd', 't' };
00112 static const symbol s_1_4[2] = { 'g', 't' };
00113 static const symbol s_1_5[2] = { 'k', 't' };
00114 static const symbol s_1_6[2] = { 't', 't' };
00115
00116 static const struct among a_1[7] =
00117 {
00118 { 2, s_1_0, -1, -1, 0},
00119 { 2, s_1_1, -1, -1, 0},
00120 { 2, s_1_2, -1, -1, 0},
00121 { 2, s_1_3, -1, -1, 0},
00122 { 2, s_1_4, -1, -1, 0},
00123 { 2, s_1_5, -1, -1, 0},
00124 { 2, s_1_6, -1, -1, 0}
00125 };
00126
00127 static const symbol s_2_0[2] = { 'i', 'g' };
00128 static const symbol s_2_1[3] = { 'l', 'i', 'g' };
00129 static const symbol s_2_2[3] = { 'e', 'l', 's' };
00130 static const symbol s_2_3[5] = { 'f', 'u', 'l', 'l', 't' };
00131 static const symbol s_2_4[5] = { 'l', 0xC3, 0xB6, 's', 't' };
00132
00133 static const struct among a_2[5] =
00134 {
00135 { 2, s_2_0, -1, 1, 0},
00136 { 3, s_2_1, 0, 1, 0},
00137 { 3, s_2_2, -1, 1, 0},
00138 { 5, s_2_3, -1, 3, 0},
00139 { 5, s_2_4, -1, 2, 0}
00140 };
00141
00142 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 };
00143
00144 static const unsigned char g_s_ending[] = { 119, 127, 149 };
00145
00146 static const symbol s_0[] = { 'l', 0xC3, 0xB6, 's' };
00147 static const symbol s_1[] = { 'f', 'u', 'l', 'l' };
00148
00149 static int r_mark_regions(struct SN_env * z) {
00150 z->I[0] = z->l;
00151 { int c_test = z->c;
00152 { int ret = skip_utf8(z->p, z->c, 0, z->l, + 3);
00153 if (ret < 0) return 0;
00154 z->c = ret;
00155 }
00156 z->I[1] = z->c;
00157 z->c = c_test;
00158 }
00159 if (out_grouping_U(z, g_v, 97, 246, 1) < 0) return 0;
00160 {
00161 int ret = in_grouping_U(z, g_v, 97, 246, 1);
00162 if (ret < 0) return 0;
00163 z->c += ret;
00164 }
00165 z->I[0] = z->c;
00166
00167 if (!(z->I[0] < z->I[1])) goto lab0;
00168 z->I[0] = z->I[1];
00169 lab0:
00170 return 1;
00171 }
00172
00173 static int r_main_suffix(struct SN_env * z) {
00174 int among_var;
00175 { int mlimit;
00176 int m1 = z->l - z->c; (void)m1;
00177 if (z->c < z->I[0]) return 0;
00178 z->c = z->I[0];
00179 mlimit = z->lb; z->lb = z->c;
00180 z->c = z->l - m1;
00181 z->ket = z->c;
00182 if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1851442 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = mlimit; return 0; }
00183 among_var = find_among_b(z, a_0, 37);
00184 if (!(among_var)) { z->lb = mlimit; return 0; }
00185 z->bra = z->c;
00186 z->lb = mlimit;
00187 }
00188 switch(among_var) {
00189 case 0: return 0;
00190 case 1:
00191 { int ret = slice_del(z);
00192 if (ret < 0) return ret;
00193 }
00194 break;
00195 case 2:
00196 if (in_grouping_b_U(z, g_s_ending, 98, 121, 0)) return 0;
00197 { int ret = slice_del(z);
00198 if (ret < 0) return ret;
00199 }
00200 break;
00201 }
00202 return 1;
00203 }
00204
00205 static int r_consonant_pair(struct SN_env * z) {
00206 { int mlimit;
00207 int m1 = z->l - z->c; (void)m1;
00208 if (z->c < z->I[0]) return 0;
00209 z->c = z->I[0];
00210 mlimit = z->lb; z->lb = z->c;
00211 z->c = z->l - m1;
00212 { int m2 = z->l - z->c; (void)m2;
00213 if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1064976 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = mlimit; return 0; }
00214 if (!(find_among_b(z, a_1, 7))) { z->lb = mlimit; return 0; }
00215 z->c = z->l - m2;
00216 z->ket = z->c;
00217 { int ret = skip_utf8(z->p, z->c, z->lb, 0, -1);
00218 if (ret < 0) { z->lb = mlimit; return 0; }
00219 z->c = ret;
00220 }
00221 z->bra = z->c;
00222 { int ret = slice_del(z);
00223 if (ret < 0) return ret;
00224 }
00225 }
00226 z->lb = mlimit;
00227 }
00228 return 1;
00229 }
00230
00231 static int r_other_suffix(struct SN_env * z) {
00232 int among_var;
00233 { int mlimit;
00234 int m1 = z->l - z->c; (void)m1;
00235 if (z->c < z->I[0]) return 0;
00236 z->c = z->I[0];
00237 mlimit = z->lb; z->lb = z->c;
00238 z->c = z->l - m1;
00239 z->ket = z->c;
00240 if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1572992 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = mlimit; return 0; }
00241 among_var = find_among_b(z, a_2, 5);
00242 if (!(among_var)) { z->lb = mlimit; return 0; }
00243 z->bra = z->c;
00244 switch(among_var) {
00245 case 0: { z->lb = mlimit; return 0; }
00246 case 1:
00247 { int ret = slice_del(z);
00248 if (ret < 0) return ret;
00249 }
00250 break;
00251 case 2:
00252 { int ret = slice_from_s(z, 4, s_0);
00253 if (ret < 0) return ret;
00254 }
00255 break;
00256 case 3:
00257 { int ret = slice_from_s(z, 4, s_1);
00258 if (ret < 0) return ret;
00259 }
00260 break;
00261 }
00262 z->lb = mlimit;
00263 }
00264 return 1;
00265 }
00266
00267 extern int swedish_UTF_8_stem(struct SN_env * z) {
00268 { int c1 = z->c;
00269 { int ret = r_mark_regions(z);
00270 if (ret == 0) goto lab0;
00271 if (ret < 0) return ret;
00272 }
00273 lab0:
00274 z->c = c1;
00275 }
00276 z->lb = z->c; z->c = z->l;
00277
00278 { int m2 = z->l - z->c; (void)m2;
00279 { int ret = r_main_suffix(z);
00280 if (ret == 0) goto lab1;
00281 if (ret < 0) return ret;
00282 }
00283 lab1:
00284 z->c = z->l - m2;
00285 }
00286 { int m3 = z->l - z->c; (void)m3;
00287 { int ret = r_consonant_pair(z);
00288 if (ret == 0) goto lab2;
00289 if (ret < 0) return ret;
00290 }
00291 lab2:
00292 z->c = z->l - m3;
00293 }
00294 { int m4 = z->l - z->c; (void)m4;
00295 { int ret = r_other_suffix(z);
00296 if (ret == 0) goto lab3;
00297 if (ret < 0) return ret;
00298 }
00299 lab3:
00300 z->c = z->l - m4;
00301 }
00302 z->c = z->lb;
00303 return 1;
00304 }
00305
00306 extern struct SN_env * swedish_UTF_8_create_env(void) { return SN_create_env(0, 2, 0); }
00307
00308 extern void swedish_UTF_8_close_env(struct SN_env * z) { SN_close_env(z, 0); }
00309