LCOV - code coverage report
Current view: top level - src/backend/snowball/libstemmer - stem_UTF_8_indonesian.c (source / functions) Hit Total Coverage
Test: PostgreSQL 14devel Lines: 0 213 0.0 %
Date: 2020-09-25 16:06:32 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13