2 // From: https://snowballstem.org/algorithms/catalan/stemmer.html
3 // Author: Israel Olalla
4 // Licence: 3-clause BSD, as per https://snowballstem.org/license.html
23 /* special characters */
25 stringdef a' '{U+00E1}' // a-acute
26 stringdef a` '{U+00E0}' // a-grave
27 stringdef c, '{U+00E7}' // c-cedilla
28 stringdef e' '{U+00E9}' // e-acute
29 stringdef e` '{U+00E8}' // e-grave
30 stringdef i' '{U+00ED}' // i-acute
31 stringdef i` '{U+00EC}' // i-grave
32 stringdef i" '{U+00EF}' // i-diaeresis
33 stringdef o' '{U+00F3}' // o-acute
34 stringdef o` '{U+00F2}' // o-grave
35 stringdef u' '{U+00FA}' // u-acute
36 stringdef u" '{U+00FC}' // u-diaeresis
37 stringdef - '{U+002D}' // - per aggeminades
38 stringdef . '{U+00B7}' // - per l aggeminades
40 define v 'aeiou{a'}{a`}{e'}{e`}{i'}{i"}{o'}{o`}{u'}{u"}'
42 define mark_regions as (
45 $p2 = limit // defaults
48 gopast v gopast non-v setmark p1
49 gopast v gopast non-v setmark p2
53 define cleaning as repeat (
73 define R1 as $p1 <= cursor
74 define R2 as $p2 <= cursor
76 define attached_pronoun as (
78 '{'}s' '{'}hi' '{'}ho' '{'}l' '{'}ls'
79 '{-}ls' '{-}la' '{-}les' '{-}li'
80 'vos' 'se' 'nos' '{-}nos' '{-}us' 'us'
81 '{'}n' '{'}ns' '{-}n' '{-}ns'
85 'me' 'sela' 'selo' 'selas' 'selos' 'le'
86 'la' 'las' 'les' 'ens' 'ho' 'hi'
91 define standard_suffix as (
93 'ar' 'atge' 'formes' 'icte' 'ictes'
94 'ell' 'ells' 'ella' '{e'}s' '{e`}s' 'esc' 'essa' 'et' 'ets' 'eta'
95 'eres' 'eries' 'ers' 'ina' 'ines' 'able' 'ls'
96 'i{o'}' 'itat' 'itats' 'itzar' 'iva' 'ives' 'ivisme' 'ius'
97 'fer' 'ment' 'amen' 'ament' 'aments' 'ments' 'ot' 'sfera' 'al' 'als' 'era' 'ana' 'iste'
98 'aire' 'eria' 'esa' 'eses' 'esos' 'or' '{i'}cia' '{i'}cies' 'icis' 'ici' '{i'}ci' '{i'}cis'
99 '{a`}ria' '{a`}ries' 'alla' 'ci{o'}' 'cions' 'n{c,}a' 'nces' '{o'}' 'dor' 'all'
100 'il' '{i'}stic' 'enc' 'enca' '{i'}s' 'issa' 'issos' '{i'}ssem' '{i'}ssiu' 'issem' 'isseu' '{i'}sseu'
101 '{o'}s' 'osa' 'dora' 'dores' 'dors' 'adura' 'ble' 'bles' '{i'}vol' '{i'}vola' 'd{i'}s' 'egar' 'ejar' 'ificar'
102 'itar' 'ables' 'adors' 'idores' 'idors'
103 'adora' 'aci{o'}' 'doras' 'dur' 'dures' 'alleng{u"}es'
104 'ant' 'ants' 'ancia' 'ancies' 'at{o`}ria' 'at{o`}ries' 'tori' 'toris'
105 'ats' 'ions' 'ota' 'isam' 'ors' 'ora' 'ores' 'isament'
106 'bilitat' 'bilitats' 'ivitat' 'ivitats' 'ari' 'aris' 'ionisme' 'ionista' 'ionistes'
107 'ialista' 'ialistes' 'ialisme' 'ialismes' 'ud' 'uts' 'uds' 'encia' 'encies' '{e`}ncia' '{e`}ncies'
108 '{i"}tat' '{i"}tats' 'atiu' 'atius' 'atives' 'ativa' 'ativitat' 'ativitats' 'ible' 'ibles'
109 'assa' 'asses' 'assos'
111 '{i'}ssim' '{i'}ssima' '{i'}ssims' '{i'}ssimes' '{i`}ssem' '{i`}sseu' '{i`}ssin'
113 'isme' 'ista' 'ismes' 'istes'
114 'inia' 'inies' '{i'}inia' '{i'}nies' 'ita' 'ites' 'triu' 'trius'
115 'oses' 'osos' 'ient' 'otes' 'ots'
117 'acions' 'ada' 'ades'
119 'log{i'}a' 'log{i'}es''logia' 'logies' 'logi' 'logis' 'l{o'}gica' 'l{o'}gics' 'l{o'}giques'
121 'ic' 'ica' 'ics' 'iques'
123 'qu{i'}ssim' 'qu{i'}ssims' 'qu{i'}ssimes' 'qu{i'}ssima'
128 define verb_suffix as (
130 'ador' 'adora' 'adors' 'adores' 're' 'ie'
131 'ent' 'ents' 'udes' 'ar{a`}' 'eren'
132 'ar{a'}' 'ar{i'}an' 'ar{i'}as' 'ar{a'}n' 'ar{a'}s' 'ar{i'}ais'
133 'aria' 'arian' 'arien' 'aries' 'ar{a`}s'
134 'ar{i'}a' 'ar{e'}is' 'ar{i'}amos' 'aremos' 'ara'
136 'er{i'}an' 'er{i'}as' 'er{a'}n' 'er{a'}s' 'er{i'}ais'
137 'er{i'}a' 'er{e'}is' 'er{i'}amos' 'eremos' 'er{a'}'
138 'er{e'}' 'er' 'erau' 'erass'
139 'ir{i'}an' 'ir{i'}as' 'ir{a'}n' 'ir{a'}s' 'ir{i'}ais'
140 'ir{i'}a' 'ir{e'}is' 'ir{i'}amos' 'iremos' 'ir{a'}'
141 'ir{e'}' '{i'}rem' '{i'}reu' '{i'}eu'
142 'ia' 'ies' '{i'}em' '{i`}eu' 'ien'
143 'at' 'ut' 'uda' 'ava' 'aves' 'avem' '{a'}vem' '{a`}vem' '{a`}veu' '{a'}veu' 'aven' 'au' 'ats'
144 'asseu' 'esseu' 'eresseu' '{a`}sseu' '{a`}ssem' '{a`}ssim' '{a`}ssiu'
145 'essen' 'esses' 'assen' 'asses' 'assim' 'assiu'
146 '{e'}ssen' '{e'}sseu' '{e'}ssim' '{e'}ssiu' '{e'}ssem'
147 '{i'}' 'ares' '{a`}rem' '{a`}reu' '{a`}ren'
148 'ar{i'}em' 'ar{i'}eu'
149 'areu' 'aren' 'ant' '{i"}m' '{i"}u'
150 '{e'}s' '{i"}en' 'en' 'es' 'em' 'am' 'ams' '{i"}a' '{i"}es'
151 'dre' 'eix' 'eixer' 'tzar' 'eixes' 'ides' '{i"}des' 'it' '{i"}t' '{i"}da'
152 'aba' 'ada' 'ades' 'ida' '{i'}a' 'iera' 'ad' 'ed' 'its'
153 'id' 'ids' 'ase' 'iese' 'aste' 'iste' 'an' 'aban' '{i'}an'
154 'aran' 'ieran' 'asen' 'iesen' 'aron' 'ieron' 'ado'
155 'ido' 'iendo' 'i{o'}' 'ar' 'ir' 'as'
156 'ieu' 'ii' 'io' 'i{a`}'
157 'ess' 'essin' 'essis' 'ass' 'assin' 'assis' 'essim' '{e`}ssim' '{e`}ssiu'
158 'abas' 'adas' 'idas' '{i'}as' 'aras' 'ieras' 'ases'
159 'ieses' '{i'}s' '{a'}is' 'abais' '{i'}ais' 'arais'
160 'ierais' 'aseis' 'ieseis' 'asteis' 'isteis' 'ados'
161 'idos' 'amos' '{a'}bamos' '{i'}amos' 'imos' 'ques'
162 '{a'}ramos' 'i{e'}ramos' 'i{e'}semos' '{a'}semos'
163 'ira' 'iran' 'irem' 'iren' 'ires' 'ireu' 'iria' 'irien'
164 'iries' 'ir{a`}' 'ir{a`}s' 'ir{e`}' 'ir{i`}em' 'ir{i`}eu'
165 'isquen' 'iguem' 'igueu' 'esqui' 'esquin' 'esquis' 'eixi' 'eixin' 'eixis'
166 'eixen' 'eixo' 'isin' 'isis' 'esques' 'sis' 'sin'
167 'int' 'ir{i'}em' 'ir{i'}eu' 'isc' 'atges' 'esca' 'esquen'
168 'issen' 'isses' 'issin' 'issis' 'isca' 'issiu' 'issim'
169 '{i"}sc' '{i"}sca' '{i"}ssin' '{i'}ssiu' '{i'}ssim' '{i"}ssis' '{i"}guem' '{i"}gueu'
170 '{i"}ra' '{i"}ren' '{i"}res'
171 '{i"}squen' '{i"}sques' '{i"}ssen' '{i"}sses' '{i"}xo' '{i"}xen' '{i"}xes' '{i"}x'
172 'ixo' 'ixen' 'ixes' 'ix' 'ixa' 'inin' 'inis' 'ini' 'ineu' 'itza' 'itzi' 'itzeu' 'itzis'
173 'itzo' 'itz' 'itz{a`}' 'arem' 'in' '{a`}s' 'i{i"}' 'i{i"}n' 'i{i"}s'
180 define residual_suffix as (
182 'os' 'a' 'o' '{a'}' '{a`}' '{i'}' '{o'}' 'e' '{e'}' 'eu' 'iu'
183 'is' 'i' 'ir' 's' '{i`}' 'itz' '{i"}' '{i"}n' '{i"}s' 'it'
195 do ( standard_suffix or
203 First works 2010/07/19
204 First Gramatical Reviews: https://ca.wikipedia.org/wiki/Gram%C3%A0tica_catalana
205 Sufix list: http://wapedia.mobi/ca/Llista_de_sufixos
206 Irregular Verbs: https://ca.wikipedia.org/wiki/Flexi%C3%B3_verbal_del_catal%C3%A0