LCOV - code coverage report
Current view: top level - src/backend/snowball/libstemmer - stem_UTF_8_norwegian.c (source / functions) Coverage Total Hit
Test: Code coverage Lines: 0.0 % 155 0
Test Date: 2026-01-26 10:56:24 Functions: 0.0 % 7 0
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 0.0 % 141 0

             Branch data     Line data    Source code
       1                 :             : /* Generated from norwegian.sbl by Snowball 3.0.0 - https://snowballstem.org/ */
       2                 :             : 
       3                 :             : #include "stem_UTF_8_norwegian.h"
       4                 :             : 
       5                 :             : #include <stddef.h>
       6                 :             : 
       7                 :             : #include "snowball_runtime.h"
       8                 :             : 
       9                 :             : struct SN_local {
      10                 :             :     struct SN_env z;
      11                 :             :     int i_p1;
      12                 :             : };
      13                 :             : 
      14                 :             : typedef struct SN_local SN_local;
      15                 :             : 
      16                 :             : #ifdef __cplusplus
      17                 :             : extern "C" {
      18                 :             : #endif
      19                 :             : extern int norwegian_UTF_8_stem(struct SN_env * z);
      20                 :             : #ifdef __cplusplus
      21                 :             : }
      22                 :             : #endif
      23                 :             : 
      24                 :             : static int r_other_suffix(struct SN_env * z);
      25                 :             : static int r_consonant_pair(struct SN_env * z);
      26                 :             : static int r_main_suffix(struct SN_env * z);
      27                 :             : static int r_mark_regions(struct SN_env * z);
      28                 :             : 
      29                 :             : static const symbol s_0[] = { 'e', 'r' };
      30                 :             : 
      31                 :             : static const symbol s_0_1[3] = { 'i', 'n', 'd' };
      32                 :             : static const symbol s_0_2[2] = { 'k', 'k' };
      33                 :             : static const symbol s_0_3[2] = { 'n', 'k' };
      34                 :             : static const symbol s_0_4[3] = { 'a', 'm', 'm' };
      35                 :             : static const symbol s_0_5[3] = { 'o', 'm', 'm' };
      36                 :             : static const symbol s_0_6[3] = { 'k', 'a', 'p' };
      37                 :             : static const symbol s_0_7[4] = { 's', 'k', 'a', 'p' };
      38                 :             : static const symbol s_0_8[2] = { 'p', 'p' };
      39                 :             : static const symbol s_0_9[2] = { 'l', 't' };
      40                 :             : static const symbol s_0_10[3] = { 'a', 's', 't' };
      41                 :             : static const symbol s_0_11[4] = { 0xC3, 0xB8, 's', 't' };
      42                 :             : static const symbol s_0_12[1] = { 'v' };
      43                 :             : static const symbol s_0_13[3] = { 'h', 'a', 'v' };
      44                 :             : static const symbol s_0_14[3] = { 'g', 'i', 'v' };
      45                 :             : static const struct among a_0[15] = {
      46                 :             : { 0, 0, 0, 1, 0},
      47                 :             : { 3, s_0_1, -1, -1, 0},
      48                 :             : { 2, s_0_2, -2, -1, 0},
      49                 :             : { 2, s_0_3, -3, -1, 0},
      50                 :             : { 3, s_0_4, -4, -1, 0},
      51                 :             : { 3, s_0_5, -5, -1, 0},
      52                 :             : { 3, s_0_6, -6, -1, 0},
      53                 :             : { 4, s_0_7, -1, 1, 0},
      54                 :             : { 2, s_0_8, -8, -1, 0},
      55                 :             : { 2, s_0_9, -9, -1, 0},
      56                 :             : { 3, s_0_10, -10, -1, 0},
      57                 :             : { 4, s_0_11, -11, -1, 0},
      58                 :             : { 1, s_0_12, -12, -1, 0},
      59                 :             : { 3, s_0_13, -1, 1, 0},
      60                 :             : { 3, s_0_14, -2, 1, 0}
      61                 :             : };
      62                 :             : 
      63                 :             : static const symbol s_1_0[1] = { 'a' };
      64                 :             : static const symbol s_1_1[1] = { 'e' };
      65                 :             : static const symbol s_1_2[3] = { 'e', 'd', 'e' };
      66                 :             : static const symbol s_1_3[4] = { 'a', 'n', 'd', 'e' };
      67                 :             : static const symbol s_1_4[4] = { 'e', 'n', 'd', 'e' };
      68                 :             : static const symbol s_1_5[3] = { 'a', 'n', 'e' };
      69                 :             : static const symbol s_1_6[3] = { 'e', 'n', 'e' };
      70                 :             : static const symbol s_1_7[6] = { 'h', 'e', 't', 'e', 'n', 'e' };
      71                 :             : static const symbol s_1_8[4] = { 'e', 'r', 't', 'e' };
      72                 :             : static const symbol s_1_9[2] = { 'e', 'n' };
      73                 :             : static const symbol s_1_10[5] = { 'h', 'e', 't', 'e', 'n' };
      74                 :             : static const symbol s_1_11[2] = { 'a', 'r' };
      75                 :             : static const symbol s_1_12[2] = { 'e', 'r' };
      76                 :             : static const symbol s_1_13[5] = { 'h', 'e', 't', 'e', 'r' };
      77                 :             : static const symbol s_1_14[1] = { 's' };
      78                 :             : static const symbol s_1_15[2] = { 'a', 's' };
      79                 :             : static const symbol s_1_16[2] = { 'e', 's' };
      80                 :             : static const symbol s_1_17[4] = { 'e', 'd', 'e', 's' };
      81                 :             : static const symbol s_1_18[5] = { 'e', 'n', 'd', 'e', 's' };
      82                 :             : static const symbol s_1_19[4] = { 'e', 'n', 'e', 's' };
      83                 :             : static const symbol s_1_20[7] = { 'h', 'e', 't', 'e', 'n', 'e', 's' };
      84                 :             : static const symbol s_1_21[3] = { 'e', 'n', 's' };
      85                 :             : static const symbol s_1_22[6] = { 'h', 'e', 't', 'e', 'n', 's' };
      86                 :             : static const symbol s_1_23[3] = { 'e', 'r', 's' };
      87                 :             : static const symbol s_1_24[3] = { 'e', 't', 's' };
      88                 :             : static const symbol s_1_25[2] = { 'e', 't' };
      89                 :             : static const symbol s_1_26[3] = { 'h', 'e', 't' };
      90                 :             : static const symbol s_1_27[3] = { 'e', 'r', 't' };
      91                 :             : static const symbol s_1_28[3] = { 'a', 's', 't' };
      92                 :             : static const struct among a_1[29] = {
      93                 :             : { 1, s_1_0, 0, 1, 0},
      94                 :             : { 1, s_1_1, 0, 1, 0},
      95                 :             : { 3, s_1_2, -1, 1, 0},
      96                 :             : { 4, s_1_3, -2, 1, 0},
      97                 :             : { 4, s_1_4, -3, 1, 0},
      98                 :             : { 3, s_1_5, -4, 1, 0},
      99                 :             : { 3, s_1_6, -5, 1, 0},
     100                 :             : { 6, s_1_7, -1, 1, 0},
     101                 :             : { 4, s_1_8, -7, 4, 0},
     102                 :             : { 2, s_1_9, 0, 1, 0},
     103                 :             : { 5, s_1_10, -1, 1, 0},
     104                 :             : { 2, s_1_11, 0, 1, 0},
     105                 :             : { 2, s_1_12, 0, 1, 0},
     106                 :             : { 5, s_1_13, -1, 1, 0},
     107                 :             : { 1, s_1_14, 0, 3, 0},
     108                 :             : { 2, s_1_15, -1, 1, 0},
     109                 :             : { 2, s_1_16, -2, 1, 0},
     110                 :             : { 4, s_1_17, -1, 1, 0},
     111                 :             : { 5, s_1_18, -2, 1, 0},
     112                 :             : { 4, s_1_19, -3, 1, 0},
     113                 :             : { 7, s_1_20, -1, 1, 0},
     114                 :             : { 3, s_1_21, -7, 1, 0},
     115                 :             : { 6, s_1_22, -1, 1, 0},
     116                 :             : { 3, s_1_23, -9, 2, 0},
     117                 :             : { 3, s_1_24, -10, 1, 0},
     118                 :             : { 2, s_1_25, 0, 1, 0},
     119                 :             : { 3, s_1_26, -1, 1, 0},
     120                 :             : { 3, s_1_27, 0, 4, 0},
     121                 :             : { 3, s_1_28, 0, 1, 0}
     122                 :             : };
     123                 :             : 
     124                 :             : static const symbol s_2_0[2] = { 'd', 't' };
     125                 :             : static const symbol s_2_1[2] = { 'v', 't' };
     126                 :             : static const struct among a_2[2] = {
     127                 :             : { 2, s_2_0, 0, -1, 0},
     128                 :             : { 2, s_2_1, 0, -1, 0}
     129                 :             : };
     130                 :             : 
     131                 :             : static const symbol s_3_0[3] = { 'l', 'e', 'g' };
     132                 :             : static const symbol s_3_1[4] = { 'e', 'l', 'e', 'g' };
     133                 :             : static const symbol s_3_2[2] = { 'i', 'g' };
     134                 :             : static const symbol s_3_3[3] = { 'e', 'i', 'g' };
     135                 :             : static const symbol s_3_4[3] = { 'l', 'i', 'g' };
     136                 :             : static const symbol s_3_5[4] = { 'e', 'l', 'i', 'g' };
     137                 :             : static const symbol s_3_6[3] = { 'e', 'l', 's' };
     138                 :             : static const symbol s_3_7[3] = { 'l', 'o', 'v' };
     139                 :             : static const symbol s_3_8[4] = { 'e', 'l', 'o', 'v' };
     140                 :             : static const symbol s_3_9[4] = { 's', 'l', 'o', 'v' };
     141                 :             : static const symbol s_3_10[7] = { 'h', 'e', 't', 's', 'l', 'o', 'v' };
     142                 :             : static const struct among a_3[11] = {
     143                 :             : { 3, s_3_0, 0, 1, 0},
     144                 :             : { 4, s_3_1, -1, 1, 0},
     145                 :             : { 2, s_3_2, 0, 1, 0},
     146                 :             : { 3, s_3_3, -1, 1, 0},
     147                 :             : { 3, s_3_4, -2, 1, 0},
     148                 :             : { 4, s_3_5, -1, 1, 0},
     149                 :             : { 3, s_3_6, 0, 1, 0},
     150                 :             : { 3, s_3_7, 0, 1, 0},
     151                 :             : { 4, s_3_8, -1, 1, 0},
     152                 :             : { 4, s_3_9, -2, 1, 0},
     153                 :             : { 7, s_3_10, -1, 1, 0}
     154                 :             : };
     155                 :             : 
     156                 :             : static const unsigned char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 2, 142 };
     157                 :             : 
     158                 :             : static const unsigned char g_s_ending[] = { 119, 125, 148, 1 };
     159                 :             : 
     160                 :           0 : static int r_mark_regions(struct SN_env * z) {
     161                 :           0 :     int i_x;
     162                 :           0 :     ((SN_local *)z)->i_p1 = z->l;
     163                 :             :     {
     164                 :           0 :         int v_1 = z->c;
     165                 :             :         {
     166                 :           0 :             int ret = skip_utf8(z->p, z->c, z->l, 3);
     167         [ #  # ]:           0 :             if (ret < 0) return 0;
     168                 :           0 :             z->c = ret;
     169         [ #  # ]:           0 :         }
     170                 :           0 :         i_x = z->c;
     171                 :           0 :         z->c = v_1;
     172         [ #  # ]:           0 :     }
     173                 :             :     {
     174                 :           0 :         int ret = out_grouping_U(z, g_v, 97, 248, 1);
     175         [ #  # ]:           0 :         if (ret < 0) return 0;
     176                 :           0 :         z->c += ret;
     177         [ #  # ]:           0 :     }
     178                 :             :     {
     179                 :           0 :         int ret = in_grouping_U(z, g_v, 97, 248, 1);
     180         [ #  # ]:           0 :         if (ret < 0) return 0;
     181                 :           0 :         z->c += ret;
     182         [ #  # ]:           0 :     }
     183                 :           0 :     ((SN_local *)z)->i_p1 = z->c;
     184         [ #  # ]:           0 :     if (((SN_local *)z)->i_p1 >= i_x) goto lab0;
     185                 :           0 :     ((SN_local *)z)->i_p1 = i_x;
     186                 :             : lab0:
     187                 :           0 :     return 1;
     188                 :           0 : }
     189                 :             : 
     190                 :           0 : static int r_main_suffix(struct SN_env * z) {
     191                 :           0 :     int among_var;
     192                 :             :     {
     193                 :           0 :         int v_1;
     194         [ #  # ]:           0 :         if (z->c < ((SN_local *)z)->i_p1) return 0;
     195                 :           0 :         v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
     196                 :           0 :         z->ket = z->c;
     197   [ #  #  #  #  :           0 :         if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1851426 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
                   #  # ]
     198                 :           0 :         among_var = find_among_b(z, a_1, 29, 0);
     199         [ #  # ]:           0 :         if (!among_var) { z->lb = v_1; return 0; }
     200                 :           0 :         z->bra = z->c;
     201                 :           0 :         z->lb = v_1;
     202         [ #  # ]:           0 :     }
     203   [ #  #  #  #  :           0 :     switch (among_var) {
                      # ]
     204                 :             :         case 1:
     205                 :             :             {
     206                 :           0 :                 int ret = slice_del(z);
     207         [ #  # ]:           0 :                 if (ret < 0) return ret;
     208         [ #  # ]:           0 :             }
     209                 :           0 :             break;
     210                 :             :         case 2:
     211   [ #  #  #  #  :           0 :             if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((5318672 >> (z->p[z->c - 1] & 0x1f)) & 1)) among_var = 1; else
                   #  # ]
     212                 :           0 :             among_var = find_among_b(z, a_0, 15, 0);
     213         [ #  # ]:           0 :             switch (among_var) {
     214                 :             :                 case 1:
     215                 :             :                     {
     216                 :           0 :                         int ret = slice_del(z);
     217         [ #  # ]:           0 :                         if (ret < 0) return ret;
     218         [ #  # ]:           0 :                     }
     219                 :           0 :                     break;
     220                 :             :             }
     221                 :           0 :             break;
     222                 :             :         case 3:
     223                 :           0 :             do {
     224                 :           0 :                 int v_2 = z->l - z->c;
     225         [ #  # ]:           0 :                 if (in_grouping_b_U(z, g_s_ending, 98, 122, 0)) goto lab0;
     226                 :           0 :                 break;
     227                 :             :             lab0:
     228                 :           0 :                 z->c = z->l - v_2;
     229   [ #  #  #  # ]:           0 :                 if (z->c <= z->lb || z->p[z->c - 1] != 'r') goto lab1;
     230                 :           0 :                 z->c--;
     231                 :             :                 {
     232                 :           0 :                     int v_3 = z->l - z->c;
     233   [ #  #  #  # ]:           0 :                     if (z->c <= z->lb || z->p[z->c - 1] != 'e') goto lab2;
     234                 :           0 :                     z->c--;
     235                 :           0 :                     goto lab1;
     236                 :             :                 lab2:
     237                 :           0 :                     z->c = z->l - v_3;
     238      [ #  #  # ]:           0 :                 }
     239                 :           0 :                 break;
     240                 :             :             lab1:
     241                 :           0 :                 z->c = z->l - v_2;
     242   [ #  #  #  # ]:           0 :                 if (z->c <= z->lb || z->p[z->c - 1] != 'k') return 0;
     243                 :           0 :                 z->c--;
     244         [ #  # ]:           0 :                 if (out_grouping_b_U(z, g_v, 97, 248, 0)) return 0;
     245      [ #  #  # ]:           0 :             } while (0);
     246                 :             :             {
     247                 :           0 :                 int ret = slice_del(z);
     248         [ #  # ]:           0 :                 if (ret < 0) return ret;
     249         [ #  # ]:           0 :             }
     250                 :           0 :             break;
     251                 :             :         case 4:
     252                 :             :             {
     253                 :           0 :                 int ret = slice_from_s(z, 2, s_0);
     254         [ #  # ]:           0 :                 if (ret < 0) return ret;
     255         [ #  # ]:           0 :             }
     256                 :           0 :             break;
     257                 :             :     }
     258                 :           0 :     return 1;
     259                 :           0 : }
     260                 :             : 
     261                 :           0 : static int r_consonant_pair(struct SN_env * z) {
     262                 :             :     {
     263                 :           0 :         int v_1 = z->l - z->c;
     264                 :             :         {
     265                 :           0 :             int v_2;
     266         [ #  # ]:           0 :             if (z->c < ((SN_local *)z)->i_p1) return 0;
     267                 :           0 :             v_2 = z->lb; z->lb = ((SN_local *)z)->i_p1;
     268                 :           0 :             z->ket = z->c;
     269   [ #  #  #  # ]:           0 :             if (z->c - 1 <= z->lb || z->p[z->c - 1] != 116) { z->lb = v_2; return 0; }
     270         [ #  # ]:           0 :             if (!find_among_b(z, a_2, 2, 0)) { z->lb = v_2; return 0; }
     271                 :           0 :             z->bra = z->c;
     272                 :           0 :             z->lb = v_2;
     273         [ #  # ]:           0 :         }
     274                 :           0 :         z->c = z->l - v_1;
     275         [ #  # ]:           0 :     }
     276                 :             :     {
     277                 :           0 :         int ret = skip_b_utf8(z->p, z->c, z->lb, 1);
     278         [ #  # ]:           0 :         if (ret < 0) return 0;
     279                 :           0 :         z->c = ret;
     280         [ #  # ]:           0 :     }
     281                 :           0 :     z->bra = z->c;
     282                 :             :     {
     283                 :           0 :         int ret = slice_del(z);
     284         [ #  # ]:           0 :         if (ret < 0) return ret;
     285         [ #  # ]:           0 :     }
     286                 :           0 :     return 1;
     287                 :           0 : }
     288                 :             : 
     289                 :           0 : static int r_other_suffix(struct SN_env * z) {
     290                 :             :     {
     291                 :           0 :         int v_1;
     292         [ #  # ]:           0 :         if (z->c < ((SN_local *)z)->i_p1) return 0;
     293                 :           0 :         v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
     294                 :           0 :         z->ket = z->c;
     295   [ #  #  #  #  :           0 :         if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((4718720 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
                   #  # ]
     296         [ #  # ]:           0 :         if (!find_among_b(z, a_3, 11, 0)) { z->lb = v_1; return 0; }
     297                 :           0 :         z->bra = z->c;
     298                 :           0 :         z->lb = v_1;
     299         [ #  # ]:           0 :     }
     300                 :             :     {
     301                 :           0 :         int ret = slice_del(z);
     302         [ #  # ]:           0 :         if (ret < 0) return ret;
     303         [ #  # ]:           0 :     }
     304                 :           0 :     return 1;
     305                 :           0 : }
     306                 :             : 
     307                 :           0 : extern int norwegian_UTF_8_stem(struct SN_env * z) {
     308                 :             :     {
     309                 :           0 :         int v_1 = z->c;
     310                 :             :         {
     311                 :           0 :             int ret = r_mark_regions(z);
     312         [ #  # ]:           0 :             if (ret < 0) return ret;
     313         [ #  # ]:           0 :         }
     314                 :           0 :         z->c = v_1;
     315         [ #  # ]:           0 :     }
     316                 :           0 :     z->lb = z->c; z->c = z->l;
     317                 :             :     {
     318                 :           0 :         int v_2 = z->l - z->c;
     319                 :             :         {
     320                 :           0 :             int ret = r_main_suffix(z);
     321         [ #  # ]:           0 :             if (ret < 0) return ret;
     322         [ #  # ]:           0 :         }
     323                 :           0 :         z->c = z->l - v_2;
     324         [ #  # ]:           0 :     }
     325                 :             :     {
     326                 :           0 :         int v_3 = z->l - z->c;
     327                 :             :         {
     328                 :           0 :             int ret = r_consonant_pair(z);
     329         [ #  # ]:           0 :             if (ret < 0) return ret;
     330         [ #  # ]:           0 :         }
     331                 :           0 :         z->c = z->l - v_3;
     332         [ #  # ]:           0 :     }
     333                 :             :     {
     334                 :           0 :         int v_4 = z->l - z->c;
     335                 :             :         {
     336                 :           0 :             int ret = r_other_suffix(z);
     337         [ #  # ]:           0 :             if (ret < 0) return ret;
     338         [ #  # ]:           0 :         }
     339                 :           0 :         z->c = z->l - v_4;
     340         [ #  # ]:           0 :     }
     341                 :           0 :     z->c = z->lb;
     342                 :           0 :     return 1;
     343                 :           0 : }
     344                 :             : 
     345                 :           0 : extern struct SN_env * norwegian_UTF_8_create_env(void) {
     346                 :           0 :     struct SN_env * z = SN_new_env(sizeof(SN_local));
     347         [ #  # ]:           0 :     if (z) {
     348                 :           0 :         ((SN_local *)z)->i_p1 = 0;
     349                 :           0 :     }
     350                 :           0 :     return z;
     351                 :           0 : }
     352                 :             : 
     353                 :           0 : extern void norwegian_UTF_8_close_env(struct SN_env * z) {
     354                 :           0 :     SN_delete_env(z);
     355                 :           0 : }
     356                 :             : 
        

Generated by: LCOV version 2.3.2-1