00001
00002
00003 #include <limits.h>
00004 #include "danish.h"
00005
00006 #define s_0_0 (s_0_1 + 2)
00007 static const symbol s_pool[] = {
00008 #define s_0_1 0
00009 'e', 't', 'h', 'e', 'd',
00010 #define s_0_2 s_0_4
00011 #define s_0_3 (s_0_0 + 1)
00012 #define s_0_4 5
00013 'e', 'r', 'e', 'd', 'e',
00014 #define s_0_5 (s_0_6 + 2)
00015 #define s_0_6 s_0_20
00016 #define s_0_7 s_0_21
00017 #define s_0_8 s_0_22
00018 #define s_0_9 s_0_2
00019 #define s_0_10 s_0_5
00020 #define s_0_11 s_0_25
00021 #define s_0_12 s_0_6
00022 #define s_0_13 s_0_2
00023 #define s_0_14 10
00024 'h', 'e', 'd', 'e', 'r',
00025 #define s_0_15 15
00026 'e', 'r', 'e', 'r',
00027 #define s_0_16 (s_0_17 + 3)
00028 #define s_0_17 19
00029 'h', 'e', 'd', 's',
00030 #define s_0_18 (s_0_19 + 3)
00031 #define s_0_19 (s_0_20 + 2)
00032 #define s_0_20 23
00033 'e', 'r', 'e', 'n', 'd', 'e', 's',
00034 #define s_0_21 30
00035 'e', 'n', 'e', 's',
00036 #define s_0_22 34
00037 'e', 'r', 'n', 'e', 's',
00038 #define s_0_23 39
00039 'e', 'r', 'e', 's',
00040 #define s_0_24 (s_0_25 + 3)
00041 #define s_0_25 43
00042 'h', 'e', 'd', 'e', 'n', 's',
00043 #define s_0_26 49
00044 'e', 'r', 'e', 'n', 's',
00045 #define s_0_27 54
00046 'e', 'r', 's',
00047 #define s_0_28 (s_0_29 + 2)
00048 #define s_0_29 57
00049 'e', 'r', 'e', 't', 's',
00050 #define s_0_30 s_0_1
00051 #define s_0_31 s_0_29
00052 #define s_1_0 62
00053 'g', 'd',
00054 #define s_1_1 64
00055 'd', 't',
00056 #define s_1_2 66
00057 'g', 't',
00058 #define s_1_3 68
00059 'k', 't',
00060 #define s_2_0 (s_2_1 + 1)
00061 #define s_2_1 (s_2_2 + 1)
00062 #define s_2_2 70
00063 'e', 'l', 'i', 'g',
00064 #define s_2_3 74
00065 'e', 'l', 's',
00066 #define s_2_4 77
00067 'l', 0xC3, 0xB8, 's', 't',
00068 };
00069
00070
00071 static const struct among a_0[32] =
00072 {
00073 { 3, s_0_0, -1, 1},
00074 { 5, s_0_1, 0, 1},
00075 { 4, s_0_2, -1, 1},
00076 { 1, s_0_3, -1, 1},
00077 { 5, s_0_4, 3, 1},
00078 { 4, s_0_5, 3, 1},
00079 { 6, s_0_6, 5, 1},
00080 { 3, s_0_7, 3, 1},
00081 { 4, s_0_8, 3, 1},
00082 { 3, s_0_9, 3, 1},
00083 { 2, s_0_10, -1, 1},
00084 { 5, s_0_11, 10, 1},
00085 { 4, s_0_12, 10, 1},
00086 { 2, s_0_13, -1, 1},
00087 { 5, s_0_14, 13, 1},
00088 { 4, s_0_15, 13, 1},
00089 { 1, s_0_16, -1, 2},
00090 { 4, s_0_17, 16, 1},
00091 { 2, s_0_18, 16, 1},
00092 { 5, s_0_19, 18, 1},
00093 { 7, s_0_20, 19, 1},
00094 { 4, s_0_21, 18, 1},
00095 { 5, s_0_22, 18, 1},
00096 { 4, s_0_23, 18, 1},
00097 { 3, s_0_24, 16, 1},
00098 { 6, s_0_25, 24, 1},
00099 { 5, s_0_26, 24, 1},
00100 { 3, s_0_27, 16, 1},
00101 { 3, s_0_28, 16, 1},
00102 { 5, s_0_29, 28, 1},
00103 { 2, s_0_30, -1, 1},
00104 { 4, s_0_31, 30, 1}
00105 };
00106
00107
00108 static const struct among a_1[4] =
00109 {
00110 { 2, s_1_0, -1, -1},
00111 { 2, s_1_1, -1, -1},
00112 { 2, s_1_2, -1, -1},
00113 { 2, s_1_3, -1, -1}
00114 };
00115
00116
00117 static const struct among a_2[5] =
00118 {
00119 { 2, s_2_0, -1, 1},
00120 { 3, s_2_1, 0, 1},
00121 { 4, s_2_2, 1, 1},
00122 { 3, s_2_3, -1, 1},
00123 { 5, s_2_4, -1, 2}
00124 };
00125
00126 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 };
00127
00128 static const unsigned char g_s_ending[] = { 239, 254, 42, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 };
00129
00130 static const symbol s_0[] = { 's', 't' };
00131 static const symbol s_1[] = { 'i', 'g' };
00132 static const symbol s_2[] = { 'l', 0xC3, 0xB8, 's' };
00133
00134 int Xapian::InternalStemDanish::r_mark_regions() {
00135 I_p1 = l;
00136 { int c_test1 = c;
00137 { int ret = skip_utf8(p, c, 0, l, + 3);
00138 if (ret < 0) return 0;
00139 c = ret;
00140 }
00141 I_x = c;
00142 c = c_test1;
00143 }
00144 if (out_grouping_U(g_v, 97, 248, 1) < 0) return 0;
00145 { int ret = in_grouping_U(g_v, 97, 248, 1);
00146 if (ret < 0) return 0;
00147 c += ret;
00148 }
00149 I_p1 = c;
00150
00151 if (!(I_p1 < I_x)) goto lab0;
00152 I_p1 = I_x;
00153 lab0:
00154 return 1;
00155 }
00156
00157 int Xapian::InternalStemDanish::r_main_suffix() {
00158 int among_var;
00159 { int m1 = l - c; (void)m1;
00160 int mlimit1;
00161 if (c < I_p1) return 0;
00162 c = I_p1;
00163 mlimit1 = lb; lb = c;
00164 c = l - m1;
00165 ket = c;
00166 if (c <= lb || p[c - 1] >> 5 != 3 || !((1851440 >> (p[c - 1] & 0x1f)) & 1)) { lb = mlimit1; return 0; }
00167 among_var = find_among_b(s_pool, a_0, 32, 0, 0);
00168 if (!(among_var)) { lb = mlimit1; return 0; }
00169 bra = c;
00170 lb = mlimit1;
00171 }
00172 switch(among_var) {
00173 case 0: return 0;
00174 case 1:
00175 if (slice_del() == -1) return -1;
00176 break;
00177 case 2:
00178 if (in_grouping_b_U(g_s_ending, 97, 229, 0)) return 0;
00179 if (slice_del() == -1) return -1;
00180 break;
00181 }
00182 return 1;
00183 }
00184
00185 int Xapian::InternalStemDanish::r_consonant_pair() {
00186 { int m_test1 = l - c;
00187 { int m2 = l - c; (void)m2;
00188 int mlimit2;
00189 if (c < I_p1) return 0;
00190 c = I_p1;
00191 mlimit2 = lb; lb = c;
00192 c = l - m2;
00193 ket = c;
00194 if (c - 1 <= lb || (p[c - 1] != 100 && p[c - 1] != 116)) { lb = mlimit2; return 0; }
00195 if (!(find_among_b(s_pool, a_1, 4, 0, 0))) { lb = mlimit2; return 0; }
00196 bra = c;
00197 lb = mlimit2;
00198 }
00199 c = l - m_test1;
00200 }
00201 { int ret = skip_utf8(p, c, lb, 0, -1);
00202 if (ret < 0) return 0;
00203 c = ret;
00204 }
00205 bra = c;
00206 if (slice_del() == -1) return -1;
00207 return 1;
00208 }
00209
00210 int Xapian::InternalStemDanish::r_other_suffix() {
00211 int among_var;
00212 { int m1 = l - c; (void)m1;
00213 ket = c;
00214 if (!(eq_s_b(2, s_0))) goto lab0;
00215 bra = c;
00216 if (!(eq_s_b(2, s_1))) goto lab0;
00217 if (slice_del() == -1) return -1;
00218 lab0:
00219 c = l - m1;
00220 }
00221 { int m2 = l - c; (void)m2;
00222 int mlimit2;
00223 if (c < I_p1) return 0;
00224 c = I_p1;
00225 mlimit2 = lb; lb = c;
00226 c = l - m2;
00227 ket = c;
00228 if (c - 1 <= lb || p[c - 1] >> 5 != 3 || !((1572992 >> (p[c - 1] & 0x1f)) & 1)) { lb = mlimit2; return 0; }
00229 among_var = find_among_b(s_pool, a_2, 5, 0, 0);
00230 if (!(among_var)) { lb = mlimit2; return 0; }
00231 bra = c;
00232 lb = mlimit2;
00233 }
00234 switch(among_var) {
00235 case 0: return 0;
00236 case 1:
00237 if (slice_del() == -1) return -1;
00238 { int m3 = l - c; (void)m3;
00239 { int ret = r_consonant_pair();
00240 if (ret == 0) goto lab1;
00241 if (ret < 0) return ret;
00242 }
00243 lab1:
00244 c = l - m3;
00245 }
00246 break;
00247 case 2:
00248 { int ret = slice_from_s(4, s_2);
00249 if (ret < 0) return ret;
00250 }
00251 break;
00252 }
00253 return 1;
00254 }
00255
00256 int Xapian::InternalStemDanish::r_undouble() {
00257 { int m1 = l - c; (void)m1;
00258 int mlimit1;
00259 if (c < I_p1) return 0;
00260 c = I_p1;
00261 mlimit1 = lb; lb = c;
00262 c = l - m1;
00263 ket = c;
00264 if (out_grouping_b_U(g_v, 97, 248, 0)) { lb = mlimit1; return 0; }
00265 bra = c;
00266 { symbol * ret = slice_to(S_ch);
00267 if (ret == 0) return -1;
00268 S_ch = ret;
00269 }
00270 lb = mlimit1;
00271 }
00272 if (!(eq_v_b(S_ch))) return 0;
00273 if (slice_del() == -1) return -1;
00274 return 1;
00275 }
00276
00277 int Xapian::InternalStemDanish::stem() {
00278 { int c1 = c;
00279 { int ret = r_mark_regions();
00280 if (ret == 0) goto lab0;
00281 if (ret < 0) return ret;
00282 }
00283 lab0:
00284 c = c1;
00285 }
00286 lb = c; c = l;
00287
00288 { int m2 = l - c; (void)m2;
00289 { int ret = r_main_suffix();
00290 if (ret == 0) goto lab1;
00291 if (ret < 0) return ret;
00292 }
00293 lab1:
00294 c = l - m2;
00295 }
00296 { int m3 = l - c; (void)m3;
00297 { int ret = r_consonant_pair();
00298 if (ret == 0) goto lab2;
00299 if (ret < 0) return ret;
00300 }
00301 lab2:
00302 c = l - m3;
00303 }
00304 { int m4 = l - c; (void)m4;
00305 { int ret = r_other_suffix();
00306 if (ret == 0) goto lab3;
00307 if (ret < 0) return ret;
00308 }
00309 lab3:
00310 c = l - m4;
00311 }
00312 { int m5 = l - c; (void)m5;
00313 { int ret = r_undouble();
00314 if (ret == 0) goto lab4;
00315 if (ret < 0) return ret;
00316 }
00317 lab4:
00318 c = l - m5;
00319 }
00320 c = lb;
00321 return 1;
00322 }
00323
00324 Xapian::InternalStemDanish::InternalStemDanish()
00325 : I_x(0), I_p1(0), S_ch(0)
00326 {
00327 S_ch = create_s();
00328 }
00329
00330 Xapian::InternalStemDanish::~InternalStemDanish()
00331 {
00332 lose_s(S_ch);
00333 }
00334
00335 std::string
00336 Xapian::InternalStemDanish::get_description() const
00337 {
00338 return "danish";
00339 }