Document xapian-compact --blocksize takes an argument
[xapian.git] / xapian-core / languages / finnish.sbl
blobe98469411ecf286f0f5cd0bd24bc2f9ad659d475
1 // Alias: fi
3 /* Finnish stemmer.
5    Numbers in square brackets refer to the sections in
6    Fred Karlsson, Finnish: An Essential Grammar. Routledge, 1999
7    ISBN 0-415-20705-3
9 */
11 routines (
12            mark_regions
13            R2
14            particle_etc possessive
15            LONG VI
16            case_ending
17            i_plural
18            t_plural
19            other_endings
20            tidy
23 externals ( stem )
25 integers ( p1 p2 )
26 strings ( x )
27 booleans ( ending_removed )
28 groupings ( AEI V1 V2 particle_end )
30 stringescapes {}
32 /* special characters (in ISO Latin I) */
34 stringdef a"   hex 'E4'
35 stringdef o"   hex 'F6'
37 define AEI 'a{a"}ei'
38 define V1 'aeiouy{a"}{o"}'
39 define V2 'aeiou{a"}{o"}'
40 define particle_end V1 + 'nt'
42 define mark_regions as (
44     $p1 = limit
45     $p2 = limit
47     goto V1  gopast non-V1  setmark p1
48     goto V1  gopast non-V1  setmark p2
51 backwardmode (
53     define R2 as $p2 <= cursor
55     define particle_etc as (
56         setlimit tomark p1 for ([substring])
57         among(
58             'kin'
59             'kaan' 'k{a"}{a"}n'
60             'ko'   'k{o"}'
61             'han'  'h{a"}n'
62             'pa'   'p{a"}'    // Particles [91]
63                 (particle_end)
64             'sti'             // Adverb [87]
65                 (R2)
66         )
67         delete
68     )
69     define possessive as (    // [36]
70         setlimit tomark p1 for ([substring])
71         among(
72             'si'
73                 (not 'k' delete)  // take 'ksi' as the Comitative case
74             'ni'
75                 (delete ['kse'] <- 'ksi') // kseni = ksi + ni
76             'nsa' 'ns{a"}'
77             'mme'
78             'nne'
79                 (delete)
80             /* Now for Vn possessives after case endings: [36] */
81             'an'
82                 (among('ta' 'ssa' 'sta' 'lla' 'lta' 'na') delete)
83             '{a"}n'
84                 (among('t{a"}' 'ss{a"}' 'st{a"}'
85                        'll{a"}' 'lt{a"}' 'n{a"}') delete)
86             'en'
87                 (among('lle' 'ine') delete)
88         )
89     )
91     define LONG as
92         among('aa' 'ee' 'ii' 'oo' 'uu' '{a"}{a"}' '{o"}{o"}')
94     define VI as ('i' V2)
96     define case_ending as (
97         setlimit tomark p1 for ([substring])
98         among(
99             'han'    ('a')          //-.
100             'hen'    ('e')          // |
101             'hin'    ('i')          // |
102             'hon'    ('o')          // |
103             'h{a"}n' ('{a"}')       // Illative   [43]
104             'h{o"}n' ('{o"}')       // |
105             'siin'   VI             // |
106             'seen'   LONG           //-'
108             'den'    VI
109             'tten'   VI             // Genitive plurals [34]
110                      ()
111             'n'                     // Genitive or Illative
112                 ( try ( LONG // Illative
113                         or 'ie' // Genitive
114                           and next ]
115                       )
116                   /* otherwise Genitive */
117                 )
119             'a' '{a"}'              //-.
120                      (V1 non-V1)    // |
121             'tta' 'tt{a"}'          // Partitive  [32]
122                      ('e')          // |
123             'ta' 't{a"}'            //-'
125             'ssa' 'ss{a"}'          // Inessive   [41]
126             'sta' 'st{a"}'          // Elative    [42]
128             'lla' 'll{a"}'          // Adessive   [44]
129             'lta' 'lt{a"}'          // Ablative   [51]
130             'lle'                   // Allative   [46]
131             'na' 'n{a"}'            // Essive     [49]
132             'ksi'                   // Translative[50]
133             'ine'                   // Comitative [51]
135             /* Abessive and Instructive are too rare for
136                inclusion [51] */
138         )
139         delete
140         set ending_removed
141     )
142     define other_endings as (
143         setlimit tomark p2 for ([substring])
144         among(
145             'mpi' 'mpa' 'mp{a"}'
146             'mmi' 'mma' 'mm{a"}'    // Comparative forms [85]
147                 (not 'po')          //-improves things
148             'impi' 'impa' 'imp{a"}'
149             'immi' 'imma' 'imm{a"}' // Superlative forms [86]
150             'eja' 'ej{a"}'          // indicates agent [93.1B]
151         )
152         delete
153     )
154     define i_plural as (            // [26]
155         setlimit tomark p1 for ([substring])
156         among(
157             'i'  'j'
158         )
159         delete
160     )
161     define t_plural as (            // [26]
162         setlimit tomark p1 for (
163             ['t'] test V1
164             delete
165         )
166         setlimit tomark p2 for ([substring])
167         among(
168             'mma' (not 'po') //-mmat endings
169             'imma'           //-immat endings
170         )
171         delete
172     )
173     define tidy as (
174         setlimit tomark p1 for (
175             do ( LONG and ([next] delete ) ) // undouble vowel
176             do ( [AEI] non-V1 delete ) // remove trailing a, a", e, i
177             do ( ['j'] 'o' or 'u' delete )
178             do ( ['o'] 'j' delete )
179         )
180         goto non-V1 [next] -> x  x delete // undouble consonant
181     )
184 define stem as (
186     do mark_regions
187     unset ending_removed
188     backwards (
189         do particle_etc
190         do possessive
191         do case_ending
192         do other_endings
193         (ending_removed do i_plural) or do t_plural
194         do tidy
195     )