Debian Codegraph @

algorithms/romanian.sbl

raw
1 routines (
2 prelude postlude mark_regions
3 RV R1 R2
4 step_0
5 standard_suffix combo_suffix
6 verb_suffix
7 vowel_suffix
8 )
9
10 externals ( stem )
11
12 integers ( pV p1 p2 )
13
14 groupings ( v )
15
16 booleans ( standard_suffix_removed )
17
18 stringescapes {}
19
20 /* special characters */
21
22 stringdef a^ hex '0E2' // a circumflex
23 stringdef i^ hex '0EE' // i circumflex
24 stringdef a+ hex '103' // a breve
25 stringdef s, hex '15F' // s cedilla
26 stringdef t, hex '163' // t cedilla
27
28 define v 'aeiou{a^}{i^}{a+}'
29
30 define prelude as (
31 repeat goto (
32 v [ ('u' ] v <- 'U') or
33 ('i' ] v <- 'I')
34 )
35 )
36
37 define mark_regions as (
38
39 $pV = limit
40 $p1 = limit
41 $p2 = limit // defaults
42
43 do (
44 ( v (non-v gopast v) or (v gopast non-v) )
45 or
46 ( non-v (non-v gopast v) or (v next) )
47 setmark pV
48 )
49 do (
50 gopast v gopast non-v setmark p1
51 gopast v gopast non-v setmark p2
52 )
53 )
54
55 define postlude as repeat (
56
57 [substring] among(
58 'I' (<- 'i')
59 'U' (<- 'u')
60 '' (next)
61 )
62
63 )
64
65 backwardmode (
66
67 define RV as $pV <= cursor
68 define R1 as $p1 <= cursor
69 define R2 as $p2 <= cursor
70
71 define step_0 as (
72 [substring] R1 among(
73 'ul' 'ului'
74 ( delete )
75 'aua'
76 ( <-'a' )
77 'ea' 'ele' 'elor'
78 ( <-'e' )
79 'ii' 'iua' 'iei' 'iile' 'iilor' 'ilor'
80 ( <-'i')
81 'ile'
82 ( not 'ab' <- 'i' )
83 'atei'
84 ( <- 'at' )
85 'a{t,}ie' 'a{t,}ia'
86 ( <- 'a{t,}i' )
87 )
88 )
89
90 define combo_suffix as test (
91 [substring] R1 (
92 among(
93 /* 'IST'. alternative: include the following
94 'alism' 'alisme'
95 'alist' 'alista' 'aliste' 'alisti' 'alist{a+}' 'ali{s,}ti' (
96 <- 'al'
97 )
98 */
99 'abilitate' 'abilitati' 'abilit{a+}i' 'abilit{a+}{t,}i' (
100 <- 'abil'
101 )
102 'ibilitate' (
103 <- 'ibil'
104 )
105 'ivitate' 'ivitati' 'ivit{a+}i' 'ivit{a+}{t,}i' (
106 <- 'iv'
107 )
108 'icitate' 'icitati' 'icit{a+}i' 'icit{a+}{t,}i'
109 'icator' 'icatori'
110 'iciv' 'iciva' 'icive' 'icivi' 'iciv{a+}'
111 'ical' 'icala' 'icale' 'icali' 'ical{a+}' (
112 <- 'ic'
113 )
114 'ativ' 'ativa' 'ative' 'ativi' 'ativ{a+}' 'a{t,}iune'
115 'atoare' 'ator' 'atori'
116 '{a+}toare' '{a+}tor' '{a+}tori' (
117 <- 'at'
118 )
119 'itiv' 'itiva' 'itive' 'itivi' 'itiv{a+}' 'i{t,}iune'
120 'itoare' 'itor' 'itori' (
121 <- 'it'
122 )
123 )
124 set standard_suffix_removed
125 )
126 )
127
128 define standard_suffix as (
129 unset standard_suffix_removed
130 repeat combo_suffix
131 [substring] R2 (
132 among(
133
134 // past participle is treated here, rather than
135 // as a verb ending:
136 'at' 'ata' 'at{a+}' 'ati' 'ate'
137 'ut' 'uta' 'ut{a+}' 'uti' 'ute'
138 'it' 'ita' 'it{a+}' 'iti' 'ite'
139
140 'ic' 'ica' 'ice' 'ici' 'ic{a+}'
141 'abil' 'abila' 'abile' 'abili' 'abil{a+}'
142 'ibil' 'ibila' 'ibile' 'ibili' 'ibil{a+}'
143 'oasa' 'oas{a+}' 'oase' 'os' 'osi' 'o{s,}i'
144 'ant' 'anta' 'ante' 'anti' 'ant{a+}'
145 'ator' 'atori'
146 'itate' 'itati' 'it{a+}i' 'it{a+}{t,}i'
147 'iv' 'iva' 'ive' 'ivi' 'iv{a+}' (
148 delete
149 )
150 'iune' 'iuni' (
151 '{t,}'] <- 't'
152 )
153 'ism' 'isme'
154 'ist' 'ista' 'iste' 'isti' 'ist{a+}' 'i{s,}ti' (
155 <- 'ist'
156 /* 'IST'. alternative: remove with <- '' */
157 )
158 )
159 set standard_suffix_removed
160 )
161 )
162
163 define verb_suffix as setlimit tomark pV for (
164 [substring] among(
165 // 'long' infinitive:
166 'are' 'ere' 'ire' '{a^}re'
167
168 // gerund:
169 'ind' '{a^}nd'
170 'indu' '{a^}ndu'
171
172 'eze'
173 'easc{a+}'
174 // present:
175 'ez' 'ezi' 'eaz{a+}' 'esc' 'e{s,}ti'
176 'e{s,}te'
177 '{a+}sc' '{a+}{s,}ti'
178 '{a+}{s,}te'
179
180 // imperfect:
181 'am' 'ai' 'au'
182 'eam' 'eai' 'ea' 'ea{t,}i' 'eau'
183 'iam' 'iai' 'ia' 'ia{t,}i' 'iau'
184
185 // past: // (not 'ii')
186 'ui'
187 'a{s,}i' 'ar{a+}m' 'ar{a+}{t,}i' 'ar{a+}'
188 'u{s,}i' 'ur{a+}m' 'ur{a+}{t,}i' 'ur{a+}'
189 'i{s,}i' 'ir{a+}m' 'ir{a+}{t,}i' 'ir{a+}'
190 '{a^}i' '{a^}{s,}i' '{a^}r{a+}m' '{a^}r{a+}{t,}i' '{a^}r{a+}'
191
192 // pluferfect:
193 'asem' 'ase{s,}i' 'ase' 'aser{a+}m' 'aser{a+}{t,}i' 'aser{a+}'
194 'isem' 'ise{s,}i' 'ise' 'iser{a+}m' 'iser{a+}{t,}i' 'iser{a+}'
195 '{a^}sem' '{a^}se{s,}i' '{a^}se' '{a^}ser{a+}m' '{a^}ser{a+}{t,}i'
196 '{a^}ser{a+}'
197 'usem' 'use{s,}i' 'use' 'user{a+}m' 'user{a+}{t,}i' 'user{a+}'
198
199 ( non-v or 'u' delete )
200
201 // present:
202 '{a+}m' 'a{t,}i'
203 'em' 'e{t,}i'
204 'im' 'i{t,}i'
205 '{a^}m' '{a^}{t,}i'
206
207 // past:
208 'se{s,}i' 'ser{a+}m' 'ser{a+}{t,}i' 'ser{a+}'
209 'sei' 'se'
210
211 // pluperfect:
212 'sesem' 'sese{s,}i' 'sese' 'seser{a+}m' 'seser{a+}{t,}i' 'seser{a+}'
213 (delete)
214 )
215 )
216
217 define vowel_suffix as (
218 [substring] RV among (
219 'a' 'e' 'i' 'ie' '{a+}' ( delete )
220 )
221 )
222 )
223
224 define stem as (
225 do prelude
226 do mark_regions
227 backwards (
228 do step_0
229 do standard_suffix
230 do ( standard_suffix_removed or verb_suffix )
231 do vowel_suffix
232 )
233 do postlude
234 )