mittens 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +1 -0
  4. data/README.md +2 -2
  5. data/Rakefile +10 -3
  6. data/lib/mittens/version.rb +1 -1
  7. data/vendor/snowball/.github/workflows/ci.yml +144 -17
  8. data/vendor/snowball/.github/workflows/coverage.yml +117 -0
  9. data/vendor/snowball/.github/workflows/runtime-tests.yml +26 -0
  10. data/vendor/snowball/.gitignore +33 -7
  11. data/vendor/snowball/CONTRIBUTING.rst +7 -0
  12. data/vendor/snowball/COPYING +1 -1
  13. data/vendor/snowball/GNUmakefile +736 -298
  14. data/vendor/snowball/NEWS +1394 -7
  15. data/vendor/snowball/README.rst +8 -8
  16. data/vendor/snowball/ada/generate/generate.adb +5 -5
  17. data/vendor/snowball/ada/src/stemmer.adb +177 -188
  18. data/vendor/snowball/ada/src/stemmer.ads +86 -89
  19. data/vendor/snowball/ada/src/stemwords.adb +21 -5
  20. data/vendor/snowball/algorithms/czech.sbl +255 -0
  21. data/vendor/snowball/algorithms/danish.sbl +22 -10
  22. data/vendor/snowball/algorithms/english.sbl +7 -4
  23. data/vendor/snowball/algorithms/esperanto.sbl +6 -7
  24. data/vendor/snowball/algorithms/estonian.sbl +9 -4
  25. data/vendor/snowball/algorithms/finnish.sbl +33 -21
  26. data/vendor/snowball/algorithms/german.sbl +5 -0
  27. data/vendor/snowball/algorithms/indonesian.sbl +115 -96
  28. data/vendor/snowball/algorithms/italian.sbl +26 -1
  29. data/vendor/snowball/algorithms/lithuanian.sbl +13 -13
  30. data/vendor/snowball/algorithms/norwegian.sbl +17 -6
  31. data/vendor/snowball/algorithms/persian.sbl +387 -0
  32. data/vendor/snowball/algorithms/polish.sbl +177 -0
  33. data/vendor/snowball/algorithms/sesotho.sbl +115 -0
  34. data/vendor/snowball/algorithms/turkish.sbl +4 -4
  35. data/vendor/snowball/compiler/analyser.c +2002 -711
  36. data/vendor/snowball/compiler/driver.c +460 -298
  37. data/vendor/snowball/compiler/generator.c +439 -1965
  38. data/vendor/snowball/compiler/generator_ada.c +605 -430
  39. data/vendor/snowball/compiler/generator_c.c +2227 -0
  40. data/vendor/snowball/compiler/generator_csharp.c +365 -274
  41. data/vendor/snowball/compiler/generator_dart.c +1476 -0
  42. data/vendor/snowball/compiler/generator_go.c +348 -270
  43. data/vendor/snowball/compiler/generator_java.c +330 -233
  44. data/vendor/snowball/compiler/generator_js.c +534 -385
  45. data/vendor/snowball/compiler/generator_pascal.c +361 -320
  46. data/vendor/snowball/compiler/generator_php.c +1445 -0
  47. data/vendor/snowball/compiler/generator_python.c +399 -299
  48. data/vendor/snowball/compiler/generator_rust.c +370 -261
  49. data/vendor/snowball/compiler/generator_zig.c +1474 -0
  50. data/vendor/snowball/compiler/header.h +153 -86
  51. data/vendor/snowball/compiler/space.c +121 -63
  52. data/vendor/snowball/compiler/tokeniser.c +286 -182
  53. data/vendor/snowball/compiler/tokens.h +71 -0
  54. data/vendor/snowball/csharp/Snowball/Among.cs +14 -26
  55. data/vendor/snowball/csharp/Snowball/AssemblyInfo.cs +3 -3
  56. data/vendor/snowball/csharp/Snowball/Stemmer.cs +41 -45
  57. data/vendor/snowball/csharp/Stemwords/Program.cs +20 -14
  58. data/vendor/snowball/cxx/.gitignore +4 -0
  59. data/vendor/snowball/cxx/generate_algorithms.pl +87 -0
  60. data/vendor/snowball/cxx/stemmer.h +12 -0
  61. data/vendor/snowball/cxx/stemwords.cxx +176 -0
  62. data/vendor/snowball/cxx/utilities.cxx +2 -0
  63. data/vendor/snowball/dart/.gitignore +4 -0
  64. data/vendor/snowball/dart/analysis_options.yaml +1 -0
  65. data/vendor/snowball/dart/example/test_app.dart +65 -0
  66. data/vendor/snowball/dart/generate_algorithms.pl +21 -0
  67. data/vendor/snowball/dart/lib/snowball.dart +18 -0
  68. data/vendor/snowball/dart/lib/src/snowball.dart +339 -0
  69. data/vendor/snowball/dart/pubspec.yaml +17 -0
  70. data/vendor/snowball/doc/libstemmer_dart_README +37 -0
  71. data/vendor/snowball/doc/libstemmer_js_README +2 -2
  72. data/vendor/snowball/doc/libstemmer_php_README +38 -0
  73. data/vendor/snowball/doc/libstemmer_python_README +3 -3
  74. data/vendor/snowball/examples/stemwords.c +18 -3
  75. data/vendor/snowball/go/README.md +12 -4
  76. data/vendor/snowball/go/env.go +12 -14
  77. data/vendor/snowball/go/stemwords/main.go +2 -1
  78. data/vendor/snowball/java/org/tartarus/snowball/CharArraySequence.java +36 -0
  79. data/vendor/snowball/java/org/tartarus/snowball/SnowballProgram.java +17 -34
  80. data/vendor/snowball/java/org/tartarus/snowball/SnowballStemmer.java +0 -2
  81. data/vendor/snowball/javascript/base-stemmer.js +219 -252
  82. data/vendor/snowball/javascript/stemwords.js +86 -58
  83. data/vendor/snowball/libstemmer/mkmodules.pl +1 -1
  84. data/vendor/snowball/libstemmer/modules.txt +4 -0
  85. data/vendor/snowball/pascal/SnowballProgram.pas +18 -31
  86. data/vendor/snowball/php/base-stemmer.php +453 -0
  87. data/vendor/snowball/php/stemwords.php +25 -0
  88. data/vendor/snowball/python/create_init.py +16 -21
  89. data/vendor/snowball/python/pyproject.toml +3 -0
  90. data/vendor/snowball/python/setup.py +5 -7
  91. data/vendor/snowball/python/snowballstemmer/among.py +1 -2
  92. data/vendor/snowball/python/snowballstemmer/basestemmer.py +24 -33
  93. data/vendor/snowball/python/stemwords.py +72 -63
  94. data/vendor/snowball/runtime/api.c +11 -42
  95. data/vendor/snowball/runtime/api.h +11 -9
  96. data/vendor/snowball/runtime/snowball_runtime.h +110 -0
  97. data/vendor/snowball/runtime/utilities.c +282 -106
  98. data/vendor/snowball/rust/src/main.rs +2 -2
  99. data/vendor/snowball/rust/src/snowball/snowball_env.rs +7 -9
  100. data/vendor/snowball/tests/compilertest +62 -0
  101. data/vendor/snowball/tests/errors/ae-errors.sbl +53 -0
  102. data/vendor/snowball/tests/errors/ae-errors.stderr +8 -0
  103. data/vendor/snowball/tests/errors/bad-dollar.sbl +14 -0
  104. data/vendor/snowball/tests/errors/bad-dollar.stderr +4 -0
  105. data/vendor/snowball/tests/errors/bad-grouping-definition.sbl +9 -0
  106. data/vendor/snowball/tests/errors/bad-grouping-definition.stderr +6 -0
  107. data/vendor/snowball/tests/errors/missing-bra.sbl +6 -0
  108. data/vendor/snowball/tests/errors/missing-bra.stderr +3 -0
  109. data/vendor/snowball/tests/errors/missing-command.sbl +9 -0
  110. data/vendor/snowball/tests/errors/missing-command.stderr +1 -0
  111. data/vendor/snowball/tests/errors/missing-ket-backwardmode.sbl +3 -0
  112. data/vendor/snowball/tests/errors/missing-ket-backwardmode.stderr +1 -0
  113. data/vendor/snowball/tests/errors/missing-ket.sbl +7 -0
  114. data/vendor/snowball/tests/errors/missing-ket.stderr +6 -0
  115. data/vendor/snowball/tests/errors/notdefined.sbl +4 -0
  116. data/vendor/snowball/tests/errors/notdefined.stderr +2 -0
  117. data/vendor/snowball/tests/errors/string-omitted.sbl +5 -0
  118. data/vendor/snowball/tests/errors/string-omitted.stderr +1 -0
  119. data/vendor/snowball/tests/errors/undeclared.sbl +20 -0
  120. data/vendor/snowball/tests/errors/undeclared.stderr +9 -0
  121. data/vendor/snowball/tests/errors/unexpected-token.sbl +24 -0
  122. data/vendor/snowball/tests/errors/unexpected-token.stderr +17 -0
  123. data/vendor/snowball/tests/errors/wrongdirection.sbl +14 -0
  124. data/vendor/snowball/tests/errors/wrongdirection.stderr +1 -0
  125. data/vendor/snowball/tests/runtime/among.sbl +19 -0
  126. data/vendor/snowball/tests/runtime/arithmeticexpr.sbl +86 -0
  127. data/vendor/snowball/tests/runtime/attachinsert.sbl +47 -0
  128. data/vendor/snowball/tests/runtime/booleans.sbl +19 -0
  129. data/vendor/snowball/tests/runtime/externals.sbl +22 -0
  130. data/vendor/snowball/tests/runtime/hop.sbl +12 -0
  131. data/vendor/snowball/tests/runtime/integertests.sbl +60 -0
  132. data/vendor/snowball/tests/runtime/intlimits.sbl +25 -0
  133. data/vendor/snowball/tests/runtime/naming.sbl +20 -0
  134. data/vendor/snowball/tests/runtime/not.sbl +30 -0
  135. data/vendor/snowball/tests/runtime/or.sbl +17 -0
  136. data/vendor/snowball/tests/runtime/repeat.sbl +16 -0
  137. data/vendor/snowball/tests/runtime/setlimit.sbl +24 -0
  138. data/vendor/snowball/tests/runtime/sizelen.sbl +56 -0
  139. data/vendor/snowball/tests/runtime/slice.sbl +27 -0
  140. data/vendor/snowball/tests/runtime/stringdollar.sbl +39 -0
  141. data/vendor/snowball/tests/runtime/strings.sbl +66 -0
  142. data/vendor/snowball/tests/runtime/test.sbl +19 -0
  143. data/vendor/snowball/tests/stemtest.c +41 -1
  144. data/vendor/snowball/tests/syntax/canon.sbl +32 -0
  145. data/vendor/snowball/tests/syntax/canon.stderr +0 -0
  146. data/vendor/snowball/tests/syntax/canon.syntax +57 -0
  147. data/vendor/snowball/tests/syntax/emptyprogram.sbl +2 -0
  148. data/vendor/snowball/tests/syntax/emptyprogram.syntax +0 -0
  149. data/vendor/snowball/tests/syntax/groupings.sbl +11 -0
  150. data/vendor/snowball/tests/syntax/inline.sbl +144 -0
  151. data/vendor/snowball/tests/syntax/inline.stderr +0 -0
  152. data/vendor/snowball/tests/syntax/inline.syntax +121 -0
  153. data/vendor/snowball/tests/syntax/legacy.sbl +17 -0
  154. data/vendor/snowball/tests/syntax/legacy.stderr +5 -0
  155. data/vendor/snowball/tests/syntax/legacy.syntax +19 -0
  156. data/vendor/snowball/tests/syntax/loops.sbl +14 -0
  157. data/vendor/snowball/tests/syntax/loops.stderr +9 -0
  158. data/vendor/snowball/tests/syntax/loops.syntax +29 -0
  159. data/vendor/snowball/tests/syntax/noops.sbl +76 -0
  160. data/vendor/snowball/tests/syntax/noops.stderr +27 -0
  161. data/vendor/snowball/tests/syntax/noops.syntax +135 -0
  162. data/vendor/snowball/tests/syntax/simplifyae.sbl +21 -0
  163. data/vendor/snowball/tests/syntax/simplifyae.stderr +0 -0
  164. data/vendor/snowball/tests/syntax/simplifyae.syntax +39 -0
  165. data/vendor/snowball/tests/syntax/unused.sbl +18 -0
  166. data/vendor/snowball/tests/syntax/unused.stderr +7 -0
  167. data/vendor/snowball/tests/syntax/unused.syntax +3 -0
  168. data/vendor/snowball/zig/env.zig +599 -0
  169. data/vendor/snowball/zig/generate_algorithms.pl +19 -0
  170. data/vendor/snowball/zig/stemwords.zig +123 -0
  171. metadata +102 -4
  172. data/vendor/snowball/compiler/syswords.h +0 -86
  173. data/vendor/snowball/runtime/header.h +0 -62
