mittens 0.3.0 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -1
- data/README.md +2 -2
- data/Rakefile +12 -5
- data/ext/mittens/extconf.rb +3 -1
- data/lib/mittens/version.rb +1 -1
- data/vendor/snowball/.github/workflows/ci.yml +144 -17
- data/vendor/snowball/.github/workflows/coverage.yml +117 -0
- data/vendor/snowball/.github/workflows/runtime-tests.yml +26 -0
- data/vendor/snowball/.gitignore +33 -7
- data/vendor/snowball/CONTRIBUTING.rst +7 -0
- data/vendor/snowball/COPYING +1 -1
- data/vendor/snowball/GNUmakefile +736 -298
- data/vendor/snowball/NEWS +1394 -7
- data/vendor/snowball/README.rst +8 -8
- data/vendor/snowball/ada/generate/generate.adb +5 -5
- data/vendor/snowball/ada/src/stemmer.adb +177 -188
- data/vendor/snowball/ada/src/stemmer.ads +86 -89
- data/vendor/snowball/ada/src/stemwords.adb +21 -5
- data/vendor/snowball/algorithms/czech.sbl +255 -0
- data/vendor/snowball/algorithms/danish.sbl +22 -10
- data/vendor/snowball/algorithms/english.sbl +7 -4
- data/vendor/snowball/algorithms/esperanto.sbl +6 -7
- data/vendor/snowball/algorithms/estonian.sbl +9 -4
- data/vendor/snowball/algorithms/finnish.sbl +33 -21
- data/vendor/snowball/algorithms/german.sbl +5 -0
- data/vendor/snowball/algorithms/indonesian.sbl +115 -96
- data/vendor/snowball/algorithms/italian.sbl +26 -1
- data/vendor/snowball/algorithms/lithuanian.sbl +13 -13
- data/vendor/snowball/algorithms/norwegian.sbl +17 -6
- data/vendor/snowball/algorithms/persian.sbl +387 -0
- data/vendor/snowball/algorithms/polish.sbl +177 -0
- data/vendor/snowball/algorithms/sesotho.sbl +115 -0
- data/vendor/snowball/algorithms/turkish.sbl +4 -4
- data/vendor/snowball/compiler/analyser.c +2002 -711
- data/vendor/snowball/compiler/driver.c +460 -298
- data/vendor/snowball/compiler/generator.c +439 -1965
- data/vendor/snowball/compiler/generator_ada.c +605 -430
- data/vendor/snowball/compiler/generator_c.c +2227 -0
- data/vendor/snowball/compiler/generator_csharp.c +365 -274
- data/vendor/snowball/compiler/generator_dart.c +1476 -0
- data/vendor/snowball/compiler/generator_go.c +348 -270
- data/vendor/snowball/compiler/generator_java.c +330 -233
- data/vendor/snowball/compiler/generator_js.c +534 -385
- data/vendor/snowball/compiler/generator_pascal.c +361 -320
- data/vendor/snowball/compiler/generator_php.c +1445 -0
- data/vendor/snowball/compiler/generator_python.c +399 -299
- data/vendor/snowball/compiler/generator_rust.c +370 -261
- data/vendor/snowball/compiler/generator_zig.c +1474 -0
- data/vendor/snowball/compiler/header.h +153 -86
- data/vendor/snowball/compiler/space.c +121 -63
- data/vendor/snowball/compiler/tokeniser.c +286 -182
- data/vendor/snowball/compiler/tokens.h +71 -0
- data/vendor/snowball/csharp/Snowball/Among.cs +14 -26
- data/vendor/snowball/csharp/Snowball/AssemblyInfo.cs +3 -3
- data/vendor/snowball/csharp/Snowball/Stemmer.cs +41 -45
- data/vendor/snowball/csharp/Stemwords/Program.cs +20 -14
- data/vendor/snowball/cxx/.gitignore +4 -0
- data/vendor/snowball/cxx/generate_algorithms.pl +87 -0
- data/vendor/snowball/cxx/stemmer.h +12 -0
- data/vendor/snowball/cxx/stemwords.cxx +176 -0
- data/vendor/snowball/cxx/utilities.cxx +2 -0
- data/vendor/snowball/dart/.gitignore +4 -0
- data/vendor/snowball/dart/analysis_options.yaml +1 -0
- data/vendor/snowball/dart/example/test_app.dart +65 -0
- data/vendor/snowball/dart/generate_algorithms.pl +21 -0
- data/vendor/snowball/dart/lib/snowball.dart +18 -0
- data/vendor/snowball/dart/lib/src/snowball.dart +339 -0
- data/vendor/snowball/dart/pubspec.yaml +17 -0
- data/vendor/snowball/doc/libstemmer_dart_README +37 -0
- data/vendor/snowball/doc/libstemmer_js_README +2 -2
- data/vendor/snowball/doc/libstemmer_php_README +38 -0
- data/vendor/snowball/doc/libstemmer_python_README +3 -3
- data/vendor/snowball/examples/stemwords.c +18 -3
- data/vendor/snowball/go/README.md +12 -4
- data/vendor/snowball/go/env.go +12 -14
- data/vendor/snowball/go/stemwords/main.go +2 -1
- data/vendor/snowball/java/org/tartarus/snowball/CharArraySequence.java +36 -0
- data/vendor/snowball/java/org/tartarus/snowball/SnowballProgram.java +17 -34
- data/vendor/snowball/java/org/tartarus/snowball/SnowballStemmer.java +0 -2
- data/vendor/snowball/javascript/base-stemmer.js +219 -252
- data/vendor/snowball/javascript/stemwords.js +86 -58
- data/vendor/snowball/libstemmer/mkmodules.pl +1 -1
- data/vendor/snowball/libstemmer/modules.txt +4 -0
- data/vendor/snowball/pascal/SnowballProgram.pas +18 -31
- data/vendor/snowball/php/base-stemmer.php +453 -0
- data/vendor/snowball/php/stemwords.php +25 -0
- data/vendor/snowball/python/create_init.py +16 -21
- data/vendor/snowball/python/pyproject.toml +3 -0
- data/vendor/snowball/python/setup.py +5 -7
- data/vendor/snowball/python/snowballstemmer/among.py +1 -2
- data/vendor/snowball/python/snowballstemmer/basestemmer.py +24 -33
- data/vendor/snowball/python/stemwords.py +72 -63
- data/vendor/snowball/runtime/api.c +11 -42
- data/vendor/snowball/runtime/api.h +11 -9
- data/vendor/snowball/runtime/snowball_runtime.h +110 -0
- data/vendor/snowball/runtime/utilities.c +282 -106
- data/vendor/snowball/rust/src/main.rs +2 -2
- data/vendor/snowball/rust/src/snowball/snowball_env.rs +7 -9
- data/vendor/snowball/tests/compilertest +62 -0
- data/vendor/snowball/tests/errors/ae-errors.sbl +53 -0
- data/vendor/snowball/tests/errors/ae-errors.stderr +8 -0
- data/vendor/snowball/tests/errors/bad-dollar.sbl +14 -0
- data/vendor/snowball/tests/errors/bad-dollar.stderr +4 -0
- data/vendor/snowball/tests/errors/bad-grouping-definition.sbl +9 -0
- data/vendor/snowball/tests/errors/bad-grouping-definition.stderr +6 -0
- data/vendor/snowball/tests/errors/missing-bra.sbl +6 -0
- data/vendor/snowball/tests/errors/missing-bra.stderr +3 -0
- data/vendor/snowball/tests/errors/missing-command.sbl +9 -0
- data/vendor/snowball/tests/errors/missing-command.stderr +1 -0
- data/vendor/snowball/tests/errors/missing-ket-backwardmode.sbl +3 -0
- data/vendor/snowball/tests/errors/missing-ket-backwardmode.stderr +1 -0
- data/vendor/snowball/tests/errors/missing-ket.sbl +7 -0
- data/vendor/snowball/tests/errors/missing-ket.stderr +6 -0
- data/vendor/snowball/tests/errors/notdefined.sbl +4 -0
- data/vendor/snowball/tests/errors/notdefined.stderr +2 -0
- data/vendor/snowball/tests/errors/string-omitted.sbl +5 -0
- data/vendor/snowball/tests/errors/string-omitted.stderr +1 -0
- data/vendor/snowball/tests/errors/undeclared.sbl +20 -0
- data/vendor/snowball/tests/errors/undeclared.stderr +9 -0
- data/vendor/snowball/tests/errors/unexpected-token.sbl +24 -0
- data/vendor/snowball/tests/errors/unexpected-token.stderr +17 -0
- data/vendor/snowball/tests/errors/wrongdirection.sbl +14 -0
- data/vendor/snowball/tests/errors/wrongdirection.stderr +1 -0
- data/vendor/snowball/tests/runtime/among.sbl +19 -0
- data/vendor/snowball/tests/runtime/arithmeticexpr.sbl +86 -0
- data/vendor/snowball/tests/runtime/attachinsert.sbl +47 -0
- data/vendor/snowball/tests/runtime/booleans.sbl +19 -0
- data/vendor/snowball/tests/runtime/externals.sbl +22 -0
- data/vendor/snowball/tests/runtime/hop.sbl +12 -0
- data/vendor/snowball/tests/runtime/integertests.sbl +60 -0
- data/vendor/snowball/tests/runtime/intlimits.sbl +25 -0
- data/vendor/snowball/tests/runtime/naming.sbl +20 -0
- data/vendor/snowball/tests/runtime/not.sbl +30 -0
- data/vendor/snowball/tests/runtime/or.sbl +17 -0
- data/vendor/snowball/tests/runtime/repeat.sbl +16 -0
- data/vendor/snowball/tests/runtime/setlimit.sbl +24 -0
- data/vendor/snowball/tests/runtime/sizelen.sbl +56 -0
- data/vendor/snowball/tests/runtime/slice.sbl +27 -0
- data/vendor/snowball/tests/runtime/stringdollar.sbl +39 -0
- data/vendor/snowball/tests/runtime/strings.sbl +66 -0
- data/vendor/snowball/tests/runtime/test.sbl +19 -0
- data/vendor/snowball/tests/stemtest.c +41 -1
- data/vendor/snowball/tests/syntax/canon.sbl +32 -0
- data/vendor/snowball/tests/syntax/canon.stderr +0 -0
- data/vendor/snowball/tests/syntax/canon.syntax +57 -0
- data/vendor/snowball/tests/syntax/emptyprogram.sbl +2 -0
- data/vendor/snowball/tests/syntax/emptyprogram.syntax +0 -0
- data/vendor/snowball/tests/syntax/groupings.sbl +11 -0
- data/vendor/snowball/tests/syntax/inline.sbl +144 -0
- data/vendor/snowball/tests/syntax/inline.stderr +0 -0
- data/vendor/snowball/tests/syntax/inline.syntax +121 -0
- data/vendor/snowball/tests/syntax/legacy.sbl +17 -0
- data/vendor/snowball/tests/syntax/legacy.stderr +5 -0
- data/vendor/snowball/tests/syntax/legacy.syntax +19 -0
- data/vendor/snowball/tests/syntax/loops.sbl +14 -0
- data/vendor/snowball/tests/syntax/loops.stderr +9 -0
- data/vendor/snowball/tests/syntax/loops.syntax +29 -0
- data/vendor/snowball/tests/syntax/noops.sbl +76 -0
- data/vendor/snowball/tests/syntax/noops.stderr +27 -0
- data/vendor/snowball/tests/syntax/noops.syntax +135 -0
- data/vendor/snowball/tests/syntax/simplifyae.sbl +21 -0
- data/vendor/snowball/tests/syntax/simplifyae.stderr +0 -0
- data/vendor/snowball/tests/syntax/simplifyae.syntax +39 -0
- data/vendor/snowball/tests/syntax/unused.sbl +18 -0
- data/vendor/snowball/tests/syntax/unused.stderr +7 -0
- data/vendor/snowball/tests/syntax/unused.syntax +3 -0
- data/vendor/snowball/zig/env.zig +599 -0
- data/vendor/snowball/zig/generate_algorithms.pl +19 -0
- data/vendor/snowball/zig/stemwords.zig +123 -0
- metadata +102 -4
- data/vendor/snowball/compiler/syswords.h +0 -86
- data/vendor/snowball/runtime/header.h +0 -62
|
@@ -36,18 +36,18 @@ package Stemmer with SPARK_Mode is
|
|
|
36
36
|
type Context_Type is abstract tagged private;
|
|
37
37
|
|
|
38
38
|
-- Apply the stemming algorithm on the word initialized in the context.
|
|
39
|
-
procedure Stem (
|
|
40
|
-
Result
|
|
39
|
+
procedure Stem (Z : in out Context_Type;
|
|
40
|
+
Result : out Boolean) is abstract;
|
|
41
41
|
|
|
42
42
|
-- Stem the word and return True if it was reduced.
|
|
43
|
-
procedure Stem_Word (
|
|
44
|
-
Word
|
|
45
|
-
Result
|
|
43
|
+
procedure Stem_Word (Z : in out Context_Type'Class;
|
|
44
|
+
Word : in String;
|
|
45
|
+
Result : out Boolean) with
|
|
46
46
|
Global => null,
|
|
47
47
|
Pre => Word'Length < WORD_MAX_LENGTH;
|
|
48
48
|
|
|
49
49
|
-- Get the stem or the input word unmodified.
|
|
50
|
-
function Get_Result (
|
|
50
|
+
function Get_Result (Z : in Context_Type'Class) return String with
|
|
51
51
|
Global => null,
|
|
52
52
|
Post => Get_Result'Result'Length < WORD_MAX_LENGTH;
|
|
53
53
|
|
|
@@ -82,19 +82,19 @@ private
|
|
|
82
82
|
|
|
83
83
|
type Among_Array_Type is array (Natural range <>) of Among_Type;
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
procedure Eq_S (Z : in out Context_Type'Class;
|
|
86
|
+
S : in String;
|
|
87
|
+
Len : in Char_Index;
|
|
88
|
+
Result : out Boolean) with
|
|
89
|
+
Global => null;
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
procedure Eq_S_Backward (Z : in out Context_Type'Class;
|
|
92
|
+
S : in String;
|
|
93
|
+
Len : in Char_Index;
|
|
94
|
+
Result : out Boolean) with
|
|
95
|
+
Global => null;
|
|
96
96
|
|
|
97
|
-
procedure Find_Among (
|
|
97
|
+
procedure Find_Among (Z : in out Context_Type'Class;
|
|
98
98
|
Amongs : in Among_Array_Type;
|
|
99
99
|
Pattern : in String;
|
|
100
100
|
Execute : access procedure
|
|
@@ -105,7 +105,7 @@ private
|
|
|
105
105
|
Global => null,
|
|
106
106
|
Pre => Pattern'Length > 0 and Amongs'Length > 0;
|
|
107
107
|
|
|
108
|
-
procedure Find_Among_Backward (
|
|
108
|
+
procedure Find_Among_Backward (Z : in out Context_Type'Class;
|
|
109
109
|
Amongs : in Among_Array_Type;
|
|
110
110
|
Pattern : in String;
|
|
111
111
|
Execute : access procedure
|
|
@@ -116,92 +116,89 @@ private
|
|
|
116
116
|
Global => null,
|
|
117
117
|
Pre => Pattern'Length > 0 and Amongs'Length > 0;
|
|
118
118
|
|
|
119
|
-
function Skip_Utf8 (
|
|
119
|
+
function Skip_Utf8 (Z : in Context_Type'Class) return Result_Index with
|
|
120
120
|
Global => null;
|
|
121
121
|
|
|
122
|
-
function Skip_Utf8 (
|
|
123
|
-
N
|
|
122
|
+
function Skip_Utf8 (Z : in Context_Type'Class;
|
|
123
|
+
N : in Integer) return Result_Index with
|
|
124
124
|
Global => null;
|
|
125
125
|
|
|
126
|
-
function Skip_Utf8_Backward (
|
|
126
|
+
function Skip_Utf8_Backward (Z : in Context_Type'Class) return Result_Index with
|
|
127
127
|
Global => null;
|
|
128
128
|
|
|
129
|
-
function Skip_Utf8_Backward (
|
|
130
|
-
N
|
|
129
|
+
function Skip_Utf8_Backward (Z : in Context_Type'Class;
|
|
130
|
+
N : in Integer) return Result_Index with
|
|
131
131
|
Global => null;
|
|
132
132
|
|
|
133
|
-
procedure Get_Utf8 (
|
|
134
|
-
Value
|
|
135
|
-
Count
|
|
136
|
-
|
|
137
|
-
procedure Get_Utf8_Backward (
|
|
138
|
-
Value
|
|
139
|
-
Count
|
|
140
|
-
|
|
141
|
-
function Length_Utf8 (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Adjustment : out Integer) with
|
|
133
|
+
procedure Get_Utf8 (Z : in Context_Type'Class;
|
|
134
|
+
Value : out Utf8_Type;
|
|
135
|
+
Count : out Natural);
|
|
136
|
+
|
|
137
|
+
procedure Get_Utf8_Backward (Z : in Context_Type'Class;
|
|
138
|
+
Value : out Utf8_Type;
|
|
139
|
+
Count : out Natural);
|
|
140
|
+
|
|
141
|
+
function Length_Utf8 (S : in String;
|
|
142
|
+
Len : in Char_Index) return Natural;
|
|
143
|
+
|
|
144
|
+
function Check_Among (Z : in Context_Type'Class;
|
|
145
|
+
Pos : in Char_Index;
|
|
146
|
+
Shift : in Natural;
|
|
147
|
+
Mask : in Mask_Type) return Boolean;
|
|
148
|
+
|
|
149
|
+
procedure Out_Grouping (Z : in out Context_Type'Class;
|
|
150
|
+
S : in Grouping_Array;
|
|
151
|
+
Min : in Utf8_Type;
|
|
152
|
+
Max : in Utf8_Type;
|
|
153
|
+
Repeat : in Boolean;
|
|
154
|
+
Result : out Result_Index);
|
|
155
|
+
|
|
156
|
+
procedure Out_Grouping_Backward (Z : in out Context_Type'Class;
|
|
157
|
+
S : in Grouping_Array;
|
|
158
|
+
Min : in Utf8_Type;
|
|
159
|
+
Max : in Utf8_Type;
|
|
160
|
+
Repeat : in Boolean;
|
|
161
|
+
Result : out Result_Index);
|
|
162
|
+
|
|
163
|
+
procedure In_Grouping (Z : in out Context_Type'Class;
|
|
164
|
+
S : in Grouping_Array;
|
|
165
|
+
Min : in Utf8_Type;
|
|
166
|
+
Max : in Utf8_Type;
|
|
167
|
+
Repeat : in Boolean;
|
|
168
|
+
Result : out Result_Index);
|
|
169
|
+
|
|
170
|
+
procedure In_Grouping_Backward (Z : in out Context_Type'Class;
|
|
171
|
+
S : in Grouping_Array;
|
|
172
|
+
Min : in Utf8_Type;
|
|
173
|
+
Max : in Utf8_Type;
|
|
174
|
+
Repeat : in Boolean;
|
|
175
|
+
Result : out Result_Index);
|
|
176
|
+
|
|
177
|
+
procedure Replace (Z : in out Context_Type'Class;
|
|
178
|
+
C_Bra : in Char_Index;
|
|
179
|
+
C_Ket : in Char_Index;
|
|
180
|
+
S : in String;
|
|
181
|
+
Len : in Char_Index) with
|
|
183
182
|
Global => null,
|
|
184
|
-
Pre => C_Ket
|
|
183
|
+
Pre => C_Bra <= C_Ket and C_Ket <= Z.Len
|
|
184
|
+
and Z.Len + Len - (C_Ket - C_Bra) < Z.P'Length;
|
|
185
185
|
|
|
186
|
-
procedure Slice_Del (
|
|
186
|
+
procedure Slice_Del (Z : in out Context_Type'Class) with
|
|
187
187
|
Global => null,
|
|
188
|
-
Pre =>
|
|
188
|
+
Pre => Z.Bra <= Z.Ket and Z.Ket <= Z.Len;
|
|
189
189
|
|
|
190
|
-
procedure Slice_From (
|
|
191
|
-
Text
|
|
190
|
+
procedure Slice_From (Z : in out Context_Type'Class;
|
|
191
|
+
Text : in String;
|
|
192
|
+
Len : in Char_Index) with
|
|
192
193
|
Global => null,
|
|
193
|
-
Pre =>
|
|
194
|
-
and Context.Len - (Context.Ket - Context.Bra) + Text'Length < Context.P'Length;
|
|
195
|
-
|
|
196
|
-
function Slice_To (Context : in Context_Type'Class) return String;
|
|
194
|
+
Pre => Z.Bra <= Z.Ket and Z.Ket <= Z.Len;
|
|
197
195
|
|
|
198
|
-
procedure Insert (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
S : in String) with
|
|
196
|
+
procedure Insert (Z : in out Context_Type'Class;
|
|
197
|
+
S : in String;
|
|
198
|
+
Len : in Char_Index) with
|
|
202
199
|
Global => null,
|
|
203
|
-
Pre =>
|
|
204
|
-
and
|
|
200
|
+
Pre => Z.C <= Z.Len
|
|
201
|
+
and Z.Len + Len < Z.P'Length;
|
|
205
202
|
|
|
206
203
|
-- The context indexes follow the C paradigm: they start at 0 for the first character.
|
|
207
204
|
-- This is necessary because several algorithms rely on this when they compare the
|
|
@@ -5,38 +5,54 @@ procedure Stemwords is
|
|
|
5
5
|
|
|
6
6
|
use Stemmer.Factory;
|
|
7
7
|
|
|
8
|
-
function Get_Language (Name : in String
|
|
8
|
+
function Get_Language (Name : in String;
|
|
9
|
+
Error: out Boolean) return Language_Type;
|
|
9
10
|
function Is_Space (C : in Character) return Boolean;
|
|
11
|
+
procedure Show_Usage;
|
|
10
12
|
|
|
11
13
|
function Is_Space (C : in Character) return Boolean is
|
|
12
14
|
begin
|
|
13
15
|
return C = ' ' or C = ASCII.HT;
|
|
14
16
|
end Is_Space;
|
|
15
17
|
|
|
16
|
-
function Get_Language (Name : in String
|
|
18
|
+
function Get_Language (Name : in String;
|
|
19
|
+
Error: out Boolean) return Language_Type is
|
|
17
20
|
begin
|
|
21
|
+
Error := False;
|
|
18
22
|
return Language_Type'Value ("L_" & Name);
|
|
19
23
|
|
|
20
24
|
exception
|
|
21
25
|
when Constraint_Error =>
|
|
22
26
|
Ada.Text_IO.Put_Line ("Unsupported language: " & Name);
|
|
23
|
-
|
|
27
|
+
Error := True;
|
|
28
|
+
return Language_Type'Val (0);
|
|
24
29
|
|
|
25
30
|
end Get_Language;
|
|
26
31
|
|
|
32
|
+
procedure Show_Usage is
|
|
33
|
+
begin
|
|
34
|
+
Ada.Text_IO.Put_Line ("Usage: stemwords <language> <input file> <output file>");
|
|
35
|
+
Ada.Command_Line.Set_Exit_Status(Ada.Command_Line.Failure);
|
|
36
|
+
end Show_Usage;
|
|
37
|
+
|
|
27
38
|
Count : constant Natural := Ada.Command_Line.Argument_Count;
|
|
28
39
|
begin
|
|
29
40
|
if Count /= 3 then
|
|
30
|
-
|
|
41
|
+
Show_Usage;
|
|
31
42
|
return;
|
|
32
43
|
end if;
|
|
33
44
|
declare
|
|
34
|
-
|
|
45
|
+
Bad_Usage : Boolean := False;
|
|
46
|
+
Lang : constant Language_Type := Get_Language (Ada.Command_Line.Argument (1), Bad_Usage);
|
|
35
47
|
Input : constant String := Ada.Command_Line.Argument (2);
|
|
36
48
|
Output : constant String := Ada.Command_Line.Argument (3);
|
|
37
49
|
Src_File : Ada.Text_IO.File_Type;
|
|
38
50
|
Dst_File : Ada.Text_IO.File_Type;
|
|
39
51
|
begin
|
|
52
|
+
if Bad_Usage then
|
|
53
|
+
Show_Usage;
|
|
54
|
+
return;
|
|
55
|
+
end if;
|
|
40
56
|
Ada.Text_IO.Open (Src_File, Ada.Text_IO.In_File, Input);
|
|
41
57
|
Ada.Text_IO.Create (Dst_File, Ada.Text_IO.Out_File, Output);
|
|
42
58
|
while not Ada.Text_IO.End_Of_File (Src_File) loop
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
routines (
|
|
2
|
+
R1
|
|
3
|
+
palatalise_e
|
|
4
|
+
palatalise_i
|
|
5
|
+
mark_regions
|
|
6
|
+
possessive_suffix
|
|
7
|
+
case_suffix
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
externals ( stem )
|
|
11
|
+
|
|
12
|
+
integers ( p1 x )
|
|
13
|
+
|
|
14
|
+
groupings ( env_ending ev_ending v v_or_syllabic_c )
|
|
15
|
+
|
|
16
|
+
stringescapes {}
|
|
17
|
+
|
|
18
|
+
stringdef a' '{U+00E1}' // á
|
|
19
|
+
stringdef cv '{U+010D}' // č
|
|
20
|
+
stringdef dv '{U+010F}' // ď
|
|
21
|
+
stringdef e' '{U+00E9}' // é
|
|
22
|
+
stringdef ev '{U+011B}' // ě
|
|
23
|
+
stringdef i' '{U+00ED}' // í
|
|
24
|
+
stringdef nv '{U+0148}' // ň
|
|
25
|
+
stringdef o' '{U+00F3}' // ó
|
|
26
|
+
stringdef rv '{U+0159}' // ř
|
|
27
|
+
stringdef sv '{U+0161}' // š
|
|
28
|
+
stringdef tv '{U+0165}' // ť
|
|
29
|
+
stringdef u' '{U+00FA}' // ú
|
|
30
|
+
stringdef uo '{U+016F}' // ů
|
|
31
|
+
stringdef y' '{U+00FD}' // ý
|
|
32
|
+
stringdef zv '{U+017E}' // ž
|
|
33
|
+
|
|
34
|
+
define v 'aeiouy{a'}{ev}{e'}{i'}{o'}{u'}{uo}{y'}'
|
|
35
|
+
|
|
36
|
+
// Some consonants in Czech can be syllabic - if these occur between two other
|
|
37
|
+
// consonants then they act in a vowel-like way and it is helpful to include
|
|
38
|
+
// them in the definition of R1.
|
|
39
|
+
//
|
|
40
|
+
// Some sources also list 'm' and 'n' as syllabic consonants for Czech but they
|
|
41
|
+
// seem to be much rarer and including them makes no difference to the results
|
|
42
|
+
// of stemming any words in our sample vocabulary list. Checking on a larger
|
|
43
|
+
// vocabulary list (also from wikipedia but with a lower cut-off frequency)
|
|
44
|
+
// all but one of the affected words don't seem to actually be Czech words.
|
|
45
|
+
define v_or_syllabic_c v + 'lr'
|
|
46
|
+
|
|
47
|
+
// Letters that can occur before -ev. Actual known exceptions include
|
|
48
|
+
// 'j' (objev, projev, výjev) and 'ř' (ohřev)
|
|
49
|
+
define ev_ending 'hknrtz'
|
|
50
|
+
|
|
51
|
+
// Letters that can occur before -eň. Actual known exceptions include
|
|
52
|
+
// 'g' (Irgeň), 'l' (zeleň), 'm' (kameň) and 'ř' (třeň).
|
|
53
|
+
define env_ending 'bc{cv}dhkprs{sv}tvz{zv}'
|
|
54
|
+
|
|
55
|
+
define mark_regions as (
|
|
56
|
+
|
|
57
|
+
test (hop 3 setmark x) // Signals f if the input < 3 characters.
|
|
58
|
+
|
|
59
|
+
$p1 = limit
|
|
60
|
+
do (
|
|
61
|
+
// A syllabic consonant must occur between two consonants, or be
|
|
62
|
+
// preceded by a consonant and at the end of the word.
|
|
63
|
+
//
|
|
64
|
+
// Instead of literally testing that, we handle the first character
|
|
65
|
+
// specially by only checking if it's a vowel; for subsequent
|
|
66
|
+
// characters we know that the character before is a consonant because
|
|
67
|
+
// otherwise we'd have stopped already.
|
|
68
|
+
//
|
|
69
|
+
// We also don't actually need to check the character after, since
|
|
70
|
+
// if it's a vowel then that vowel means we'd end up at the same
|
|
71
|
+
// position after `gopast non-v` anyway, and if it's the end of the
|
|
72
|
+
// word then there's no non-v after it.
|
|
73
|
+
(v or (next gopast v_or_syllabic_c)) gopast non-v
|
|
74
|
+
setmark p1
|
|
75
|
+
try($p1 < x $p1 = x) // at least 3
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
backwardmode (
|
|
80
|
+
|
|
81
|
+
define R1 as $p1 <= cursor
|
|
82
|
+
|
|
83
|
+
define palatalise_e as (
|
|
84
|
+
[substring] among (
|
|
85
|
+
// -c -> -k
|
|
86
|
+
'c'
|
|
87
|
+
(<- 'k')
|
|
88
|
+
'nc' // e.g. finance
|
|
89
|
+
'avc' // e.g. dravce
|
|
90
|
+
'ovc' // e.g. jalovce
|
|
91
|
+
()
|
|
92
|
+
'{i'}nc' // e.g. podmínce
|
|
93
|
+
(<- '{i'}nk')
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
define palatalise_i as (
|
|
98
|
+
[substring] among (
|
|
99
|
+
// -c -> -k
|
|
100
|
+
'c'
|
|
101
|
+
(<- 'k')
|
|
102
|
+
'nc' // e.g. financí
|
|
103
|
+
'avc' // e.g. nástavci
|
|
104
|
+
'ovc' // e.g. pískovci
|
|
105
|
+
()
|
|
106
|
+
'{i'}nc' // e.g. Gruzínci
|
|
107
|
+
(<- '{i'}nk')
|
|
108
|
+
|
|
109
|
+
'{cv}t' (<- 'ck')
|
|
110
|
+
|
|
111
|
+
// -št -> -sk
|
|
112
|
+
'{sv}t' // e.g. čeština
|
|
113
|
+
(<-'sk')
|
|
114
|
+
'{a'}{sv}t' // e.g. plášti
|
|
115
|
+
'de{sv}t' // e.g. dešti
|
|
116
|
+
'i{sv}t' // e.g. bojišti
|
|
117
|
+
'{i'}{sv}t' // e.g. příští
|
|
118
|
+
'le{sv}t' // e.g. kleští
|
|
119
|
+
'pou{sv}t' // e.g. poušti, spouští
|
|
120
|
+
()
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
define possessive_suffix as (
|
|
125
|
+
[substring] R1 among (
|
|
126
|
+
'ov' '{uo}v'
|
|
127
|
+
(delete)
|
|
128
|
+
'in'
|
|
129
|
+
(
|
|
130
|
+
delete
|
|
131
|
+
try palatalise_i
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
define case_suffix as (
|
|
137
|
+
setlimit tomark p1 for ( [substring] ) among (
|
|
138
|
+
'atech'
|
|
139
|
+
'at{uo}m'
|
|
140
|
+
'{a'}ch' '{y'}ch' 'ov{e'}' '{y'}mi'
|
|
141
|
+
'ata' 'aty' 'ama' 'ami' 'ovi'
|
|
142
|
+
'at' '{a'}m' 'us' '{uo}m' '{y'}m' 'mi' 'ou'
|
|
143
|
+
'{e'}ho' '{e'}m' '{e'}mu'
|
|
144
|
+
'u' 'y' '{uo}' 'a' 'o' '{a'}' '{e'}' '{y'}'
|
|
145
|
+
(delete)
|
|
146
|
+
'{ev}' '{ev}tem' '{ev}mi' '{ev}te' '{ev}ti'
|
|
147
|
+
'{ev}m' // e.g. koněm
|
|
148
|
+
(
|
|
149
|
+
delete
|
|
150
|
+
)
|
|
151
|
+
'e' 'ech' 'em' 'emi'
|
|
152
|
+
(
|
|
153
|
+
delete
|
|
154
|
+
try palatalise_e
|
|
155
|
+
)
|
|
156
|
+
'ete' 'eti' 'etem'
|
|
157
|
+
(
|
|
158
|
+
// t-stem neuter nouns
|
|
159
|
+
among (
|
|
160
|
+
'{cv}' // e.g. dvojč-etem
|
|
161
|
+
'l' // e.g. batol-ete
|
|
162
|
+
'{rv}' // e.g. zvíř-ete
|
|
163
|
+
's' // e.g. pras-ete
|
|
164
|
+
'{zv}' // e.g. páž-ete
|
|
165
|
+
(delete)
|
|
166
|
+
'e{cv}' // e.g. pečet-i
|
|
167
|
+
'tl' // e.g. atlet-i
|
|
168
|
+
'es' // e.g. deset-i
|
|
169
|
+
''
|
|
170
|
+
(
|
|
171
|
+
// Remove -e, -i, or -em; stem now ends -et so no palatalise
|
|
172
|
+
// step is needed.
|
|
173
|
+
<-'et'
|
|
174
|
+
)
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
'eb'
|
|
178
|
+
( // Conflate e.g. skladeb with skladba, skladbě, skladby, etc.
|
|
179
|
+
test non-v
|
|
180
|
+
not 't{rv}' // potřeb
|
|
181
|
+
<-'b'
|
|
182
|
+
)
|
|
183
|
+
'ec'
|
|
184
|
+
( // Conflate e.g. obec with obce, obcemi, obci, obcí, obcích.
|
|
185
|
+
test non-v
|
|
186
|
+
delete attach 'c'
|
|
187
|
+
try palatalise_e
|
|
188
|
+
)
|
|
189
|
+
'ek'
|
|
190
|
+
( // Conflate e.g. článek with článkem, článku, článků, článkům, články.
|
|
191
|
+
test non-v
|
|
192
|
+
not among (
|
|
193
|
+
'dot' // dotek
|
|
194
|
+
'obl' // oblek
|
|
195
|
+
'sn' // česnek
|
|
196
|
+
)
|
|
197
|
+
<-'k'
|
|
198
|
+
)
|
|
199
|
+
'{ev}k'
|
|
200
|
+
( // Conflate e.g. daněk with daňka, daňkem, daňki, daňkovi, daňků, etc.
|
|
201
|
+
'n'] <-'{nv}k'
|
|
202
|
+
)
|
|
203
|
+
'e{nv}'
|
|
204
|
+
( // Conflate e.g. Plzeň with Plzně, Plzni, Plzní.
|
|
205
|
+
test env_ending
|
|
206
|
+
<-'n' // -eň -> -n not -ň
|
|
207
|
+
)
|
|
208
|
+
// -eš can also lose the -e- but this seems very uncommon - the only
|
|
209
|
+
// example I've seen is Aleš (a male given name or diminutive name)
|
|
210
|
+
// but we require 3 characters before R1 so this won't be considered
|
|
211
|
+
// for stemming.
|
|
212
|
+
//
|
|
213
|
+
// Also this can decline as Alše or Aleše, etc, and these alternative
|
|
214
|
+
// declensions mean that just removing the -e- from Aleš would not
|
|
215
|
+
// really help (especially as the forms which keep the -e- seem
|
|
216
|
+
// more common, at least based on cs.wikipedia.org) so if we did this
|
|
217
|
+
// we would need to also remove -e- from Aleše, etc, which seems a lot
|
|
218
|
+
// of complication for a single word.
|
|
219
|
+
'et'
|
|
220
|
+
( // Conflate e.g. počet with počte, počtu, počty, etc.
|
|
221
|
+
among (
|
|
222
|
+
'uc' // e.g. tucet but not dvacet.
|
|
223
|
+
'{cv}'
|
|
224
|
+
'h'
|
|
225
|
+
'ok' // e.g. loket but not paket.
|
|
226
|
+
'kar' // e.g. karet but not cigaret.
|
|
227
|
+
)
|
|
228
|
+
<-'t'
|
|
229
|
+
)
|
|
230
|
+
'ev'
|
|
231
|
+
( // Conflate e.g. církev with církve, církve, církvemu, církví, etc.
|
|
232
|
+
ev_ending
|
|
233
|
+
<-'v'
|
|
234
|
+
)
|
|
235
|
+
'{tv}' '{tv}mi'
|
|
236
|
+
( // Conflate e.g. oběť and oběťmi with obětech; hradišť with hradišti.
|
|
237
|
+
<-'t'
|
|
238
|
+
)
|
|
239
|
+
'i'
|
|
240
|
+
'{i'}' '{i'}ch' '{i'}ho' '{i'}m' '{i'}mi' '{i'}mu'
|
|
241
|
+
(
|
|
242
|
+
delete
|
|
243
|
+
try palatalise_i
|
|
244
|
+
)
|
|
245
|
+
)
|
|
246
|
+
)
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
define stem as (
|
|
250
|
+
mark_regions // Signals f if the input has < 3 characters.
|
|
251
|
+
backwards (
|
|
252
|
+
do case_suffix
|
|
253
|
+
do possessive_suffix
|
|
254
|
+
)
|
|
255
|
+
)
|
|
@@ -10,9 +10,9 @@ externals ( stem )
|
|
|
10
10
|
|
|
11
11
|
strings ( ch )
|
|
12
12
|
|
|
13
|
-
integers ( p1
|
|
13
|
+
integers ( p1 )
|
|
14
14
|
|
|
15
|
-
groupings (
|
|
15
|
+
groupings ( undouble_c v s_ending )
|
|
16
16
|
|
|
17
17
|
stringescapes {}
|
|
18
18
|
|
|
@@ -22,19 +22,29 @@ stringdef ae '{U+00E6}'
|
|
|
22
22
|
stringdef ao '{U+00E5}'
|
|
23
23
|
stringdef o/ '{U+00F8}'
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// Consonants which get undoubled by routine `undouble`.
|
|
26
|
+
define undouble_c 'bdfgklmnprst'
|
|
26
27
|
|
|
27
28
|
define v 'aeiouy{ae}{ao}{o/}'
|
|
28
29
|
|
|
29
|
-
define s_ending 'abcdfghjklmnoprtvyz{ao}'
|
|
30
|
+
define s_ending 'abcdfghjklmnoprtvyz{ao}{'}'
|
|
30
31
|
|
|
31
32
|
define mark_regions as (
|
|
32
|
-
|
|
33
33
|
$p1 = limit
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
do (
|
|
36
|
+
(
|
|
37
|
+
// If there's an apostrophe, start R1 after it to handle
|
|
38
|
+
// acronym loanwords such as "pc'en" and "ep'en".
|
|
39
|
+
gopast '{'}'
|
|
40
|
+
) or (
|
|
41
|
+
gopast v gopast non-v
|
|
42
|
+
)
|
|
43
|
+
setmark p1
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
// Ensure at least 3 characters before R1.
|
|
47
|
+
test (hop 3 do ($p1 < cursor $p1 = cursor))
|
|
38
48
|
)
|
|
39
49
|
|
|
40
50
|
backwardmode (
|
|
@@ -75,7 +85,7 @@ backwardmode (
|
|
|
75
85
|
)
|
|
76
86
|
)
|
|
77
87
|
define undouble as (
|
|
78
|
-
setlimit tomark p1 for ([
|
|
88
|
+
setlimit tomark p1 for ([undouble_c] ->ch)
|
|
79
89
|
ch
|
|
80
90
|
delete
|
|
81
91
|
)
|
|
@@ -83,11 +93,13 @@ backwardmode (
|
|
|
83
93
|
|
|
84
94
|
define stem as (
|
|
85
95
|
|
|
86
|
-
|
|
96
|
+
mark_regions
|
|
87
97
|
backwards (
|
|
88
98
|
do main_suffix
|
|
89
99
|
do consonant_pair
|
|
90
100
|
do other_suffix
|
|
91
101
|
do undouble
|
|
102
|
+
// Remove trailing apostrophe.
|
|
103
|
+
['{'}'] delete
|
|
92
104
|
)
|
|
93
105
|
)
|
|
@@ -42,6 +42,7 @@ define mark_regions as (
|
|
|
42
42
|
'later' // lateral/later
|
|
43
43
|
'emerg' // emerge/emergency
|
|
44
44
|
'organ' // organ/organic/organize
|
|
45
|
+
'inter' // intern/internal/international/internment; interfere; interval
|
|
45
46
|
// ... extensions possible here ...
|
|
46
47
|
) or (gopast v gopast non-v)
|
|
47
48
|
setmark p1
|
|
@@ -83,11 +84,12 @@ backwardmode (
|
|
|
83
84
|
'eed' 'eedly'
|
|
84
85
|
(
|
|
85
86
|
do (
|
|
87
|
+
R1
|
|
86
88
|
among (
|
|
87
89
|
'proc' 'exc' 'succ'
|
|
88
90
|
(atlimit)
|
|
89
91
|
) or (
|
|
90
|
-
|
|
92
|
+
<-'ee'
|
|
91
93
|
)
|
|
92
94
|
)
|
|
93
95
|
)
|
|
@@ -99,7 +101,7 @@ backwardmode (
|
|
|
99
101
|
// dying->die, lying->die, tying->tie, vying->vie
|
|
100
102
|
'y'
|
|
101
103
|
(test(non-v atlimit) ] <-'ie')
|
|
102
|
-
// Leave inning, outing, etc
|
|
104
|
+
// Leave inning, outing, etc alone.
|
|
103
105
|
'inn' 'out' 'cann' 'herr' 'earr' 'even'
|
|
104
106
|
(atlimit)
|
|
105
107
|
)
|
|
@@ -158,8 +160,8 @@ backwardmode (
|
|
|
158
160
|
|
|
159
161
|
define Step_3 as (
|
|
160
162
|
[substring] R1 among (
|
|
161
|
-
'tional' (<-
|
|
162
|
-
'ational' (<-
|
|
163
|
+
'tional' (<-'tion')
|
|
164
|
+
'ational' (<-'ate')
|
|
163
165
|
'alize' (<-'al')
|
|
164
166
|
'icate' 'iciti' 'ical'
|
|
165
167
|
(<-'ic')
|
|
@@ -193,6 +195,7 @@ define exception1 as (
|
|
|
193
195
|
|
|
194
196
|
/* special changes: */
|
|
195
197
|
|
|
198
|
+
'skis' (<-'ski')
|
|
196
199
|
'skies' (<-'sky')
|
|
197
200
|
|
|
198
201
|
/* special -LY cases */
|