LCOV - code coverage report
Current view: top level - src/backend/snowball/libstemmer - stem_UTF_8_swedish.c (source / functions) Hit Total Coverage
Test: PostgreSQL 19devel Lines: 0 137 0.0 %
Date: 2026-02-02 16:19:03 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Generated from swedish.sbl by Snowball 3.0.0 - https://snowballstem.org/ */
       2             : 
       3             : #include "stem_UTF_8_swedish.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 swedish_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             : static int r_et_condition(struct SN_env * z);
      29             : 
      30             : static const symbol s_0[] = { 'e', 't' };
      31             : static const symbol s_1[] = { 0xC3, 0xB6, 's' };
      32             : static const symbol s_2[] = { 'f', 'u', 'l', 'l' };
      33             : 
      34             : static const symbol s_0_0[3] = { 'f', 'a', 'b' };
      35             : static const symbol s_0_1[1] = { 'h' };
      36             : static const symbol s_0_2[3] = { 'p', 'a', 'k' };
      37             : static const symbol s_0_3[3] = { 'r', 'a', 'k' };
      38             : static const symbol s_0_4[4] = { 's', 't', 'a', 'k' };
      39             : static const symbol s_0_5[3] = { 'k', 'o', 'm' };
      40             : static const symbol s_0_6[3] = { 'i', 'e', 't' };
      41             : static const symbol s_0_7[3] = { 'c', 'i', 't' };
      42             : static const symbol s_0_8[3] = { 'd', 'i', 't' };
      43             : static const symbol s_0_9[4] = { 'a', 'l', 'i', 't' };
      44             : static const symbol s_0_10[4] = { 'i', 'l', 'i', 't' };
      45             : static const symbol s_0_11[3] = { 'm', 'i', 't' };
      46             : static const symbol s_0_12[3] = { 'n', 'i', 't' };
      47             : static const symbol s_0_13[3] = { 'p', 'i', 't' };
      48             : static const symbol s_0_14[3] = { 'r', 'i', 't' };
      49             : static const symbol s_0_15[3] = { 's', 'i', 't' };
      50             : static const symbol s_0_16[3] = { 't', 'i', 't' };
      51             : static const symbol s_0_17[3] = { 'u', 'i', 't' };
      52             : static const symbol s_0_18[4] = { 'i', 'v', 'i', 't' };
      53             : static const symbol s_0_19[4] = { 'k', 'v', 'i', 't' };
      54             : static const symbol s_0_20[3] = { 'x', 'i', 't' };
      55             : static const struct among a_0[21] = {
      56             : { 3, s_0_0, 0, -1, 0},
      57             : { 1, s_0_1, 0, -1, 0},
      58             : { 3, s_0_2, 0, -1, 0},
      59             : { 3, s_0_3, 0, -1, 0},
      60             : { 4, s_0_4, 0, -1, 0},
      61             : { 3, s_0_5, 0, -1, 0},
      62             : { 3, s_0_6, 0, -1, 0},
      63             : { 3, s_0_7, 0, -1, 0},
      64             : { 3, s_0_8, 0, -1, 0},
      65             : { 4, s_0_9, 0, -1, 0},
      66             : { 4, s_0_10, 0, -1, 0},
      67             : { 3, s_0_11, 0, -1, 0},
      68             : { 3, s_0_12, 0, -1, 0},
      69             : { 3, s_0_13, 0, -1, 0},
      70             : { 3, s_0_14, 0, -1, 0},
      71             : { 3, s_0_15, 0, -1, 0},
      72             : { 3, s_0_16, 0, -1, 0},
      73             : { 3, s_0_17, 0, -1, 0},
      74             : { 4, s_0_18, 0, -1, 0},
      75             : { 4, s_0_19, 0, -1, 0},
      76             : { 3, s_0_20, 0, -1, 0}
      77             : };
      78             : 
      79             : static const symbol s_1_0[1] = { 'a' };
      80             : static const symbol s_1_1[4] = { 'a', 'r', 'n', 'a' };
      81             : static const symbol s_1_2[4] = { 'e', 'r', 'n', 'a' };
      82             : static const symbol s_1_3[7] = { 'h', 'e', 't', 'e', 'r', 'n', 'a' };
      83             : static const symbol s_1_4[4] = { 'o', 'r', 'n', 'a' };
      84             : static const symbol s_1_5[2] = { 'a', 'd' };
      85             : static const symbol s_1_6[1] = { 'e' };
      86             : static const symbol s_1_7[3] = { 'a', 'd', 'e' };
      87             : static const symbol s_1_8[4] = { 'a', 'n', 'd', 'e' };
      88             : static const symbol s_1_9[4] = { 'a', 'r', 'n', 'e' };
      89             : static const symbol s_1_10[3] = { 'a', 'r', 'e' };
      90             : static const symbol s_1_11[4] = { 'a', 's', 't', 'e' };
      91             : static const symbol s_1_12[2] = { 'e', 'n' };
      92             : static const symbol s_1_13[5] = { 'a', 'n', 'd', 'e', 'n' };
      93             : static const symbol s_1_14[4] = { 'a', 'r', 'e', 'n' };
      94             : static const symbol s_1_15[5] = { 'h', 'e', 't', 'e', 'n' };
      95             : static const symbol s_1_16[3] = { 'e', 'r', 'n' };
      96             : static const symbol s_1_17[2] = { 'a', 'r' };
      97             : static const symbol s_1_18[2] = { 'e', 'r' };
      98             : static const symbol s_1_19[5] = { 'h', 'e', 't', 'e', 'r' };
      99             : static const symbol s_1_20[2] = { 'o', 'r' };
     100             : static const symbol s_1_21[1] = { 's' };
     101             : static const symbol s_1_22[2] = { 'a', 's' };
     102             : static const symbol s_1_23[5] = { 'a', 'r', 'n', 'a', 's' };
     103             : static const symbol s_1_24[5] = { 'e', 'r', 'n', 'a', 's' };
     104             : static const symbol s_1_25[5] = { 'o', 'r', 'n', 'a', 's' };
     105             : static const symbol s_1_26[2] = { 'e', 's' };
     106             : static const symbol s_1_27[4] = { 'a', 'd', 'e', 's' };
     107             : static const symbol s_1_28[5] = { 'a', 'n', 'd', 'e', 's' };
     108             : static const symbol s_1_29[3] = { 'e', 'n', 's' };
     109             : static const symbol s_1_30[5] = { 'a', 'r', 'e', 'n', 's' };
     110             : static const symbol s_1_31[6] = { 'h', 'e', 't', 'e', 'n', 's' };
     111             : static const symbol s_1_32[4] = { 'e', 'r', 'n', 's' };
     112             : static const symbol s_1_33[2] = { 'a', 't' };
     113             : static const symbol s_1_34[2] = { 'e', 't' };
     114             : static const symbol s_1_35[5] = { 'a', 'n', 'd', 'e', 't' };
     115             : static const symbol s_1_36[3] = { 'h', 'e', 't' };
     116             : static const symbol s_1_37[3] = { 'a', 's', 't' };
     117             : static const struct among a_1[38] = {
     118             : { 1, s_1_0, 0, 1, 0},
     119             : { 4, s_1_1, -1, 1, 0},
     120             : { 4, s_1_2, -2, 1, 0},
     121             : { 7, s_1_3, -1, 1, 0},
     122             : { 4, s_1_4, -4, 1, 0},
     123             : { 2, s_1_5, 0, 1, 0},
     124             : { 1, s_1_6, 0, 1, 0},
     125             : { 3, s_1_7, -1, 1, 0},
     126             : { 4, s_1_8, -2, 1, 0},
     127             : { 4, s_1_9, -3, 1, 0},
     128             : { 3, s_1_10, -4, 1, 0},
     129             : { 4, s_1_11, -5, 1, 0},
     130             : { 2, s_1_12, 0, 1, 0},
     131             : { 5, s_1_13, -1, 1, 0},
     132             : { 4, s_1_14, -2, 1, 0},
     133             : { 5, s_1_15, -3, 1, 0},
     134             : { 3, s_1_16, 0, 1, 0},
     135             : { 2, s_1_17, 0, 1, 0},
     136             : { 2, s_1_18, 0, 1, 0},
     137             : { 5, s_1_19, -1, 1, 0},
     138             : { 2, s_1_20, 0, 1, 0},
     139             : { 1, s_1_21, 0, 2, 0},
     140             : { 2, s_1_22, -1, 1, 0},
     141             : { 5, s_1_23, -1, 1, 0},
     142             : { 5, s_1_24, -2, 1, 0},
     143             : { 5, s_1_25, -3, 1, 0},
     144             : { 2, s_1_26, -5, 1, 0},
     145             : { 4, s_1_27, -1, 1, 0},
     146             : { 5, s_1_28, -2, 1, 0},
     147             : { 3, s_1_29, -8, 1, 0},
     148             : { 5, s_1_30, -1, 1, 0},
     149             : { 6, s_1_31, -2, 1, 0},
     150             : { 4, s_1_32, -11, 1, 0},
     151             : { 2, s_1_33, 0, 1, 0},
     152             : { 2, s_1_34, 0, 3, 0},
     153             : { 5, s_1_35, -1, 1, 0},
     154             : { 3, s_1_36, -2, 1, 0},
     155             : { 3, s_1_37, 0, 1, 0}
     156             : };
     157             : 
     158             : static const symbol s_2_0[2] = { 'd', 'd' };
     159             : static const symbol s_2_1[2] = { 'g', 'd' };
     160             : static const symbol s_2_2[2] = { 'n', 'n' };
     161             : static const symbol s_2_3[2] = { 'd', 't' };
     162             : static const symbol s_2_4[2] = { 'g', 't' };
     163             : static const symbol s_2_5[2] = { 'k', 't' };
     164             : static const symbol s_2_6[2] = { 't', 't' };
     165             : static const struct among a_2[7] = {
     166             : { 2, s_2_0, 0, -1, 0},
     167             : { 2, s_2_1, 0, -1, 0},
     168             : { 2, s_2_2, 0, -1, 0},
     169             : { 2, s_2_3, 0, -1, 0},
     170             : { 2, s_2_4, 0, -1, 0},
     171             : { 2, s_2_5, 0, -1, 0},
     172             : { 2, s_2_6, 0, -1, 0}
     173             : };
     174             : 
     175             : static const symbol s_3_0[2] = { 'i', 'g' };
     176             : static const symbol s_3_1[3] = { 'l', 'i', 'g' };
     177             : static const symbol s_3_2[3] = { 'e', 'l', 's' };
     178             : static const symbol s_3_3[5] = { 'f', 'u', 'l', 'l', 't' };
     179             : static const symbol s_3_4[4] = { 0xC3, 0xB6, 's', 't' };
     180             : static const struct among a_3[5] = {
     181             : { 2, s_3_0, 0, 1, 0},
     182             : { 3, s_3_1, -1, 1, 0},
     183             : { 3, s_3_2, 0, 1, 0},
     184             : { 5, s_3_3, 0, 3, 0},
     185             : { 4, s_3_4, 0, 2, 0}
     186             : };
     187             : 
     188             : static const unsigned char g_v[] = { 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 32 };
     189             : 
     190             : static const unsigned char g_s_ending[] = { 119, 127, 149 };
     191             : 
     192             : static const unsigned char g_ost_ending[] = { 173, 58 };
     193             : 
     194           0 : static int r_mark_regions(struct SN_env * z) {
     195             :     int i_x;
     196           0 :     ((SN_local *)z)->i_p1 = z->l;
     197             :     {
     198           0 :         int v_1 = z->c;
     199             :         {
     200           0 :             int ret = skip_utf8(z->p, z->c, z->l, 3);
     201           0 :             if (ret < 0) return 0;
     202           0 :             z->c = ret;
     203             :         }
     204           0 :         i_x = z->c;
     205           0 :         z->c = v_1;
     206             :     }
     207             :     {
     208           0 :         int ret = out_grouping_U(z, g_v, 97, 246, 1);
     209           0 :         if (ret < 0) return 0;
     210           0 :         z->c += ret;
     211             :     }
     212             :     {
     213           0 :         int ret = in_grouping_U(z, g_v, 97, 246, 1);
     214           0 :         if (ret < 0) return 0;
     215           0 :         z->c += ret;
     216             :     }
     217           0 :     ((SN_local *)z)->i_p1 = z->c;
     218           0 :     if (((SN_local *)z)->i_p1 >= i_x) goto lab0;
     219           0 :     ((SN_local *)z)->i_p1 = i_x;
     220           0 : lab0:
     221           0 :     return 1;
     222             : }
     223             : 
     224           0 : static int r_et_condition(struct SN_env * z) {
     225             :     {
     226           0 :         int v_1 = z->l - z->c;
     227           0 :         if (out_grouping_b_U(z, g_v, 97, 246, 0)) return 0;
     228           0 :         if (in_grouping_b_U(z, g_v, 97, 246, 0)) return 0;
     229           0 :         if (z->c > z->lb) goto lab0;
     230           0 :         return 0;
     231           0 :     lab0:
     232           0 :         z->c = z->l - v_1;
     233             :         {
     234           0 :             int v_2 = z->l - z->c;
     235           0 :             if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1059076 >> (z->p[z->c - 1] & 0x1f)) & 1)) goto lab1;
     236           0 :             if (!find_among_b(z, a_0, 21, 0)) goto lab1;
     237           0 :             return 0;
     238           0 :         lab1:
     239           0 :             z->c = z->l - v_2;
     240             :         }
     241             :     }
     242           0 :     return 1;
     243             : }
     244             : 
     245           0 : static int r_main_suffix(struct SN_env * z) {
     246             :     int among_var;
     247             :     {
     248             :         int v_1;
     249           0 :         if (z->c < ((SN_local *)z)->i_p1) return 0;
     250           0 :         v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
     251           0 :         z->ket = z->c;
     252           0 :         if (z->c <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1851442 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
     253           0 :         among_var = find_among_b(z, a_1, 38, 0);
     254           0 :         if (!among_var) { z->lb = v_1; return 0; }
     255           0 :         z->bra = z->c;
     256           0 :         z->lb = v_1;
     257             :     }
     258           0 :     switch (among_var) {
     259           0 :         case 1:
     260             :             {
     261           0 :                 int ret = slice_del(z);
     262           0 :                 if (ret < 0) return ret;
     263             :             }
     264           0 :             break;
     265           0 :         case 2:
     266             :             do {
     267           0 :                 int v_2 = z->l - z->c;
     268           0 :                 if (!(eq_s_b(z, 2, s_0))) goto lab0;
     269             :                 {
     270           0 :                     int ret = r_et_condition(z);
     271           0 :                     if (ret == 0) goto lab0;
     272           0 :                     if (ret < 0) return ret;
     273             :                 }
     274           0 :                 z->bra = z->c;
     275           0 :                 break;
     276           0 :             lab0:
     277           0 :                 z->c = z->l - v_2;
     278           0 :                 if (in_grouping_b_U(z, g_s_ending, 98, 121, 0)) return 0;
     279             :             } while (0);
     280             :             {
     281           0 :                 int ret = slice_del(z);
     282           0 :                 if (ret < 0) return ret;
     283             :             }
     284           0 :             break;
     285           0 :         case 3:
     286             :             {
     287           0 :                 int ret = r_et_condition(z);
     288           0 :                 if (ret <= 0) return ret;
     289             :             }
     290             :             {
     291           0 :                 int ret = slice_del(z);
     292           0 :                 if (ret < 0) return ret;
     293             :             }
     294           0 :             break;
     295             :     }
     296           0 :     return 1;
     297             : }
     298             : 
     299           0 : static int r_consonant_pair(struct SN_env * z) {
     300             :     {
     301             :         int v_1;
     302           0 :         if (z->c < ((SN_local *)z)->i_p1) return 0;
     303           0 :         v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
     304             :         {
     305           0 :             int v_2 = z->l - z->c;
     306           0 :             if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1064976 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
     307           0 :             if (!find_among_b(z, a_2, 7, 0)) { z->lb = v_1; return 0; }
     308           0 :             z->c = z->l - v_2;
     309           0 :             z->ket = z->c;
     310             :             {
     311           0 :                 int ret = skip_b_utf8(z->p, z->c, z->lb, 1);
     312           0 :                 if (ret < 0) { z->lb = v_1; return 0; }
     313           0 :                 z->c = ret;
     314             :             }
     315           0 :             z->bra = z->c;
     316             :             {
     317           0 :                 int ret = slice_del(z);
     318           0 :                 if (ret < 0) return ret;
     319             :             }
     320             :         }
     321           0 :         z->lb = v_1;
     322             :     }
     323           0 :     return 1;
     324             : }
     325             : 
     326           0 : static int r_other_suffix(struct SN_env * z) {
     327             :     int among_var;
     328             :     {
     329             :         int v_1;
     330           0 :         if (z->c < ((SN_local *)z)->i_p1) return 0;
     331           0 :         v_1 = z->lb; z->lb = ((SN_local *)z)->i_p1;
     332           0 :         z->ket = z->c;
     333           0 :         if (z->c - 1 <= z->lb || z->p[z->c - 1] >> 5 != 3 || !((1572992 >> (z->p[z->c - 1] & 0x1f)) & 1)) { z->lb = v_1; return 0; }
     334           0 :         among_var = find_among_b(z, a_3, 5, 0);
     335           0 :         if (!among_var) { z->lb = v_1; return 0; }
     336           0 :         z->bra = z->c;
     337           0 :         z->lb = v_1;
     338             :     }
     339           0 :     switch (among_var) {
     340           0 :         case 1:
     341             :             {
     342           0 :                 int ret = slice_del(z);
     343           0 :                 if (ret < 0) return ret;
     344             :             }
     345           0 :             break;
     346           0 :         case 2:
     347           0 :             if (in_grouping_b_U(z, g_ost_ending, 105, 118, 0)) return 0;
     348             :             {
     349           0 :                 int ret = slice_from_s(z, 3, s_1);
     350           0 :                 if (ret < 0) return ret;
     351             :             }
     352           0 :             break;
     353           0 :         case 3:
     354             :             {
     355           0 :                 int ret = slice_from_s(z, 4, s_2);
     356           0 :                 if (ret < 0) return ret;
     357             :             }
     358           0 :             break;
     359             :     }
     360           0 :     return 1;
     361             : }
     362             : 
     363           0 : extern int swedish_UTF_8_stem(struct SN_env * z) {
     364             :     {
     365           0 :         int v_1 = z->c;
     366             :         {
     367           0 :             int ret = r_mark_regions(z);
     368           0 :             if (ret < 0) return ret;
     369             :         }
     370           0 :         z->c = v_1;
     371             :     }
     372           0 :     z->lb = z->c; z->c = z->l;
     373             :     {
     374           0 :         int v_2 = z->l - z->c;
     375             :         {
     376           0 :             int ret = r_main_suffix(z);
     377           0 :             if (ret < 0) return ret;
     378             :         }
     379           0 :         z->c = z->l - v_2;
     380             :     }
     381             :     {
     382           0 :         int v_3 = z->l - z->c;
     383             :         {
     384           0 :             int ret = r_consonant_pair(z);
     385           0 :             if (ret < 0) return ret;
     386             :         }
     387           0 :         z->c = z->l - v_3;
     388             :     }
     389             :     {
     390           0 :         int v_4 = z->l - z->c;
     391             :         {
     392           0 :             int ret = r_other_suffix(z);
     393           0 :             if (ret < 0) return ret;
     394             :         }
     395           0 :         z->c = z->l - v_4;
     396             :     }
     397           0 :     z->c = z->lb;
     398           0 :     return 1;
     399             : }
     400             : 
     401           0 : extern struct SN_env * swedish_UTF_8_create_env(void) {
     402           0 :     struct SN_env * z = SN_new_env(sizeof(SN_local));
     403           0 :     if (z) {
     404           0 :         ((SN_local *)z)->i_p1 = 0;
     405             :     }
     406           0 :     return z;
     407             : }
     408             : 
     409           0 : extern void swedish_UTF_8_close_env(struct SN_env * z) {
     410           0 :     SN_delete_env(z);
     411           0 : }
     412             : 

Generated by: LCOV version 1.16