@@ -33,68 +33,64 @@ package body Stemmer with SPARK_Mode is
33
33
  subtype Byte is Interfaces.Unsigned_8;
34
34
  use type Interfaces.Unsigned_8;
35
35
 
36
- procedure Stem_Word (Context : in out Context_Type'Class;
37
- Word : in String;
38
- Result : out Boolean) is
36
+ procedure Stem_Word (Z : in out Context_Type'Class;
37
+ Word : in String;
38
+ Result : out Boolean) is
39
39
  begin
40
- Context.P (1 .. Word'Length) := Word;
41
- Context.Len := Word'Length;
42
- Context.C := 0;
43
- Context.L := Word'Length;
44
- Context.Lb := 0;
45
- Stemmer.Stem (Context, Result);
40
+ Z.P (1 .. Word'Length) := Word;
41
+ Z.Len := Word'Length;
42
+ Z.C := 0;
43
+ Z.L := Word'Length;
44
+ Z.Lb := 0;
45
+ Stemmer.Stem (Z, Result);
46
46
  end Stem_Word;
47
47
 
48
- function Get_Result (Context : in Context_Type'Class) return String is
48
+ function Get_Result (Z : in Context_Type'Class) return String is
49
49
  begin
50
- return Context.P (1 .. Context.Len);
50
+ return Z.P (1 .. Z.Len);
51
51
  end Get_Result;
52
52
 
53
- function Eq_S (Context : in Context_Type'Class;
54
- S : in String) return Char_Index is
53
+ procedure Eq_S (Z : in out Context_Type'Class;
54
+ S : in String;
55
+ Len : in Char_Index;
56
+ Result : out Boolean) is
55
57
  begin
56
- if Context.L - Context.C < S'Length then
57
- return 0;
58
+ if Z.L - Z.C < Len then
59
+ Result := False;
60
+ return;
58
61
  end if;
59
- if Context.P (Context.C + 1 .. Context.C + S'Length) /= S then
60
- return 0;
62
+ if Z.P (Z.C + 1 .. Z.C + Len) /= S (S'First .. Len) then
63
+ Result := False;
64
+ return;
61
65
  end if;
62
- return S'Length;
66
+ Z.C := Z.C + Len;
67
+ Result := True;
63
68
  end Eq_S;
64
69
 
65
- function Eq_S_Backward (Context : in Context_Type'Class;
66
- S : in String) return Char_Index is
70
+ procedure Eq_S_Backward (Z : in out Context_Type'Class;
71
+ S : in String;
72
+ Len : in Char_Index;
73
+ Result : out Boolean) is
67
74
  begin
68
- if Context.C - Context.Lb < S'Length then
69
- return 0;
75
+ if Z.C - Z.Lb < Len then
76
+ Result := False;
77
+ return;
70
78
  end if;
71
- if Context.P (Context.C + 1 - S'Length .. Context.C) /= S then
72
- return 0;
79
+ if Z.P (Z.C + 1 - Len .. Z.C) /= S (S'First .. Len) then
80
+ Result := False;
81
+ return;
73
82
  end if;
74
- return S'Length;
83
+ Z.C := Z.C - Len;
84
+ Result := True;
75
85
  end Eq_S_Backward;
76
86
 
77
- function Length_Utf8 (Context : in Context_Type'Class) return Natural is
87
+ function Length_Utf8 (S : in String;
88
+ Len : in Char_Index) return Natural is
78
89
  Count : Natural := 0;
79
90
  Pos : Positive := 1;
80
91
  Val : Byte;
81
92
  begin
82
- while Pos <= Context.Len loop
83
- Val := Character'Pos (Context.P (Pos));
84
- Pos := Pos + 1;
85
- if Val >= 16#C0# or Val < 16#80# then
86
- Count := Count + 1;
87
- end if;
88
- end loop;
89
- return Count;
90
- end Length_Utf8;
91
-
92
- function Length_Utf8 (S : in String) return Natural is
93
- Count : Natural := 0;
94
- Pos : Positive := 1;
95
- Val : Byte;
96
- begin
97
- while Pos <= S'Length loop
93
+ while Pos <= Len loop
98
94
  Val := Character'Pos (S (Pos));
99
95
  Pos := Pos + 1;
100
96
  if Val >= 16#C0# or Val < 16#80# then
@@ -104,12 +100,12 @@ package body Stemmer with SPARK_Mode is
104
100
  return Count;
105
101
  end Length_Utf8;
106
102
 
107
- function Check_Among (Context : in Context_Type'Class;
108
- Pos : in Char_Index;
109
- Shift : in Natural;
110
- Mask : in Mask_Type) return Boolean is
103
+ function Check_Among (Z : in Context_Type'Class;
104
+ Pos : in Char_Index;
105
+ Shift : in Natural;
106
+ Mask : in Mask_Type) return Boolean is
111
107
  use Interfaces;
112
- Val : constant Byte := Character'Pos (Context.P (Pos + 1));
108
+ Val : constant Byte := Character'Pos (Z.P (Pos + 1));
113
109
  begin
114
110
  if Natural (Shift_Right (Val, 5)) /= Shift then
115
111
  return True;
@@ -117,7 +113,7 @@ package body Stemmer with SPARK_Mode is
117
113
  return (Shift_Right (Unsigned_64 (Mask), Natural (Val and 16#1f#)) and 1) = 0;
118
114
  end Check_Among;
119
115
 
120
- procedure Find_Among (Context : in out Context_Type'Class;
116
+ procedure Find_Among (Z : in out Context_Type'Class;
121
117
  Amongs : in Among_Array_Type;
122
118
  Pattern : in String;
123
119
  Execute : access procedure
@@ -130,8 +126,8 @@ package body Stemmer with SPARK_Mode is
130
126
  Common_I : Natural := 0;
131
127
  Common_J : Natural := 0;
132
128
  First_Key_Inspected : Boolean := False;
133
- C : constant Natural := Context.C;
134
- L : constant Integer := Context.L;
129
+ C : constant Natural := Z.C;
130
+ L : constant Integer := Z.L;
135
131
  begin
136
132
  loop
137
133
  declare
@@ -145,7 +141,7 @@ package body Stemmer with SPARK_Mode is
145
141
  Diff := -1;
146
142
  exit;
147
143
  end if;
148
- Diff := Character'Pos (Context.P (C + Common + 1))
144
+ Diff := Character'Pos (Z.P (C + Common + 1))
149
145
  - Character'Pos (Pattern (I2));
150
146
  exit when Diff /= 0;
151
147
  Common := Common + 1;
@@ -171,14 +167,14 @@ package body Stemmer with SPARK_Mode is
171
167
  Status : Boolean;
172
168
  begin
173
169
  if Common_I >= Len then
174
- Context.C := C + Len;
170
+ Z.C := C + Len;
175
171
  if W.Operation = 0 then
176
172
  Result := W.Result;
177
173
  return;
178
174
  end if;
179
- Execute (Context, W.Operation, Status);
180
- Context.C := C + Len;
175
+ Execute (Z, W.Operation, Status);
181
176
  if Status then
177
+ Z.C := C + Len;
182
178
  Result := W.Result;
183
179
  return;
184
180
  end if;
@@ -190,7 +186,7 @@ package body Stemmer with SPARK_Mode is
190
186
  Result := 0;
191
187
  end Find_Among;
192
188
 
193
- procedure Find_Among_Backward (Context : in out Context_Type'Class;
189
+ procedure Find_Among_Backward (Z : in out Context_Type'Class;
194
190
  Amongs : in Among_Array_Type;
195
191
  Pattern : in String;
196
192
  Execute : access procedure
@@ -203,8 +199,8 @@ package body Stemmer with SPARK_Mode is
203
199
  Common_I : Natural := 0;
204
200
  Common_J : Natural := 0;
205
201
  First_Key_Inspected : Boolean := False;
206
- C : constant Integer := Context.C;
207
- Lb : constant Integer := Context.Lb;
202
+ C : constant Integer := Z.C;
203
+ Lb : constant Integer := Z.Lb;
208
204
  begin
209
205
  loop
210
206
  declare
@@ -218,7 +214,7 @@ package body Stemmer with SPARK_Mode is
218
214
  Diff := -1;
219
215
  exit;
220
216
  end if;
221
- Diff := Character'Pos (Context.P (C - Common))
217
+ Diff := Character'Pos (Z.P (C - Common))
222
218
  - Character'Pos (Pattern (I2));
223
219
  exit when Diff /= 0;
224
220
  Common := Common + 1;
@@ -244,14 +240,14 @@ package body Stemmer with SPARK_Mode is
244
240
  Status : Boolean;
245
241
  begin
246
242
  if Common_I >= Len then
247
- Context.C := C - Len;
243
+ Z.C := C - Len;
248
244
  if W.Operation = 0 then
249
245
  Result := W.Result;
250
246
  return;
251
247
  end if;
252
- Execute (Context, W.Operation, Status);
253
- Context.C := C - Len;
248
+ Execute (Z, W.Operation, Status);
254
249
  if Status then
250
+ Z.C := C - Len;
255
251
  Result := W.Result;
256
252
  return;
257
253
  end if;
@@ -263,18 +259,18 @@ package body Stemmer with SPARK_Mode is
263
259
  Result := 0;
264
260
  end Find_Among_Backward;
265
261
 
266
- function Skip_Utf8 (Context : in Context_Type'Class) return Result_Index is
267
- Pos : Char_Index := Context.C;
262
+ function Skip_Utf8 (Z : in Context_Type'Class) return Result_Index is
263
+ Pos : Char_Index := Z.C;
268
264
  Val : Byte;
269
265
  begin
270
- if Pos >= Context.L then
266
+ if Pos >= Z.L then
271
267
  return -1;
272
268
  end if;
273
269
  Pos := Pos + 1;
274
- Val := Character'Pos (Context.P (Pos));
270
+ Val := Character'Pos (Z.P (Pos));
275
271
  if Val >= 16#C0# then
276
- while Pos < Context.L loop
277
- Val := Character'Pos (Context.P (Pos + 1));
272
+ while Pos < Z.L loop
273
+ Val := Character'Pos (Z.P (Pos + 1));
278
274
  exit when Val >= 16#C0# or Val < 16#80#;
279
275
  Pos := Pos + 1;
280
276
  end loop;
@@ -282,23 +278,23 @@ package body Stemmer with SPARK_Mode is
282
278
  return Pos;
283
279
  end Skip_Utf8;
284
280
 
285
- function Skip_Utf8 (Context : in Context_Type'Class;
281
+ function Skip_Utf8 (Z : in Context_Type'Class;
286
282
  N : in Integer) return Result_Index is
287
- Pos : Char_Index := Context.C;
283
+ Pos : Char_Index := Z.C;
288
284
  Val : Byte;
289
285
  begin
290
286
  if N < 0 then
291
287
  return -1;
292
288
  end if;
293
289
  for I in 1 .. N loop
294
- if Pos >= Context.L then
290
+ if Pos >= Z.L then
295
291
  return -1;
296
292
  end if;
297
293
  Pos := Pos + 1;
298
- Val := Character'Pos (Context.P (Pos));
294
+ Val := Character'Pos (Z.P (Pos));
299
295
  if Val >= 16#C0# then
300
- while Pos < Context.L loop
301
- Val := Character'Pos (Context.P (Pos + 1));
296
+ while Pos < Z.L loop
297
+ Val := Character'Pos (Z.P (Pos + 1));
302
298
  exit when Val >= 16#C0# or Val < 16#80#;
303
299
  Pos := Pos + 1;
304
300
  end loop;
@@ -307,18 +303,18 @@ package body Stemmer with SPARK_Mode is
307
303
  return Pos;
308
304
  end Skip_Utf8;
309
305
 
310
- function Skip_Utf8_Backward (Context : in Context_Type'Class) return Result_Index is
311
- Pos : Char_Index := Context.C;
306
+ function Skip_Utf8_Backward (Z : in Context_Type'Class) return Result_Index is
307
+ Pos : Char_Index := Z.C;
312
308
  Val : Byte;
313
309
  begin
314
- if Pos <= Context.Lb then
310
+ if Pos <= Z.Lb then
315
311
  return -1;
316
312
  end if;
317
- Val := Character'Pos (Context.P (Pos));
313
+ Val := Character'Pos (Z.P (Pos));
318
314
  Pos := Pos - 1;
319
315
  if Val >= 16#80# then
320
- while Pos > Context.Lb loop
321
- Val := Character'Pos (Context.P (Pos + 1));
316
+ while Pos > Z.Lb loop
317
+ Val := Character'Pos (Z.P (Pos + 1));
322
318
  exit when Val >= 16#C0#;
323
319
  Pos := Pos - 1;
324
320
  end loop;
@@ -326,23 +322,23 @@ package body Stemmer with SPARK_Mode is
326
322
  return Pos;
327
323
  end Skip_Utf8_Backward;
328
324
 
329
- function Skip_Utf8_Backward (Context : in Context_Type'Class;
330
- N : in Integer) return Result_Index is
331
- Pos : Char_Index := Context.C;
325
+ function Skip_Utf8_Backward (Z : in Context_Type'Class;
326
+ N : in Integer) return Result_Index is
327
+ Pos : Char_Index := Z.C;
332
328
  Val : Byte;
333
329
  begin
334
330
  if N < 0 then
335
331
  return -1;
336
332
  end if;
337
333
  for I in 1 .. N loop
338
- if Pos <= Context.Lb then
334
+ if Pos <= Z.Lb then
339
335
  return -1;
340
336
  end if;
341
- Val := Character'Pos (Context.P (Pos));
337
+ Val := Character'Pos (Z.P (Pos));
342
338
  Pos := Pos - 1;
343
339
  if Val >= 16#80# then
344
- while Pos > Context.Lb loop
345
- Val := Character'Pos (Context.P (Pos + 1));
340
+ while Pos > Z.Lb loop
341
+ Val := Character'Pos (Z.P (Pos + 1));
346
342
  exit when Val >= 16#C0#;
347
343
  Pos := Pos - 1;
348
344
  end loop;
@@ -355,67 +351,67 @@ package body Stemmer with SPARK_Mode is
355
351
  Shift : in Natural) return Utf8_Type
356
352
  is (Utf8_Type (Interfaces.Shift_Left (Interfaces.Unsigned_32 (Value), Shift)));
357
353
 
358
- procedure Get_Utf8 (Context : in Context_Type'Class;
359
- Value : out Utf8_Type;
360
- Count : out Natural) is
354
+ procedure Get_Utf8 (Z : in Context_Type'Class;
355
+ Value : out Utf8_Type;
356
+ Count : out Natural) is
361
357
  B0, B1, B2, B3 : Byte;
362
358
  begin
363
- if Context.C >= Context.L then
359
+ if Z.C >= Z.L then
364
360
  Value := 0;
365
361
  Count := 0;
366
362
  return;
367
363
  end if;
368
- B0 := Character'Pos (Context.P (Context.C + 1));
369
- if B0 < 16#C0# or Context.C + 1 >= Context.L then
364
+ B0 := Character'Pos (Z.P (Z.C + 1));
365
+ if B0 < 16#C0# or Z.C + 1 >= Z.L then
370
366
  Value := Utf8_Type (B0);
371
367
  Count := 1;
372
368
  return;
373
369
  end if;
374
- B1 := Character'Pos (Context.P (Context.C + 2)) and 16#3F#;
375
- if B0 < 16#E0# or Context.C + 2 >= Context.L then
370
+ B1 := Character'Pos (Z.P (Z.C + 2)) and 16#3F#;
371
+ if B0 < 16#E0# or Z.C + 2 >= Z.L then
376
372
  Value := Shift_Left (Utf8_Type (B0 and 16#1F#), 6) or Utf8_Type (B1);
377
373
  Count := 2;
378
374
  return;
379
375
  end if;
380
- B2 := Character'Pos (Context.P (Context.C + 3)) and 16#3F#;
381
- if B0 < 16#F0# or Context.C + 3 >= Context.L then
376
+ B2 := Character'Pos (Z.P (Z.C + 3)) and 16#3F#;
377
+ if B0 < 16#F0# or Z.C + 3 >= Z.L then
382
378
  Value := Shift_Left (Utf8_Type (B0 and 16#0F#), 12)
383
379
  or Shift_Left (Utf8_Type (B1), 6) or Utf8_Type (B2);
384
380
  Count := 3;
385
381
  return;
386
382
  end if;
387
- B3 := Character'Pos (Context.P (Context.C + 4)) and 16#3F#;
383
+ B3 := Character'Pos (Z.P (Z.C + 4)) and 16#3F#;
388
384
  Value := Shift_Left (Utf8_Type (B0 and 16#07#), 18)
389
385
  or Shift_Left (Utf8_Type (B1), 12)
390
386
  or Shift_Left (Utf8_Type (B2), 6) or Utf8_Type (B3);
391
387
  Count := 4;
392
388
  end Get_Utf8;
393
389
 
394
- procedure Get_Utf8_Backward (Context : in Context_Type'Class;
395
- Value : out Utf8_Type;
396
- Count : out Natural) is
390
+ procedure Get_Utf8_Backward (Z : in Context_Type'Class;
391
+ Value : out Utf8_Type;
392
+ Count : out Natural) is
397
393
  B0, B1, B2, B3 : Byte;
398
394
  begin
399
- if Context.C <= Context.Lb then
395
+ if Z.C <= Z.Lb then
400
396
  Value := 0;
401
397
  Count := 0;
402
398
  return;
403
399
  end if;
404
- B3 := Character'Pos (Context.P (Context.C));
405
- if B3 < 16#80# or Context.C - 1 <= Context.Lb then
400
+ B3 := Character'Pos (Z.P (Z.C));
401
+ if B3 < 16#80# or Z.C - 1 <= Z.Lb then
406
402
  Value := Utf8_Type (B3);
407
403
  Count := 1;
408
404
  return;
409
405
  end if;
410
- B2 := Character'Pos (Context.P (Context.C - 1));
411
- if B2 >= 16#C0# or Context.C - 2 <= Context.Lb then
406
+ B2 := Character'Pos (Z.P (Z.C - 1));
407
+ if B2 >= 16#C0# or Z.C - 2 <= Z.Lb then
412
408
  B3 := B3 and 16#3F#;
413
409
  Value := Shift_Left (Utf8_Type (B2 and 16#1F#), 6) or Utf8_Type (B3);
414
410
  Count := 2;
415
411
  return;
416
412
  end if;
417
- B1 := Character'Pos (Context.P (Context.C - 2));
418
- if B1 >= 16#E0# or Context.C - 3 <= Context.Lb then
413
+ B1 := Character'Pos (Z.P (Z.C - 2));
414
+ if B1 >= 16#E0# or Z.C - 3 <= Z.Lb then
419
415
  B3 := B3 and 16#3F#;
420
416
  B2 := B2 and 16#3F#;
421
417
  Value := Shift_Left (Utf8_Type (B1 and 16#0F#), 12)
@@ -423,7 +419,7 @@ package body Stemmer with SPARK_Mode is
423
419
  Count := 3;
424
420
  return;
425
421
  end if;
426
- B0 := Character'Pos (Context.P (Context.C - 3));
422
+ B0 := Character'Pos (Z.P (Z.C - 3));
427
423
  B1 := B1 and 16#1F#;
428
424
  B2 := B2 and 16#3F#;
429
425
  B3 := B3 and 16#3F#;
@@ -433,22 +429,22 @@ package body Stemmer with SPARK_Mode is
433
429
  Count := 4;
434
430
  end Get_Utf8_Backward;
435
431
 
436
- procedure Out_Grouping (Context : in out Context_Type'Class;
437
- S : in Grouping_Array;
438
- Min : in Utf8_Type;
439
- Max : in Utf8_Type;
440
- Repeat : in Boolean;
441
- Result : out Result_Index) is
432
+ procedure Out_Grouping (Z : in out Context_Type'Class;
433
+ S : in Grouping_Array;
434
+ Min : in Utf8_Type;
435
+ Max : in Utf8_Type;
436
+ Repeat : in Boolean;
437
+ Result : out Result_Index) is
442
438
  Ch : Utf8_Type;
443
439
  Count : Natural;
444
440
  begin
445
- if Context.C >= Context.L then
441
+ if Z.C >= Z.L then
446
442
  Result := -1;
447
443
  return;
448
444
  end if;
449
445
 
450
446
  loop
451
- Get_Utf8 (Context, Ch, Count);
447
+ Get_Utf8 (Z, Ch, Count);
452
448
  if Count = 0 then
453
449
  Result := -1;
454
450
  return;
@@ -460,28 +456,28 @@ package body Stemmer with SPARK_Mode is
460
456
  return;
461
457
  end if;
462
458
  end if;
463
- Context.C := Context.C + Count;
459
+ Z.C := Z.C + Count;
464
460
  exit when not Repeat;
465
461
  end loop;
466
462
  Result := 0;
467
463
  end Out_Grouping;
468
464
 
469
- procedure Out_Grouping_Backward (Context : in out Context_Type'Class;
470
- S : in Grouping_Array;
471
- Min : in Utf8_Type;
472
- Max : in Utf8_Type;
473
- Repeat : in Boolean;
474
- Result : out Result_Index) is
465
+ procedure Out_Grouping_Backward (Z : in out Context_Type'Class;
466
+ S : in Grouping_Array;
467
+ Min : in Utf8_Type;
468
+ Max : in Utf8_Type;
469
+ Repeat : in Boolean;
470
+ Result : out Result_Index) is
475
471
  Ch : Utf8_Type;
476
472
  Count : Natural;
477
473
  begin
478
- if Context.C <= Context.Lb then
474
+ if Z.C <= Z.Lb then
479
475
  Result := -1;
480
476
  return;
481
477
  end if;
482
478
 
483
479
  loop
484
- Get_Utf8_Backward (Context, Ch, Count);
480
+ Get_Utf8_Backward (Z, Ch, Count);
485
481
  if Count = 0 then
486
482
  Result := -1;
487
483
  return;
@@ -493,28 +489,28 @@ package body Stemmer with SPARK_Mode is
493
489
  return;
494
490
  end if;
495
491
  end if;
496
- Context.C := Context.C - Count;
492
+ Z.C := Z.C - Count;
497
493
  exit when not Repeat;
498
494
  end loop;
499
495
  Result := 0;
500
496
  end Out_Grouping_Backward;
501
497
 
502
- procedure In_Grouping (Context : in out Context_Type'Class;
503
- S : in Grouping_Array;
504
- Min : in Utf8_Type;
505
- Max : in Utf8_Type;
506
- Repeat : in Boolean;
507
- Result : out Result_Index) is
498
+ procedure In_Grouping (Z : in out Context_Type'Class;
499
+ S : in Grouping_Array;
500
+ Min : in Utf8_Type;
501
+ Max : in Utf8_Type;
502
+ Repeat : in Boolean;
503
+ Result : out Result_Index) is
508
504
  Ch : Utf8_Type;
509
505
  Count : Natural;
510
506
  begin
511
- if Context.C >= Context.L then
507
+ if Z.C >= Z.L then
512
508
  Result := -1;
513
509
  return;
514
510
  end if;
515
511
 
516
512
  loop
517
- Get_Utf8 (Context, Ch, Count);
513
+ Get_Utf8 (Z, Ch, Count);
518
514
  if Count = 0 then
519
515
  Result := -1;
520
516
  return;
@@ -528,28 +524,28 @@ package body Stemmer with SPARK_Mode is
528
524
  Result := Count;
529
525
  return;
530
526
  end if;
531
- Context.C := Context.C + Count;
527
+ Z.C := Z.C + Count;
532
528
  exit when not Repeat;
533
529
  end loop;
534
530
  Result := 0;
535
531
  end In_Grouping;
536
532
 
537
- procedure In_Grouping_Backward (Context : in out Context_Type'Class;
538
- S : in Grouping_Array;
539
- Min : in Utf8_Type;
540
- Max : in Utf8_Type;
541
- Repeat : in Boolean;
542
- Result : out Result_Index) is
533
+ procedure In_Grouping_Backward (Z : in out Context_Type'Class;
534
+ S : in Grouping_Array;
535
+ Min : in Utf8_Type;
536
+ Max : in Utf8_Type;
537
+ Repeat : in Boolean;
538
+ Result : out Result_Index) is
543
539
  Ch : Utf8_Type;
544
540
  Count : Natural;
545
541
  begin
546
- if Context.C <= Context.Lb then
542
+ if Z.C <= Z.Lb then
547
543
  Result := -1;
548
544
  return;
549
545
  end if;
550
546
 
551
547
  loop
552
- Get_Utf8_Backward (Context, Ch, Count);
548
+ Get_Utf8_Backward (Z, Ch, Count);
553
549
  if Count = 0 then
554
550
  Result := -1;
555
551
  return;
@@ -563,69 +559,62 @@ package body Stemmer with SPARK_Mode is
563
559
  Result := Count;
564
560
  return;
565
561
  end if;
566
- Context.C := Context.C - Count;
562
+ Z.C := Z.C - Count;
567
563
  exit when not Repeat;
568
564
  end loop;
569
565
  Result := 0;
570
566
  end In_Grouping_Backward;
571
567
 
572
- procedure Replace (Context : in out Context_Type'Class;
573
- C_Bra : in Char_Index;
574
- C_Ket : in Char_Index;
575
- S : in String;
576
- Adjustment : out Integer) is
568
+ procedure Replace (Z : in out Context_Type'Class;
569
+ C_Bra : in Char_Index;
570
+ C_Ket : in Char_Index;
571
+ S : in String;
572
+ Len : in Char_Index) is
573
+ Adjustment : Integer;
577
574
  begin
578
- Adjustment := S'Length - (C_Ket - C_Bra);
579
- if Adjustment > 0 then
580
- Context.P (C_Bra + S'Length + 1 .. Context.Len + Adjustment + 1)
581
- := Context.P (C_Ket + 1 .. Context.Len + 1);
582
- end if;
583
- if S'Length > 0 then
584
- Context.P (C_Bra + 1 .. C_Bra + S'Length) := S;
585
- end if;
586
- if Adjustment < 0 then
587
- Context.P (C_Bra + S'Length + 1 .. Context.Len + Adjustment + 1)
588
- := Context.P (C_Ket + 1 .. Context.Len + 1);
575
+ Adjustment := Len - (C_Ket - C_Bra);
576
+ if Adjustment /= 0 then
577
+ Z.P (C_Ket + Adjustment + 1 .. Z.Len + Adjustment)
578
+ := Z.P (C_Ket + 1 .. Z.Len);
579
+ Z.Len := Z.Len + Adjustment;
580
+ Z.L := Z.L + Adjustment;
581
+ if Z.C >= C_Ket then
582
+ Z.C := Z.C + Adjustment;
583
+ elsif Z.C > C_Bra then
584
+ Z.C := C_Bra;
585
+ end if;
589
586
  end if;
590
- Context.Len := Context.Len + Adjustment;
591
- Context.L := Context.L + Adjustment;
592
- if Context.C >= C_Ket then
593
- Context.C := Context.C + Adjustment;
594
- elsif Context.C > C_Bra then
595
- Context.C := C_Bra;
587
+ if Len > 0 then
588
+ Z.P (C_Bra + 1 .. C_Bra + Len) := S (S'First .. Len);
596
589
  end if;
597
590
  end Replace;
598
591
 
599
- procedure Slice_Del (Context : in out Context_Type'Class) is
600
- Result : Integer;
592
+ procedure Slice_Del (Z : in out Context_Type'Class) is
601
593
  begin
602
- Replace (Context, Context.Bra, Context.Ket, "", Result);
594
+ Replace (Z, Z.Bra, Z.Ket, "", 0);
595
+ Z.Ket := Z.Bra;
603
596
  end Slice_Del;
604
597
 
605
- procedure Slice_From (Context : in out Context_Type'Class;
606
- Text : in String) is
607
- Result : Integer;
598
+ procedure Slice_From (Z : in out Context_Type'Class;
599
+ Text : in String;
600
+ Len : in Char_Index) is
608
601
  begin
609
- Replace (Context, Context.Bra, Context.Ket, Text, Result);
602
+ Replace (Z, Z.Bra, Z.Ket, Text, Len);
603
+ Z.Ket := Z.Bra + Len;
610
604
  end Slice_From;
611
605
 
612
- function Slice_To (Context : in Context_Type'Class) return String is
613
- begin
614
- return Context.P (Context.Bra + 1 .. Context.Ket);
615
- end Slice_To;
616
-
617
- procedure Insert (Context : in out Context_Type'Class;
618
- C_Bra : in Char_Index;
619
- C_Ket : in Char_Index;
620
- S : in String) is
621
- Result : Integer;
606
+ procedure Insert (Z : in out Context_Type'Class;
607
+ S : in String;
608
+ Len : in Char_Index) is
609
+ C : Char_Index;
622
610
  begin
623
- Replace (Context, C_Bra, C_Ket, S, Result);
624
- if C_Bra <= Context.Bra then
625
- Context.Bra := Context.Bra + Result;
611
+ C := Z.C;
612
+ Replace (Z, Z.C, Z.C, S, Len);
613
+ if C <= Z.Bra then
614
+ Z.Bra := Z.Bra + Len;
626
615
  end if;
627
- if C_Bra <= Context.Ket then
628
- Context.Ket := Context.Ket + Result;
616
+ if C <= Z.Ket then
617
+ Z.Ket := Z.Ket + Len;
629
618
  end if;
630
619
  end Insert;
631
620