LCOV - code coverage report
Current view: top level - src/backend/snowball/libstemmer - stem_UTF_8_indonesian.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 0 197 0.0 %
Date: 2019-11-15 23:07:02 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This file was generated automatically by the Snowball to ISO C compiler */
       2             : /* http://snowballstem.org/ */
       3             : 
       4             : #include "header.h"
       5             : 
       6             : #ifdef __cplusplus
       7             : extern "C" {
       8             : #endif
       9             : extern int indonesian_UTF_8_stem(struct SN_env * z);
      10             : #ifdef __cplusplus
      11             : }
      12             : #endif
      13             : static int r_VOWEL(struct SN_env * z);
      14             : static int r_SUFFIX_I_OK(struct SN_env * z);
      15             : static int r_SUFFIX_AN_OK(struct SN_env * z);
      16             : static int r_SUFFIX_KAN_OK(struct SN_env * z);
      17             : static int r_KER(struct SN_env * z);
      18             : static int r_remove_suffix(struct SN_env * z);
      19             : static int r_remove_second_order_prefix(struct SN_env * z);
      20             : static int r_remove_first_order_prefix(struct SN_env * z);
      21             : static int r_remove_possessive_pronoun(struct SN_env * z);
      22             : static int r_remove_particle(struct SN_env * z);
      23             : #ifdef __cplusplus
      24             : extern "C" {
      25             : #endif
      26             : 
      27             : 
      28             : extern struct SN_env * indonesian_UTF_8_create_env(void);
      29             : extern void indonesian_UTF_8_close_env(struct SN_env * z);
      30             : 
      31             : 
      32             : #ifdef __cplusplus
      33             : }
      34             : #endif
      35             : static const symbol s_0_0[3] = { 'k', 'a', 'h' };
      36             : static const symbol s_0_1[3] = { 'l', 'a', 'h' };
      37             : static const symbol s_0_2[3] = { 'p', 'u', 'n' };
      38             : 
      39             : static const struct among a_0[3] =
      40             : {
      41             : /*  0 */ { 3, s_0_0, -1, 1, 0},
      42             : /*  1 */ { 3, s_0_1, -1, 1, 0},
      43             : /*  2 */ { 3, s_0_2, -1, 1, 0}
      44             : };
      45             : 
      46             : static const symbol s_1_0[3] = { 'n', 'y', 'a' };
      47             : static const symbol s_1_1[2] = { 'k', 'u' };
      48             : static const symbol s_1_2[2] = { 'm', 'u' };
      49             : 
      50             : static const struct among a_1[3] =
      51             : {
      52             : /*  0 */ { 3, s_1_0, -1, 1, 0},
      53             : /*  1 */ { 2, s_1_1, -1, 1, 0},
      54             : /*  2 */ { 2, s_1_2, -1, 1, 0}
      55             : };
      56             : 
      57             : static const symbol s_2_0[1] = { 'i' };
      58             : static const symbol s_2_1[2] = { 'a', 'n' };
      59             : static const symbol s_2_2[3] = { 'k', 'a', 'n' };
      60             : 
      61             : static const struct among a_2[3] =
      62             : {
      63             : /*  0 */ { 1, s_2_0, -1, 1, r_SUFFIX_I_OK},
      64             : /*  1 */ { 2, s_2_1, -1, 1, r_SUFFIX_AN_OK},
      65             : /*  2 */ { 3, s_2_2, 1, 1, r_SUFFIX_KAN_OK}
      66             : };
      67             : 
      68             : static const symbol s_3_0[2] = { 'd', 'i' };
      69             : static const symbol s_3_1[2] = { 'k', 'e' };
      70             : static const symbol s_3_2[2] = { 'm', 'e' };
      71             : static const symbol s_3_3[3] = { 'm', 'e', 'm' };
      72             : static const symbol s_3_4[3] = { 'm', 'e', 'n' };
      73             : static const symbol s_3_5[4] = { 'm', 'e', 'n', 'g' };
      74             : static const symbol s_3_6[4] = { 'm', 'e', 'n', 'y' };
      75             : static const symbol s_3_7[3] = { 'p', 'e', 'm' };
      76             : static const symbol s_3_8[3] = { 'p', 'e', 'n' };
      77             : static const symbol s_3_9[4] = { 'p', 'e', 'n', 'g' };
      78             : static const symbol s_3_10[4] = { 'p', 'e', 'n', 'y' };
      79             : static const symbol s_3_11[3] = { 't', 'e', 'r' };
      80             : 
      81             : static const struct among a_3[12] =
      82             : {
      83             : /*  0 */ { 2, s_3_0, -1, 1, 0},
      84             : /*  1 */ { 2, s_3_1, -1, 2, 0},
      85             : /*  2 */ { 2, s_3_2, -1, 1, 0},
      86             : /*  3 */ { 3, s_3_3, 2, 5, 0},
      87             : /*  4 */ { 3, s_3_4, 2, 1, 0},
      88             : /*  5 */ { 4, s_3_5, 4, 1, 0},
      89             : /*  6 */ { 4, s_3_6, 4, 3, r_VOWEL},
      90             : /*  7 */ { 3, s_3_7, -1, 6, 0},
      91             : /*  8 */ { 3, s_3_8, -1, 2, 0},
      92             : /*  9 */ { 4, s_3_9, 8, 2, 0},
      93             : /* 10 */ { 4, s_3_10, 8, 4, r_VOWEL},
      94             : /* 11 */ { 3, s_3_11, -1, 1, 0}
      95             : };
      96             : 
      97             : static const symbol s_4_0[2] = { 'b', 'e' };
      98             : static const symbol s_4_1[7] = { 'b', 'e', 'l', 'a', 'j', 'a', 'r' };
      99             : static const symbol s_4_2[3] = { 'b', 'e', 'r' };
     100             : static const symbol s_4_3[2] = { 'p', 'e' };
     101             : static const symbol s_4_4[7] = { 'p', 'e', 'l', 'a', 'j', 'a', 'r' };
     102             : static const symbol s_4_5[3] = { 'p', 'e', 'r' };
     103             : 
     104             : static const struct among a_4[6] =
     105             : {
     106             : /*  0 */ { 2, s_4_0, -1, 3, r_KER},
     107             : /*  1 */ { 7, s_4_1, 0, 4, 0},
     108             : /*  2 */ { 3, s_4_2, 0, 3, 0},
     109             : /*  3 */ { 2, s_4_3, -1, 1, 0},
     110             : /*  4 */ { 7, s_4_4, 3, 2, 0},
     111             : /*  5 */ { 3, s_4_5, 3, 1, 0}
     112             : };
     113             : 
     114             : static const unsigned char g_vowel[] = { 17, 65, 16 };
     115             : 
     116             : static const symbol s_0[] = { 'e', 'r' };
     117             : static const symbol s_1[] = { 's' };
     118             : static const symbol s_2[] = { 's' };
     119             : static const symbol s_3[] = { 'p' };
     120             : static const symbol s_4[] = { 'p' };
     121             : static const symbol s_5[] = { 'a', 'j', 'a', 'r' };
     122             : static const symbol s_6[] = { 'a', 'j', 'a', 'r' };
     123             : 
     124           0 : static int r_remove_particle(struct SN_env * z) { /* backwardmode */
     125           0 :     z->ket = z->c; /* [, line 51 */
     126           0 :     if (z->c - 2 <= z->lb || (z->p[z->c - 1] != 104 && z->p[z->c - 1] != 110)) return 0; /* substring, line 51 */
     127           0 :     if (!(find_among_b(z, a_0, 3))) return 0;
     128           0 :     z->bra = z->c; /* ], line 51 */
     129           0 :     {   int ret = slice_del(z); /* delete, line 52 */
     130           0 :         if (ret < 0) return ret;
     131             :     }
     132           0 :     z->I[0] -= 1; /* $measure -= <integer expression>, line 52 */
     133           0 :     return 1;
     134             : }
     135             : 
     136           0 : static int r_remove_possessive_pronoun(struct SN_env * z) { /* backwardmode */
     137           0 :     z->ket = z->c; /* [, line 57 */
     138           0 :     if (z->c - 1 <= z->lb || (z->p[z->c - 1] != 97 && z->p[z->c - 1] != 117)) return 0; /* substring, line 57 */
     139           0 :     if (!(find_among_b(z, a_1, 3))) return 0;
     140           0 :     z->bra = z->c; /* ], line 57 */
     141           0 :     {   int ret = slice_del(z); /* delete, line 58 */
     142           0 :         if (ret < 0) return ret;
     143             :     }
     144           0 :     z->I[0] -= 1; /* $measure -= <integer expression>, line 58 */
     145           0 :     return 1;
     146             : }
     147             : 
     148           0 : static int r_SUFFIX_KAN_OK(struct SN_env * z) { /* backwardmode */
     149             :     /* and, line 85 */
     150           0 :     if (!(z->I[1] != 3)) return 0; /* $(<integer expression> != <integer expression>), line 85 */
     151           0 :     if (!(z->I[1] != 2)) return 0; /* $(<integer expression> != <integer expression>), line 85 */
     152           0 :     return 1;
     153             : }
     154             : 
     155           0 : static int r_SUFFIX_AN_OK(struct SN_env * z) { /* backwardmode */
     156           0 :     if (!(z->I[1] != 1)) return 0; /* $(<integer expression> != <integer expression>), line 89 */
     157           0 :     return 1;
     158             : }
     159             : 
     160           0 : static int r_SUFFIX_I_OK(struct SN_env * z) { /* backwardmode */
     161           0 :     if (!(z->I[1] <= 2)) return 0; /* $(<integer expression> <= <integer expression>), line 93 */
     162           0 :     {   int m1 = z->l - z->c; (void)m1; /* not, line 128 */
     163           0 :         if (z->c <= z->lb || z->p[z->c - 1] != 's') goto lab0; /* literal, line 128 */
     164           0 :         z->c--;
     165           0 :         return 0;
     166             :     lab0:
     167           0 :         z->c = z->l - m1;
     168             :     }
     169           0 :     return 1;
     170             : }
     171             : 
     172           0 : static int r_remove_suffix(struct SN_env * z) { /* backwardmode */
     173           0 :     z->ket = z->c; /* [, line 132 */
     174           0 :     if (z->c <= z->lb || (z->p[z->c - 1] != 105 && z->p[z->c - 1] != 110)) return 0; /* substring, line 132 */
     175           0 :     if (!(find_among_b(z, a_2, 3))) return 0;
     176           0 :     z->bra = z->c; /* ], line 132 */
     177           0 :     {   int ret = slice_del(z); /* delete, line 134 */
     178           0 :         if (ret < 0) return ret;
     179             :     }
     180           0 :     z->I[0] -= 1; /* $measure -= <integer expression>, line 134 */
     181           0 :     return 1;
     182             : }
     183             : 
     184           0 : static int r_VOWEL(struct SN_env * z) { /* forwardmode */
     185           0 :     if (in_grouping_U(z, g_vowel, 97, 117, 0)) return 0; /* grouping vowel, line 141 */
     186           0 :     return 1;
     187             : }
     188             : 
     189           0 : static int r_KER(struct SN_env * z) { /* forwardmode */
     190           0 :     if (out_grouping_U(z, g_vowel, 97, 117, 0)) return 0; /* non vowel, line 143 */
     191           0 :     if (!(eq_s(z, 2, s_0))) return 0; /* literal, line 143 */
     192           0 :     return 1;
     193             : }
     194             : 
     195           0 : static int r_remove_first_order_prefix(struct SN_env * z) { /* forwardmode */
     196             :     int among_var;
     197           0 :     z->bra = z->c; /* [, line 146 */
     198           0 :     if (z->c + 1 >= z->l || (z->p[z->c + 1] != 105 && z->p[z->c + 1] != 101)) return 0; /* substring, line 146 */
     199           0 :     among_var = find_among(z, a_3, 12);
     200           0 :     if (!(among_var)) return 0;
     201           0 :     z->ket = z->c; /* ], line 146 */
     202           0 :     switch (among_var) { /* among, line 146 */
     203             :         case 1:
     204           0 :             {   int ret = slice_del(z); /* delete, line 147 */
     205           0 :                 if (ret < 0) return ret;
     206             :             }
     207           0 :             z->I[1] = 1; /* $prefix = <integer expression>, line 147 */
     208           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 147 */
     209           0 :             break;
     210             :         case 2:
     211           0 :             {   int ret = slice_del(z); /* delete, line 148 */
     212           0 :                 if (ret < 0) return ret;
     213             :             }
     214           0 :             z->I[1] = 3; /* $prefix = <integer expression>, line 148 */
     215           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 148 */
     216           0 :             break;
     217             :         case 3:
     218           0 :             z->I[1] = 1; /* $prefix = <integer expression>, line 149 */
     219           0 :             {   int ret = slice_from_s(z, 1, s_1); /* <-, line 149 */
     220           0 :                 if (ret < 0) return ret;
     221             :             }
     222           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 149 */
     223           0 :             break;
     224             :         case 4:
     225           0 :             z->I[1] = 3; /* $prefix = <integer expression>, line 150 */
     226           0 :             {   int ret = slice_from_s(z, 1, s_2); /* <-, line 150 */
     227           0 :                 if (ret < 0) return ret;
     228             :             }
     229           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 150 */
     230           0 :             break;
     231             :         case 5:
     232           0 :             z->I[1] = 1; /* $prefix = <integer expression>, line 151 */
     233           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 151 */
     234           0 :             {   int c1 = z->c; /* or, line 151 */
     235           0 :                 {   int c2 = z->c; /* and, line 151 */
     236           0 :                     if (in_grouping_U(z, g_vowel, 97, 117, 0)) goto lab1; /* grouping vowel, line 151 */
     237           0 :                     z->c = c2;
     238           0 :                     {   int ret = slice_from_s(z, 1, s_3); /* <-, line 151 */
     239           0 :                         if (ret < 0) return ret;
     240             :                     }
     241             :                 }
     242           0 :                 goto lab0;
     243             :             lab1:
     244           0 :                 z->c = c1;
     245           0 :                 {   int ret = slice_del(z); /* delete, line 151 */
     246           0 :                     if (ret < 0) return ret;
     247             :                 }
     248             :             }
     249             :         lab0:
     250           0 :             break;
     251             :         case 6:
     252           0 :             z->I[1] = 3; /* $prefix = <integer expression>, line 152 */
     253           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 152 */
     254           0 :             {   int c3 = z->c; /* or, line 152 */
     255           0 :                 {   int c4 = z->c; /* and, line 152 */
     256           0 :                     if (in_grouping_U(z, g_vowel, 97, 117, 0)) goto lab3; /* grouping vowel, line 152 */
     257           0 :                     z->c = c4;
     258           0 :                     {   int ret = slice_from_s(z, 1, s_4); /* <-, line 152 */
     259           0 :                         if (ret < 0) return ret;
     260             :                     }
     261             :                 }
     262           0 :                 goto lab2;
     263             :             lab3:
     264           0 :                 z->c = c3;
     265           0 :                 {   int ret = slice_del(z); /* delete, line 152 */
     266           0 :                     if (ret < 0) return ret;
     267             :                 }
     268             :             }
     269             :         lab2:
     270           0 :             break;
     271             :     }
     272           0 :     return 1;
     273             : }
     274             : 
     275           0 : static int r_remove_second_order_prefix(struct SN_env * z) { /* forwardmode */
     276             :     int among_var;
     277           0 :     z->bra = z->c; /* [, line 162 */
     278           0 :     if (z->c + 1 >= z->l || z->p[z->c + 1] != 101) return 0; /* substring, line 162 */
     279           0 :     among_var = find_among(z, a_4, 6);
     280           0 :     if (!(among_var)) return 0;
     281           0 :     z->ket = z->c; /* ], line 162 */
     282           0 :     switch (among_var) { /* among, line 162 */
     283             :         case 1:
     284           0 :             {   int ret = slice_del(z); /* delete, line 163 */
     285           0 :                 if (ret < 0) return ret;
     286             :             }
     287           0 :             z->I[1] = 2; /* $prefix = <integer expression>, line 163 */
     288           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 163 */
     289           0 :             break;
     290             :         case 2:
     291           0 :             {   int ret = slice_from_s(z, 4, s_5); /* <-, line 164 */
     292           0 :                 if (ret < 0) return ret;
     293             :             }
     294           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 164 */
     295           0 :             break;
     296             :         case 3:
     297           0 :             {   int ret = slice_del(z); /* delete, line 165 */
     298           0 :                 if (ret < 0) return ret;
     299             :             }
     300           0 :             z->I[1] = 4; /* $prefix = <integer expression>, line 165 */
     301           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 165 */
     302           0 :             break;
     303             :         case 4:
     304           0 :             {   int ret = slice_from_s(z, 4, s_6); /* <-, line 166 */
     305           0 :                 if (ret < 0) return ret;
     306             :             }
     307           0 :             z->I[1] = 4; /* $prefix = <integer expression>, line 166 */
     308           0 :             z->I[0] -= 1; /* $measure -= <integer expression>, line 166 */
     309           0 :             break;
     310             :     }
     311           0 :     return 1;
     312             : }
     313             : 
     314           0 : extern int indonesian_UTF_8_stem(struct SN_env * z) { /* forwardmode */
     315           0 :     z->I[0] = 0; /* $measure = <integer expression>, line 172 */
     316           0 :     {   int c1 = z->c; /* do, line 173 */
     317           0 :         while(1) { /* repeat, line 173 */
     318           0 :             int c2 = z->c;
     319             :             {    /* gopast */ /* grouping vowel, line 173 */
     320           0 :                 int ret = out_grouping_U(z, g_vowel, 97, 117, 1);
     321           0 :                 if (ret < 0) goto lab1;
     322           0 :                 z->c += ret;
     323             :             }
     324           0 :             z->I[0] += 1; /* $measure += <integer expression>, line 173 */
     325           0 :             continue;
     326             :         lab1:
     327           0 :             z->c = c2;
     328           0 :             break;
     329             :         }
     330           0 :         z->c = c1;
     331             :     }
     332           0 :     if (!(z->I[0] > 2)) return 0; /* $(<integer expression> > <integer expression>), line 174 */
     333           0 :     z->I[1] = 0; /* $prefix = <integer expression>, line 175 */
     334           0 :     z->lb = z->c; z->c = z->l; /* backwards, line 176 */
     335             : 
     336           0 :     {   int m3 = z->l - z->c; (void)m3; /* do, line 177 */
     337           0 :         {   int ret = r_remove_particle(z); /* call remove_particle, line 177 */
     338           0 :             if (ret == 0) goto lab2;
     339           0 :             if (ret < 0) return ret;
     340             :         }
     341             :     lab2:
     342           0 :         z->c = z->l - m3;
     343             :     }
     344           0 :     if (!(z->I[0] > 2)) return 0; /* $(<integer expression> > <integer expression>), line 178 */
     345           0 :     {   int m4 = z->l - z->c; (void)m4; /* do, line 179 */
     346           0 :         {   int ret = r_remove_possessive_pronoun(z); /* call remove_possessive_pronoun, line 179 */
     347           0 :             if (ret == 0) goto lab3;
     348           0 :             if (ret < 0) return ret;
     349             :         }
     350             :     lab3:
     351           0 :         z->c = z->l - m4;
     352             :     }
     353           0 :     z->c = z->lb;
     354           0 :     if (!(z->I[0] > 2)) return 0; /* $(<integer expression> > <integer expression>), line 181 */
     355           0 :     {   int c5 = z->c; /* or, line 188 */
     356           0 :         {   int c_test6 = z->c; /* test, line 182 */
     357           0 :             {   int ret = r_remove_first_order_prefix(z); /* call remove_first_order_prefix, line 183 */
     358           0 :                 if (ret == 0) goto lab5;
     359           0 :                 if (ret < 0) return ret;
     360             :             }
     361           0 :             {   int c7 = z->c; /* do, line 184 */
     362           0 :                 {   int c_test8 = z->c; /* test, line 185 */
     363           0 :                     if (!(z->I[0] > 2)) goto lab6; /* $(<integer expression> > <integer expression>), line 185 */
     364           0 :                     z->lb = z->c; z->c = z->l; /* backwards, line 185 */
     365             : 
     366           0 :                     {   int ret = r_remove_suffix(z); /* call remove_suffix, line 185 */
     367           0 :                         if (ret == 0) goto lab6;
     368           0 :                         if (ret < 0) return ret;
     369             :                     }
     370           0 :                     z->c = z->lb;
     371           0 :                     z->c = c_test8;
     372             :                 }
     373           0 :                 if (!(z->I[0] > 2)) goto lab6; /* $(<integer expression> > <integer expression>), line 186 */
     374           0 :                 {   int ret = r_remove_second_order_prefix(z); /* call remove_second_order_prefix, line 186 */
     375           0 :                     if (ret == 0) goto lab6;
     376           0 :                     if (ret < 0) return ret;
     377             :                 }
     378             :             lab6:
     379           0 :                 z->c = c7;
     380             :             }
     381           0 :             z->c = c_test6;
     382             :         }
     383           0 :         goto lab4;
     384             :     lab5:
     385           0 :         z->c = c5;
     386           0 :         {   int c9 = z->c; /* do, line 189 */
     387           0 :             {   int ret = r_remove_second_order_prefix(z); /* call remove_second_order_prefix, line 189 */
     388           0 :                 if (ret == 0) goto lab7;
     389           0 :                 if (ret < 0) return ret;
     390             :             }
     391             :         lab7:
     392           0 :             z->c = c9;
     393             :         }
     394           0 :         {   int c10 = z->c; /* do, line 190 */
     395           0 :             if (!(z->I[0] > 2)) goto lab8; /* $(<integer expression> > <integer expression>), line 190 */
     396           0 :             z->lb = z->c; z->c = z->l; /* backwards, line 190 */
     397             : 
     398           0 :             {   int ret = r_remove_suffix(z); /* call remove_suffix, line 190 */
     399           0 :                 if (ret == 0) goto lab8;
     400           0 :                 if (ret < 0) return ret;
     401             :             }
     402           0 :             z->c = z->lb;
     403             :         lab8:
     404           0 :             z->c = c10;
     405             :         }
     406             :     }
     407             : lab4:
     408           0 :     return 1;
     409             : }
     410             : 
     411           0 : extern struct SN_env * indonesian_UTF_8_create_env(void) { return SN_create_env(0, 2, 0); }
     412             : 
     413           0 : extern void indonesian_UTF_8_close_env(struct SN_env * z) { SN_close_env(z, 0); }
     414             : 

Generated by: LCOV version 1.13