You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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