languages/norwegian.cc

Go to the documentation of this file.
00001 /* This file was generated automatically by the Snowball to ISO C++ compiler */
00002 
00003 #include <limits.h>
00004 #include "norwegian.h"
00005 
00006 static const symbol s_pool[] = {
00007 #define s_0_0 0
00008 'a',
00009 #define s_0_1 1
00010 'e',
00011 #define s_0_2 2
00012 'e', 'd', 'e',
00013 #define s_0_3 5
00014 'a', 'n', 'd', 'e',
00015 #define s_0_4 9
00016 'e', 'n', 'd', 'e',
00017 #define s_0_5 13
00018 'a', 'n', 'e',
00019 #define s_0_6 16
00020 'e', 'n', 'e',
00021 #define s_0_7 19
00022 'h', 'e', 't', 'e', 'n', 'e',
00023 #define s_0_8 25
00024 'e', 'r', 't', 'e',
00025 #define s_0_9 29
00026 'e', 'n',
00027 #define s_0_10 31
00028 'h', 'e', 't', 'e', 'n',
00029 #define s_0_11 36
00030 'a', 'r',
00031 #define s_0_12 38
00032 'e', 'r',
00033 #define s_0_13 40
00034 'h', 'e', 't', 'e', 'r',
00035 #define s_0_14 45
00036 's',
00037 #define s_0_15 46
00038 'a', 's',
00039 #define s_0_16 48
00040 'e', 's',
00041 #define s_0_17 50
00042 'e', 'd', 'e', 's',
00043 #define s_0_18 54
00044 'e', 'n', 'd', 'e', 's',
00045 #define s_0_19 59
00046 'e', 'n', 'e', 's',
00047 #define s_0_20 63
00048 'h', 'e', 't', 'e', 'n', 'e', 's',
00049 #define s_0_21 70
00050 'e', 'n', 's',
00051 #define s_0_22 73
00052 'h', 'e', 't', 'e', 'n', 's',
00053 #define s_0_23 79
00054 'e', 'r', 's',
00055 #define s_0_24 82
00056 'e', 't', 's',
00057 #define s_0_25 85
00058 'e', 't',
00059 #define s_0_26 87
00060 'h', 'e', 't',
00061 #define s_0_27 90
00062 'e', 'r', 't',
00063 #define s_0_28 93
00064 'a', 's', 't',
00065 #define s_1_0 96
00066 'd', 't',
00067 #define s_1_1 98
00068 'v', 't',
00069 #define s_2_0 100
00070 'l', 'e', 'g',
00071 #define s_2_1 103
00072 'e', 'l', 'e', 'g',
00073 #define s_2_2 107
00074 'i', 'g',
00075 #define s_2_3 109
00076 'e', 'i', 'g',
00077 #define s_2_4 112
00078 'l', 'i', 'g',
00079 #define s_2_5 115
00080 'e', 'l', 'i', 'g',
00081 #define s_2_6 119
00082 'e', 'l', 's',
00083 #define s_2_7 122
00084 'l', 'o', 'v',
00085 #define s_2_8 125
00086 'e', 'l', 'o', 'v',
00087 #define s_2_9 129
00088 's', 'l', 'o', 'v',
00089 #define s_2_10 133
00090 'h', 'e', 't', 's', 'l', 'o', 'v',
00091 };
00092 
00093 
00094 static const struct among a_0[29] =
00095 {
00096 /*  0 */ { 1, s_0_0, -1, 1},
00097 /*  1 */ { 1, s_0_1, -1, 1},
00098 /*  2 */ { 3, s_0_2, 1, 1},
00099 /*  3 */ { 4, s_0_3, 1, 1},
00100 /*  4 */ { 4, s_0_4, 1, 1},
00101 /*  5 */ { 3, s_0_5, 1, 1},
00102 /*  6 */ { 3, s_0_6, 1, 1},
00103 /*  7 */ { 6, s_0_7, 6, 1},
00104 /*  8 */ { 4, s_0_8, 1, 3},
00105 /*  9 */ { 2, s_0_9, -1, 1},
00106 /* 10 */ { 5, s_0_10, 9, 1},
00107 /* 11 */ { 2, s_0_11, -1, 1},
00108 /* 12 */ { 2, s_0_12, -1, 1},
00109 /* 13 */ { 5, s_0_13, 12, 1},
00110 /* 14 */ { 1, s_0_14, -1, 2},
00111 /* 15 */ { 2, s_0_15, 14, 1},
00112 /* 16 */ { 2, s_0_16, 14, 1},
00113 /* 17 */ { 4, s_0_17, 16, 1},
00114 /* 18 */ { 5, s_0_18, 16, 1},
00115 /* 19 */ { 4, s_0_19, 16, 1},
00116 /* 20 */ { 7, s_0_20, 19, 1},
00117 /* 21 */ { 3, s_0_21, 14, 1},
00118 /* 22 */ { 6, s_0_22, 21, 1},
00119 /* 23 */ { 3, s_0_23, 14, 1},
00120 /* 24 */ { 3, s_0_24, 14, 1},
00121 /* 25 */ { 2, s_0_25, -1, 1},
00122 /* 26 */ { 3, s_0_26, 25, 1},
00123 /* 27 */ { 3, s_0_27, -1, 3},
00124 /* 28 */ { 3, s_0_28, -1, 1}
00125 };
00126 
00127 
00128 static const struct among a_1[2] =
00129 {
00130 /*  0 */ { 2, s_1_0, -1, -1},
00131 /*  1 */ { 2, s_1_1, -1, -1}
00132 };
00133 
00134 
00135 static const struct among a_2[11] =
00136 {
00137 /*  0 */ { 3, s_2_0, -1, 1},
00138 /*  1 */ { 4, s_2_1, 0, 1},
00139 /*  2 */ { 2, s_2_2, -1, 1},
00140 /*  3 */ { 3, s_2_3, 2, 1},
00141 /*  4 */ { 3, s_2_4, 2, 1},
00142 /*  5 */ { 4, s_2_5, 4, 1},
00143 /*  6 */ { 3, s_2_6, -1, 1},
00144 /*  7 */ { 3, s_2_7, -1, 1},
00145 /*  8 */ { 4, s_2_8, 7, 1},
00146 /*  9 */ { 4, s_2_9, 7, 1},
00147 /* 10 */ { 7, s_2_10, 9, 1}
00148 };
00149 
00150 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 };
00151 
00152 static const unsigned char g_s_ending[] = { 119, 125, 149, 1 };
00153 
00154 static const symbol s_0[] = { 'e', 'r' };
00155 
00156 int Xapian::InternalStemNorwegian::r_mark_regions() { /* forwardmode */
00157     I_p1 = l; /* p1 = <integer expression>, line 28 */
00158     {   int c_test1 = c; /* test, line 30 */
00159         {   int ret = skip_utf8(p, c, 0, l, + 3); /* hop, line 30 */
00160             if (ret < 0) return 0;
00161             c = ret;
00162         }
00163         I_x = c; /* setmark x, line 30 */
00164         c = c_test1;
00165     }
00166     if (out_grouping_U(g_v, 97, 248, 1) < 0) return 0; /* goto */ /* grouping v, line 31 */
00167     {   int ret = in_grouping_U(g_v, 97, 248, 1); /* gopast */ /* non v, line 31 */
00168         if (ret < 0) return 0;
00169         c += ret;
00170     }
00171     I_p1 = c; /* setmark p1, line 31 */
00172     /* try, line 32 */
00173     if (!(I_p1 < I_x)) goto lab0; /* p1 < <integer expression>, line 32 */
00174     I_p1 = I_x; /* p1 = <integer expression>, line 32 */
00175 lab0:
00176     return 1;
00177 }
00178 
00179 int Xapian::InternalStemNorwegian::r_main_suffix() { /* backwardmode */
00180     int among_var;
00181     {   int m1 = l - c; (void)m1; /* setlimit, line 38 */
00182         int mlimit1;
00183         if (c < I_p1) return 0;
00184         c = I_p1; /* tomark, line 38 */
00185         mlimit1 = lb; lb = c;
00186         c = l - m1;
00187         ket = c; /* [, line 38 */
00188         if (c <= lb || p[c - 1] >> 5 != 3 || !((1851426 >> (p[c - 1] & 0x1f)) & 1)) { lb = mlimit1; return 0; } /* substring, line 38 */
00189         among_var = find_among_b(s_pool, a_0, 29, 0, 0);
00190         if (!(among_var)) { lb = mlimit1; return 0; }
00191         bra = c; /* ], line 38 */
00192         lb = mlimit1;
00193     }
00194     switch(among_var) { /* among, line 39 */
00195         case 0: return 0;
00196         case 1:
00197             if (slice_del() == -1) return -1; /* delete, line 44 */
00198             break;
00199         case 2:
00200             {   int m2 = l - c; (void)m2; /* or, line 46 */
00201                 if (in_grouping_b_U(g_s_ending, 98, 122, 0)) goto lab1; /* grouping s_ending, line 46 */
00202                 goto lab0;
00203             lab1:
00204                 c = l - m2;
00205                 if (c <= lb || p[c - 1] != 'k') return 0;
00206                 c--;
00207                 if (out_grouping_b_U(g_v, 97, 248, 0)) return 0; /* non v, line 46 */
00208             }
00209         lab0:
00210             if (slice_del() == -1) return -1; /* delete, line 46 */
00211             break;
00212         case 3:
00213             {   int ret = slice_from_s(2, s_0); /* <-, line 48 */
00214                 if (ret < 0) return ret;
00215             }
00216             break;
00217     }
00218     return 1;
00219 }
00220 
00221 int Xapian::InternalStemNorwegian::r_consonant_pair() { /* backwardmode */
00222     {   int m_test1 = l - c; /* test, line 53 */
00223         {   int m2 = l - c; (void)m2; /* setlimit, line 54 */
00224             int mlimit2;
00225             if (c < I_p1) return 0;
00226             c = I_p1; /* tomark, line 54 */
00227             mlimit2 = lb; lb = c;
00228             c = l - m2;
00229             ket = c; /* [, line 54 */
00230             if (c - 1 <= lb || p[c - 1] != 116) { lb = mlimit2; return 0; } /* substring, line 54 */
00231             if (!(find_among_b(s_pool, a_1, 2, 0, 0))) { lb = mlimit2; return 0; }
00232             bra = c; /* ], line 54 */
00233             lb = mlimit2;
00234         }
00235         c = l - m_test1;
00236     }
00237     {   int ret = skip_utf8(p, c, lb, 0, -1);
00238         if (ret < 0) return 0;
00239         c = ret; /* next, line 59 */
00240     }
00241     bra = c; /* ], line 59 */
00242     if (slice_del() == -1) return -1; /* delete, line 59 */
00243     return 1;
00244 }
00245 
00246 int Xapian::InternalStemNorwegian::r_other_suffix() { /* backwardmode */
00247     int among_var;
00248     {   int m1 = l - c; (void)m1; /* setlimit, line 63 */
00249         int mlimit1;
00250         if (c < I_p1) return 0;
00251         c = I_p1; /* tomark, line 63 */
00252         mlimit1 = lb; lb = c;
00253         c = l - m1;
00254         ket = c; /* [, line 63 */
00255         if (c - 1 <= lb || p[c - 1] >> 5 != 3 || !((4718720 >> (p[c - 1] & 0x1f)) & 1)) { lb = mlimit1; return 0; } /* substring, line 63 */
00256         among_var = find_among_b(s_pool, a_2, 11, 0, 0);
00257         if (!(among_var)) { lb = mlimit1; return 0; }
00258         bra = c; /* ], line 63 */
00259         lb = mlimit1;
00260     }
00261     switch(among_var) { /* among, line 64 */
00262         case 0: return 0;
00263         case 1:
00264             if (slice_del() == -1) return -1; /* delete, line 67 */
00265             break;
00266     }
00267     return 1;
00268 }
00269 
00270 int Xapian::InternalStemNorwegian::stem() { /* forwardmode */
00271     {   int c1 = c; /* do, line 74 */
00272         {   int ret = r_mark_regions(); /* call mark_regions, line 74 */
00273             if (ret == 0) goto lab0;
00274             if (ret < 0) return ret;
00275         }
00276     lab0:
00277         c = c1;
00278     }
00279     lb = c; c = l; /* backwards, line 75 */
00280 
00281     {   int m2 = l - c; (void)m2; /* do, line 76 */
00282         {   int ret = r_main_suffix(); /* call main_suffix, line 76 */
00283             if (ret == 0) goto lab1;
00284             if (ret < 0) return ret;
00285         }
00286     lab1:
00287         c = l - m2;
00288     }
00289     {   int m3 = l - c; (void)m3; /* do, line 77 */
00290         {   int ret = r_consonant_pair(); /* call consonant_pair, line 77 */
00291             if (ret == 0) goto lab2;
00292             if (ret < 0) return ret;
00293         }
00294     lab2:
00295         c = l - m3;
00296     }
00297     {   int m4 = l - c; (void)m4; /* do, line 78 */
00298         {   int ret = r_other_suffix(); /* call other_suffix, line 78 */
00299             if (ret == 0) goto lab3;
00300             if (ret < 0) return ret;
00301         }
00302     lab3:
00303         c = l - m4;
00304     }
00305     c = lb;
00306     return 1;
00307 }
00308 
00309 Xapian::InternalStemNorwegian::InternalStemNorwegian()
00310     : I_x(0), I_p1(0)
00311 {
00312 }
00313 
00314 Xapian::InternalStemNorwegian::~InternalStemNorwegian()
00315 {
00316 }
00317 
00318 const char *
00319 Xapian::InternalStemNorwegian::get_description() const
00320 {
00321     return "norwegian";
00322 }

Documentation for Xapian (version 1.0.20).
Generated on 28 Apr 2010 by Doxygen 1.5.2.