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.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +2 -1
  4. data/README.md +2 -2
  5. data/Rakefile +12 -5
  6. data/ext/mittens/extconf.rb +3 -1
  7. data/lib/mittens/version.rb +1 -1
  8. data/vendor/snowball/.github/workflows/ci.yml +144 -17
  9. data/vendor/snowball/.github/workflows/coverage.yml +117 -0
  10. data/vendor/snowball/.github/workflows/runtime-tests.yml +26 -0
  11. data/vendor/snowball/.gitignore +33 -7
  12. data/vendor/snowball/CONTRIBUTING.rst +7 -0
  13. data/vendor/snowball/COPYING +1 -1
  14. data/vendor/snowball/GNUmakefile +736 -298
  15. data/vendor/snowball/NEWS +1394 -7
  16. data/vendor/snowball/README.rst +8 -8
  17. data/vendor/snowball/ada/generate/generate.adb +5 -5
  18. data/vendor/snowball/ada/src/stemmer.adb +177 -188
  19. data/vendor/snowball/ada/src/stemmer.ads +86 -89
  20. data/vendor/snowball/ada/src/stemwords.adb +21 -5
  21. data/vendor/snowball/algorithms/czech.sbl +255 -0
  22. data/vendor/snowball/algorithms/danish.sbl +22 -10
  23. data/vendor/snowball/algorithms/english.sbl +7 -4
  24. data/vendor/snowball/algorithms/esperanto.sbl +6 -7
  25. data/vendor/snowball/algorithms/estonian.sbl +9 -4
  26. data/vendor/snowball/algorithms/finnish.sbl +33 -21
  27. data/vendor/snowball/algorithms/german.sbl +5 -0
  28. data/vendor/snowball/algorithms/indonesian.sbl +115 -96
  29. data/vendor/snowball/algorithms/italian.sbl +26 -1
  30. data/vendor/snowball/algorithms/lithuanian.sbl +13 -13
  31. data/vendor/snowball/algorithms/norwegian.sbl +17 -6
  32. data/vendor/snowball/algorithms/persian.sbl +387 -0
  33. data/vendor/snowball/algorithms/polish.sbl +177 -0
  34. data/vendor/snowball/algorithms/sesotho.sbl +115 -0
  35. data/vendor/snowball/algorithms/turkish.sbl +4 -4
  36. data/vendor/snowball/compiler/analyser.c +2002 -711
  37. data/vendor/snowball/compiler/driver.c +460 -298
  38. data/vendor/snowball/compiler/generator.c +439 -1965
  39. data/vendor/snowball/compiler/generator_ada.c +605 -430
  40. data/vendor/snowball/compiler/generator_c.c +2227 -0
  41. data/vendor/snowball/compiler/generator_csharp.c +365 -274
  42. data/vendor/snowball/compiler/generator_dart.c +1476 -0
  43. data/vendor/snowball/compiler/generator_go.c +348 -270
  44. data/vendor/snowball/compiler/generator_java.c +330 -233
  45. data/vendor/snowball/compiler/generator_js.c +534 -385
  46. data/vendor/snowball/compiler/generator_pascal.c +361 -320
  47. data/vendor/snowball/compiler/generator_php.c +1445 -0
  48. data/vendor/snowball/compiler/generator_python.c +399 -299
  49. data/vendor/snowball/compiler/generator_rust.c +370 -261
  50. data/vendor/snowball/compiler/generator_zig.c +1474 -0
  51. data/vendor/snowball/compiler/header.h +153 -86
  52. data/vendor/snowball/compiler/space.c +121 -63
  53. data/vendor/snowball/compiler/tokeniser.c +286 -182
  54. data/vendor/snowball/compiler/tokens.h +71 -0
  55. data/vendor/snowball/csharp/Snowball/Among.cs +14 -26
  56. data/vendor/snowball/csharp/Snowball/AssemblyInfo.cs +3 -3
  57. data/vendor/snowball/csharp/Snowball/Stemmer.cs +41 -45
  58. data/vendor/snowball/csharp/Stemwords/Program.cs +20 -14
  59. data/vendor/snowball/cxx/.gitignore +4 -0
  60. data/vendor/snowball/cxx/generate_algorithms.pl +87 -0
  61. data/vendor/snowball/cxx/stemmer.h +12 -0
  62. data/vendor/snowball/cxx/stemwords.cxx +176 -0
  63. data/vendor/snowball/cxx/utilities.cxx +2 -0
  64. data/vendor/snowball/dart/.gitignore +4 -0
  65. data/vendor/snowball/dart/analysis_options.yaml +1 -0
  66. data/vendor/snowball/dart/example/test_app.dart +65 -0
  67. data/vendor/snowball/dart/generate_algorithms.pl +21 -0
  68. data/vendor/snowball/dart/lib/snowball.dart +18 -0
  69. data/vendor/snowball/dart/lib/src/snowball.dart +339 -0
  70. data/vendor/snowball/dart/pubspec.yaml +17 -0
  71. data/vendor/snowball/doc/libstemmer_dart_README +37 -0
  72. data/vendor/snowball/doc/libstemmer_js_README +2 -2
  73. data/vendor/snowball/doc/libstemmer_php_README +38 -0
  74. data/vendor/snowball/doc/libstemmer_python_README +3 -3
  75. data/vendor/snowball/examples/stemwords.c +18 -3
  76. data/vendor/snowball/go/README.md +12 -4
  77. data/vendor/snowball/go/env.go +12 -14
  78. data/vendor/snowball/go/stemwords/main.go +2 -1
  79. data/vendor/snowball/java/org/tartarus/snowball/CharArraySequence.java +36 -0
  80. data/vendor/snowball/java/org/tartarus/snowball/SnowballProgram.java +17 -34
  81. data/vendor/snowball/java/org/tartarus/snowball/SnowballStemmer.java +0 -2
  82. data/vendor/snowball/javascript/base-stemmer.js +219 -252
  83. data/vendor/snowball/javascript/stemwords.js +86 -58
  84. data/vendor/snowball/libstemmer/mkmodules.pl +1 -1
  85. data/vendor/snowball/libstemmer/modules.txt +4 -0
  86. data/vendor/snowball/pascal/SnowballProgram.pas +18 -31
  87. data/vendor/snowball/php/base-stemmer.php +453 -0
  88. data/vendor/snowball/php/stemwords.php +25 -0
  89. data/vendor/snowball/python/create_init.py +16 -21
  90. data/vendor/snowball/python/pyproject.toml +3 -0
  91. data/vendor/snowball/python/setup.py +5 -7
  92. data/vendor/snowball/python/snowballstemmer/among.py +1 -2
  93. data/vendor/snowball/python/snowballstemmer/basestemmer.py +24 -33
  94. data/vendor/snowball/python/stemwords.py +72 -63
  95. data/vendor/snowball/runtime/api.c +11 -42
  96. data/vendor/snowball/runtime/api.h +11 -9
  97. data/vendor/snowball/runtime/snowball_runtime.h +110 -0
  98. data/vendor/snowball/runtime/utilities.c +282 -106
  99. data/vendor/snowball/rust/src/main.rs +2 -2
  100. data/vendor/snowball/rust/src/snowball/snowball_env.rs +7 -9
  101. data/vendor/snowball/tests/compilertest +62 -0
  102. data/vendor/snowball/tests/errors/ae-errors.sbl +53 -0
  103. data/vendor/snowball/tests/errors/ae-errors.stderr +8 -0
  104. data/vendor/snowball/tests/errors/bad-dollar.sbl +14 -0
  105. data/vendor/snowball/tests/errors/bad-dollar.stderr +4 -0
  106. data/vendor/snowball/tests/errors/bad-grouping-definition.sbl +9 -0
  107. data/vendor/snowball/tests/errors/bad-grouping-definition.stderr +6 -0
  108. data/vendor/snowball/tests/errors/missing-bra.sbl +6 -0
  109. data/vendor/snowball/tests/errors/missing-bra.stderr +3 -0
  110. data/vendor/snowball/tests/errors/missing-command.sbl +9 -0
  111. data/vendor/snowball/tests/errors/missing-command.stderr +1 -0
  112. data/vendor/snowball/tests/errors/missing-ket-backwardmode.sbl +3 -0
  113. data/vendor/snowball/tests/errors/missing-ket-backwardmode.stderr +1 -0
  114. data/vendor/snowball/tests/errors/missing-ket.sbl +7 -0
  115. data/vendor/snowball/tests/errors/missing-ket.stderr +6 -0
  116. data/vendor/snowball/tests/errors/notdefined.sbl +4 -0
  117. data/vendor/snowball/tests/errors/notdefined.stderr +2 -0
  118. data/vendor/snowball/tests/errors/string-omitted.sbl +5 -0
  119. data/vendor/snowball/tests/errors/string-omitted.stderr +1 -0
  120. data/vendor/snowball/tests/errors/undeclared.sbl +20 -0
  121. data/vendor/snowball/tests/errors/undeclared.stderr +9 -0
  122. data/vendor/snowball/tests/errors/unexpected-token.sbl +24 -0
  123. data/vendor/snowball/tests/errors/unexpected-token.stderr +17 -0
  124. data/vendor/snowball/tests/errors/wrongdirection.sbl +14 -0
  125. data/vendor/snowball/tests/errors/wrongdirection.stderr +1 -0
  126. data/vendor/snowball/tests/runtime/among.sbl +19 -0
  127. data/vendor/snowball/tests/runtime/arithmeticexpr.sbl +86 -0
  128. data/vendor/snowball/tests/runtime/attachinsert.sbl +47 -0
  129. data/vendor/snowball/tests/runtime/booleans.sbl +19 -0
  130. data/vendor/snowball/tests/runtime/externals.sbl +22 -0
  131. data/vendor/snowball/tests/runtime/hop.sbl +12 -0
  132. data/vendor/snowball/tests/runtime/integertests.sbl +60 -0
  133. data/vendor/snowball/tests/runtime/intlimits.sbl +25 -0
  134. data/vendor/snowball/tests/runtime/naming.sbl +20 -0
  135. data/vendor/snowball/tests/runtime/not.sbl +30 -0
  136. data/vendor/snowball/tests/runtime/or.sbl +17 -0
  137. data/vendor/snowball/tests/runtime/repeat.sbl +16 -0
  138. data/vendor/snowball/tests/runtime/setlimit.sbl +24 -0
  139. data/vendor/snowball/tests/runtime/sizelen.sbl +56 -0
  140. data/vendor/snowball/tests/runtime/slice.sbl +27 -0
  141. data/vendor/snowball/tests/runtime/stringdollar.sbl +39 -0
  142. data/vendor/snowball/tests/runtime/strings.sbl +66 -0
  143. data/vendor/snowball/tests/runtime/test.sbl +19 -0
  144. data/vendor/snowball/tests/stemtest.c +41 -1
  145. data/vendor/snowball/tests/syntax/canon.sbl +32 -0
  146. data/vendor/snowball/tests/syntax/canon.stderr +0 -0
  147. data/vendor/snowball/tests/syntax/canon.syntax +57 -0
  148. data/vendor/snowball/tests/syntax/emptyprogram.sbl +2 -0
  149. data/vendor/snowball/tests/syntax/emptyprogram.syntax +0 -0
  150. data/vendor/snowball/tests/syntax/groupings.sbl +11 -0
  151. data/vendor/snowball/tests/syntax/inline.sbl +144 -0
  152. data/vendor/snowball/tests/syntax/inline.stderr +0 -0
  153. data/vendor/snowball/tests/syntax/inline.syntax +121 -0
  154. data/vendor/snowball/tests/syntax/legacy.sbl +17 -0
  155. data/vendor/snowball/tests/syntax/legacy.stderr +5 -0
  156. data/vendor/snowball/tests/syntax/legacy.syntax +19 -0
  157. data/vendor/snowball/tests/syntax/loops.sbl +14 -0
  158. data/vendor/snowball/tests/syntax/loops.stderr +9 -0
  159. data/vendor/snowball/tests/syntax/loops.syntax +29 -0
  160. data/vendor/snowball/tests/syntax/noops.sbl +76 -0
  161. data/vendor/snowball/tests/syntax/noops.stderr +27 -0
  162. data/vendor/snowball/tests/syntax/noops.syntax +135 -0
  163. data/vendor/snowball/tests/syntax/simplifyae.sbl +21 -0
  164. data/vendor/snowball/tests/syntax/simplifyae.stderr +0 -0
  165. data/vendor/snowball/tests/syntax/simplifyae.syntax +39 -0
  166. data/vendor/snowball/tests/syntax/unused.sbl +18 -0
  167. data/vendor/snowball/tests/syntax/unused.stderr +7 -0
  168. data/vendor/snowball/tests/syntax/unused.syntax +3 -0
  169. data/vendor/snowball/zig/env.zig +599 -0
  170. data/vendor/snowball/zig/generate_algorithms.pl +19 -0
  171. data/vendor/snowball/zig/stemwords.zig +123 -0
  172. metadata +102 -4
  173. data/vendor/snowball/compiler/syswords.h +0 -86
  174. data/vendor/snowball/runtime/header.h +0 -62
@@ -0,0 +1,24 @@
1
+ // Test setlimit
2
+ externals (stem)
3
+ routines (setlimit_tomark)
4
+
5
+ define stem as (
6
+ setlimit_tomark
7
+ ='ok'
8
+ )
9
+
10
+ define setlimit_tomark as (
11
+ // Regression test for bug fixed in 3.1.0.
12
+ test (
13
+ ='abcd'
14
+ next
15
+ // Forwards `setlimit tomark` restored limit incorrectly.
16
+ setlimit tomark 3 for $(limit == 3) or fail='setlimit tomark set wrong limit'
17
+ $(cursor == 1) or fail='cursor changed after setlimit tomark'
18
+ $(limit == 4) or fail='limit not restored after setlimit tomark'
19
+ // Make sure restoring of limit copes with setting the limit to itself!
20
+ setlimit tomark limit for $(limit == 4) or fail='setlimit tomark limit set wrong limit'
21
+ $(cursor == 1) or fail='cursor changed after setlimit tomark'
22
+ $(limit == 4) or fail='limit not restored after setlimit tomark'
23
+ )
24
+ )
@@ -0,0 +1,56 @@
1
+ // Test len/lenof/size/sizeof.
2
+
3
+ externals (stem)
4
+
5
+ integers (expected_size)
6
+
7
+ strings (s)
8
+
9
+ stringescapes {}
10
+
11
+ define stem as (
12
+ = ''
13
+ $(len == 0) or fail='len empty incorrect'
14
+ $(size == 0) or fail='size empty incorrect'
15
+ = 'test'
16
+ $(len == 4) or fail='len incorrect'
17
+ $(size == 4) or fail='size incorrect'
18
+
19
+ $(lenof '' == 0) or fail='lenof empty literal incorrect'
20
+ $(sizeof '' == 0) or fail='sizeof empty literal incorrect'
21
+ $(lenof 'test' == 4) or fail='lenof literal incorrect'
22
+ $(sizeof 'test' == 4) or fail='sizeof literal incorrect'
23
+
24
+ $s = ''
25
+ $(lenof s == 0) or fail='lenof empty string variable incorrect'
26
+ $(sizeof s == 0) or fail='sizeof empty string variable incorrect'
27
+ $s = 'test'
28
+ $(lenof s == 4) or fail='lenof string variable incorrect'
29
+ $(sizeof s == 4) or fail='sizeof string variable incorrect'
30
+
31
+ // Probe if character representation is UTF-8.
32
+ (
33
+ // UTF-8.
34
+ $(sizeof '{U+00A0}' == 2) $expected_size = 8
35
+ ) or (
36
+ $(sizeof '{U+00A0}' == 1) $expected_size = 7
37
+ ) or fail='sizeof U+00A0 unexpected'
38
+
39
+ = '{U+00E9}preuve'
40
+ $(len == 7) or fail='Unicode len incorrect'
41
+
42
+ $(lenof '{U+00E9}preuve' == 7) or fail='Unicode lenof literal incorrect'
43
+
44
+ $s = '{U+00E9}preuve'
45
+ $(lenof s == 7) or fail='Unicode lenof string variable incorrect'
46
+
47
+ = '{U+00E9}preuve'
48
+ $(size == expected_size) or fail='Unicode size incorrect'
49
+
50
+ $(sizeof '{U+00E9}preuve' == expected_size) or fail='Unicode sizeof literal incorrect'
51
+
52
+ $s = '{U+00E9}preuve'
53
+ $(sizeof s == expected_size) or fail='Unicode sizeof string variable incorrect'
54
+
55
+ ='ok'
56
+ )
@@ -0,0 +1,27 @@
1
+ // Test slice-related operations.
2
+
3
+ externals (stem)
4
+
5
+ strings (s)
6
+
7
+ stringescapes {}
8
+
9
+ define stem as (
10
+ test ([ tolimit ] <-'abcd') $(size == 4) or fail='<- replacement did not work as expected'
11
+ test ([ tolimit ] <-'ok') $(size == 2) or fail='<- replacement did not work as expected (2)'
12
+
13
+ test ([ tolimit ] <-'abcd' $(cursor == 4)) or fail='<- replacement did not adjust cursor as expected'
14
+ test ([ tolimit ] <-'ok' $(cursor == 2)) or fail='<- replacement did not adjust cursor as expected (2)'
15
+
16
+ test ([ tolimit ]) <-'abcd' $(cursor == 0) or fail='<- replacement did not adjust cursor as expected (3)'
17
+ test ([ tolimit ]) <-'ok' $(cursor == 0) or fail='<- replacement did not adjust cursor as expected (4)'
18
+
19
+ test ([ next ] delete <-'boo') test ('book' atlimit) or fail='delete did not adjust slice as expected'
20
+ test ([ next ] <-'ch' <-'outl') test ('outlook' atlimit) or fail='<- did not adjust slice as expected'
21
+ test (='abc' [ next ] ->s delete <-s) test ('abc' atlimit) or fail='stored slice did not survive later mutation'
22
+
23
+ // Regression test for https://github.com/snowballstem/snowball/issues/242
24
+ [] ->s $(sizeof s == 0) or fail='-> on empty slice was not empty'
25
+
26
+ ='ok'
27
+ )
@@ -0,0 +1,39 @@
1
+ // Test string-$.
2
+
3
+ externals (stem)
4
+
5
+ strings (s s2)
6
+
7
+ stringescapes {}
8
+
9
+ define stem as (
10
+ $s=''
11
+ $(lenof s == 0) or fail='setting s empty failed'
12
+
13
+ $s='xyz'
14
+ $(lenof s == 3) or fail='setting s failed'
15
+ test ('ok' atlimit) or fail='setting s changed current string'
16
+
17
+ test (next $s hop 2 $(cursor == 1)) or fail='cursor not restored after string-$'
18
+ test (next $s hop 2 $(limit == 2)) or fail='limit not restored after string-$'
19
+
20
+ test (next $s $(cursor == 0)) or fail='cursor not zeroed inside string-$'
21
+ test (next $s $(limit == 3)) or fail='limit not reset inside string-$'
22
+
23
+ // Test things are reset on failure (regression test for Dart, Go, Rust).
24
+ (not $s fail ='news' test ('ok' atlimit)) or fail='current string not restored after failing string-$'
25
+ test (next not $s fail (='news' next) $(cursor == 1)) or fail='cursor not restored after failing string-$'
26
+ (not $s fail (='news' next) $(limit == 2)) or fail='limit not restored after failing string-$'
27
+
28
+ // Test things are reset on failure with nested use (regression test for
29
+ // everything, though for C the only problem was -Wshadow warnings).
30
+ (not $s2 $s fail ='news' test ('ok' atlimit)) or fail='current string not restored after failing string-$'
31
+ test (next not $s2 $s fail (='news' next) $(cursor == 1)) or fail='cursor not restored after failing string-$'
32
+ (not $s2 $s fail (='news' next) $(limit == 2)) or fail='limit not restored after failing string-$'
33
+ (not $s2 $s (='news' $(cursor == 99)) test ('ok' atlimit)) or fail='current string not restored after failing string-$'
34
+ test (next not $s2 $s (='news' next $(cursor == 99)) $(cursor == 1)) or fail='cursor not restored after failing string-$'
35
+ (not $s2 $s (='news' next $(cursor == 99)) $(limit == 2)) or fail='limit not restored after failing string-$'
36
+
37
+ // Test successful nested use.
38
+ $s2 (='x' $s='y') or fail='nested string-$ failed'
39
+ )
@@ -0,0 +1,66 @@
1
+ // Test strings
2
+
3
+ externals (stem)
4
+
5
+ strings (s)
6
+
7
+ define stem as (
8
+ '' or fail='failed to match empty string'
9
+ test 'o' or fail='failed to match 1-char string'
10
+ test ('o' $(cursor == 1)) or fail='failed to update cursor after 1-char string match'
11
+ test 'ok' or fail='failed to match string'
12
+ test ('ok' $(cursor == 2)) or fail='failed to update cursor after string match'
13
+ test ('ok' $(cursor == 2) atlimit) or fail='atlimit failed after string match'
14
+ not 'x' or fail='incorrectly matched single character string'
15
+ not 'ko' or fail='incorrectly matched string'
16
+ $(cursor == 0) or fail='cursor not restored after string literal tests'
17
+
18
+ $s=''
19
+ s or fail='failed to match empty string var'
20
+ $s='o'
21
+ test s or fail='failed to match 1-char string var'
22
+ test (s $(cursor == 1)) or fail='failed to update cursor after 1-char string var match'
23
+ $s='ok'
24
+ test s or fail='failed to match string var'
25
+ test (s $(cursor == 2)) or fail='failed to update cursor after string var match'
26
+ test (s $(cursor == 2) atlimit) or fail='atlimit failed after string var match'
27
+ $s='x' not s or fail='incorrectly matched single character string var'
28
+ $s='ko' not s or fail='incorrectly matched string var'
29
+
30
+ do (
31
+ ='test'
32
+ )
33
+ $(cursor == 0) or fail='cursor not restored by do'
34
+
35
+ backwards (
36
+ do (
37
+ ='test'
38
+ )
39
+ $(cursor == size) or fail='cursor not restored by do'
40
+ )
41
+
42
+ ='abcde'
43
+ test ( $(len == 5) $(cursor == 0) 'abcde' atlimit ) or fail='string assignment wrong'
44
+
45
+ setlimit hop 4 for test (next ='nkl')
46
+ test ( $(len == 5) $(cursor == 0) 'ankle' atlimit ) or fail='string assignment does not replace c:l (same len)'
47
+
48
+ setlimit hop 4 for test (next ='x')
49
+ test ( $(len == 3) $(cursor == 0) 'axe' atlimit ) or fail='string assignment does not replace c:l (shorter)'
50
+
51
+ setlimit hop 2 for test (next ='ustralopithecin')
52
+ test ( $(len == 17) $(cursor == 0) 'australopithecine' atlimit ) or fail='string assignment does not replace c:l (longer)'
53
+
54
+ // Test string literals are properly escaped for various target languages.
55
+ $s='$xxx \x42 \u0042 \u{0042} \u000a {$xxx}' $(lenof s == 39) or fail='bad target language string literal escaping'
56
+
57
+ // Test ASCII control characters in string literals
58
+ stringescapes {}
59
+ $s='{U+A}{U+1F}{U+7F}{U+0}x' $(lenof s == 5) or fail='ASCII control characters not handled'
60
+ $s='a{U+80}{U+A0}b{U+00FF}' $(lenof s == 5) or fail='Unicode characters not handled'
61
+
62
+ // Test that using a C close-comment sequence doesn't trip anything up.
63
+ not '*/' or fail='C close comment sequence mishandled'
64
+
65
+ ='ok'
66
+ )
@@ -0,0 +1,19 @@
1
+ // Test `test`.
2
+
3
+ externals (stem)
4
+
5
+ strings (s)
6
+
7
+ define stem as (
8
+ backwards (
9
+ $(cursor == 2) or fail='backwards failed to swap cursor and limit'
10
+ test (
11
+ ='juggernaut'
12
+ $(cursor == 10) or fail='string= failed to update cursor'
13
+ next or fail='next failed'
14
+ )
15
+ $(cursor == 10) or fail='test failed to restore cursor'
16
+ )
17
+
18
+ ='ok'
19
+ )
@@ -1,4 +1,24 @@
1
1
  /* Unit tests for handling of cases the vocabularies don't cover.
2
+ *
3
+ * In general we test the stemming algorithms via vocabulary lists
4
+ * and corresponding lists of expected stems, which are in the snowball-data
5
+ * repo. These are used to verify that each stemmer produces the expected
6
+ * output for all the different programming languages Snowball can generate
7
+ * code for (whereas testcases here only exercise the C stemmers).
8
+ *
9
+ * Test coverage for a change to a stemmer's behaviour should generally be
10
+ * implemented by adding new words its the vocabulary (if words already there
11
+ * don't adequately cover the change).
12
+ *
13
+ * Only cases which can't be exercised by real words in the language being
14
+ * stemmed should go here. Each vocabulary lists also serves as a sample
15
+ * vocabulary for evaluating its corresponding stemmer, so we don't want to
16
+ * add entries which would be junk for such use (such as emoji, numbers, hex
17
+ * codes, etc).
18
+ *
19
+ * Testcases here can run for a specified stemmer or for all stemmers. This
20
+ * provides an easy way to test behaviours which any good stemmer should
21
+ * have (such as not mangling numbers).
2
22
  */
3
23
 
4
24
  #include <stdio.h>
@@ -7,8 +27,13 @@
7
27
 
8
28
  #include "libstemmer.h"
9
29
 
30
+ #define U_0622 "\xd8\xa2"
31
+ #define U_0627 "\xd8\xa7"
32
+ #define U_062B "\xd8\xab"
33
+ #define U_0631 "\xd8\xb1"
10
34
  #define EMOJI_FACE_THROWING_A_KISS "\xf0\x9f\x98\x98"
11
35
  #define U_40079 "\xf1\x80\x81\xb9"
36
+
12
37
  static const struct testcase {
13
38
  /* Stemmer to use, or 0 to test with all stemmers */
14
39
  const char * language;
@@ -25,12 +50,27 @@ static const struct testcase {
25
50
  "a" EMOJI_FACE_THROWING_A_KISS "ing",
26
51
  "a" EMOJI_FACE_THROWING_A_KISS "e" },
27
52
  { "en", 0, U_40079 "wing", 0 },
53
+ "a" EMOJI_FACE_THROWING_A_KISS "e" },
54
+ { "en", 0, U_40079 "wing", 0 },
55
+
56
+ // The Persian stemmer removes ASCII space inside a word. It shouldn't
57
+ // appear there if our tokenisation recommendations are followed, and
58
+ // it seems more appropriate to test here rather than adding instances
59
+ // to persian/voc.txt.
60
+ { "fa", 0, U_0622 U_062B " " U_0627 U_0631,
61
+ U_0622 U_062B U_0627 U_0631, 0 },
62
+
28
63
  // The Finnish stemmer used to damage numbers ending with two or more of
29
64
  // the same digit. Regression test, applied to all stemmers.
30
65
  // https://github.com/snowballstem/snowball/issues/66
31
- { 0, 0, "2000", 0 },
66
+ { 0, 0, "00", 0 },
67
+ { 0, 0, "555", 0 },
32
68
  { 0, 0, "999", 0 },
69
+ { 0, 0, "1899", 0 },
70
+ { 0, 0, "2000", 0 },
71
+ { 0, 0, "9999", 0 },
33
72
  { 0, 0, "1000000000", 0 },
73
+
34
74
  // The Danish stemmer used to damage a number at the end of a word.
35
75
  // Regression test, applied to all stemmers.
36
76
  // https://github.com/snowballstem/snowball/issues/81
@@ -0,0 +1,32 @@
1
+ // Test canonicalisation of commands.
2
+ externals (stem)
3
+ integers (x y)
4
+ define stem as (
5
+ $x = cursor
6
+ setmark y
7
+
8
+ try 'a'
9
+
10
+ atmark x
11
+ $(cursor == y)
12
+
13
+ atlimit
14
+ $(cursor >= limit)
15
+ not next
16
+ not hop 1
17
+
18
+ not atlimit
19
+ not $(cursor >= limit)
20
+ $(cursor < limit)
21
+ test next
22
+ test hop 1
23
+
24
+ // `<-''` is the same as `delete`.
25
+ // `hop 1` is the same as `next`
26
+ [substring] among (
27
+ 'a' (delete next)
28
+ 'b' (<-'' hop 1)
29
+ )
30
+
31
+ $(x == y)
32
+ )
File without changes
@@ -0,0 +1,57 @@
1
+ define stem
2
+ (
3
+ = x
4
+ # cursor
5
+ = y
6
+ # cursor
7
+ try
8
+ literal 'a'
9
+ ==
10
+ # name x
11
+ cursor
12
+ ==
13
+ # name y
14
+ cursor
15
+ >=
16
+ # limit
17
+ cursor
18
+ >=
19
+ # limit
20
+ cursor
21
+ >=
22
+ # limit
23
+ cursor
24
+ >=
25
+ # limit
26
+ cursor
27
+ <
28
+ # limit
29
+ cursor
30
+ <
31
+ # limit
32
+ cursor
33
+ <
34
+ # limit
35
+ cursor
36
+ <
37
+ # limit
38
+ cursor
39
+ <
40
+ # limit
41
+ cursor
42
+ [
43
+ substring
44
+ ]
45
+ among
46
+ literal 'a'
47
+ (
48
+ <- ''
49
+ next
50
+ literal 'b'
51
+ (
52
+ <- ''
53
+ next
54
+ ==
55
+ # name y
56
+ name x
57
+ Function end
@@ -0,0 +1,2 @@
1
+ // This segfaulted in print_node_() with 3.0.1 because the program was NULL.
2
+ stringescapes{}
File without changes
@@ -0,0 +1,11 @@
1
+ // Test groupings.
2
+ externals (stem)
3
+ groupings (g)
4
+ stringescapes {}
5
+ define g 'r{U+EB}p{U+EB}{U+E5}tss'
6
+ define stem as (
7
+ g
8
+ non-g
9
+ gopast g
10
+ gopast non-g
11
+ )
@@ -0,0 +1,144 @@
1
+ // Test inlining of routines.
2
+ externals (stem external2)
3
+ booleans (b)
4
+ groupings (g)
5
+ integers (i)
6
+ strings (s)
7
+ routines (
8
+ r_eq
9
+ r_ge
10
+ r_gt
11
+ r_le
12
+ r_lt
13
+ r_ne
14
+ r_booltest
15
+ r_not_booltest
16
+ r_grouping
17
+ r_non
18
+ r_goto_grouping
19
+ r_gopast_grouping
20
+ r_goto_non
21
+ r_gopast_non
22
+ r_literalstring
23
+ r_name
24
+ r_true
25
+ r_false
26
+ r_fail
27
+ r_set
28
+ r_unset
29
+ r_assign
30
+ r_plusassign
31
+ r_minusassign
32
+ r_multiplyassign
33
+ r_divideassign
34
+ r_tomark
35
+ r_tolimit
36
+ r_hop
37
+ r_next
38
+ r_delete
39
+ r_insert
40
+ r_attach
41
+ r_leftslice
42
+ r_rightslice
43
+ r_sliceto
44
+ r_stringassign
45
+ r_slicefrom
46
+ // These are canonicalised to an integer assignment or test.
47
+ r_atlimit
48
+ r_atmark
49
+ r_setmark
50
+ )
51
+
52
+ define g 'aeiou'
53
+
54
+ define stem as (
55
+ set b
56
+ [next] -> s
57
+ r_eq
58
+ r_ge
59
+ r_gt
60
+ r_le
61
+ r_lt
62
+ r_ne
63
+ r_booltest
64
+ r_not_booltest
65
+ r_grouping
66
+ r_non
67
+ r_goto_grouping
68
+ r_gopast_grouping
69
+ r_goto_non
70
+ r_gopast_non
71
+ r_literalstring
72
+ r_name
73
+ r_true
74
+ do r_false
75
+ do r_fail
76
+ r_set
77
+ r_unset
78
+ r_assign
79
+ r_plusassign
80
+ r_minusassign
81
+ r_multiplyassign
82
+ r_divideassign
83
+ r_tomark
84
+ r_tolimit
85
+ r_hop
86
+ r_next
87
+ r_delete
88
+ r_insert
89
+ r_attach
90
+ r_leftslice
91
+ r_rightslice
92
+ r_sliceto
93
+ r_stringassign
94
+ r_slicefrom
95
+ r_atlimit
96
+ r_atmark
97
+ r_setmark
98
+ external2
99
+ )
100
+
101
+ // Externals should not get inlined.
102
+ define external2 as true
103
+
104
+ define r_eq as $(cursor == 1)
105
+ define r_ge as $(cursor >= 1)
106
+ define r_gt as $(cursor > 1)
107
+ define r_le as $(cursor <= 1)
108
+ define r_lt as $(cursor < 1)
109
+ define r_ne as $(cursor != 1)
110
+ define r_booltest as b
111
+ define r_not_booltest as not b
112
+ define r_grouping as g
113
+ define r_non as non-g
114
+ define r_goto_grouping as goto g
115
+ define r_gopast_grouping as gopast g
116
+ define r_goto_non as goto non-g
117
+ define r_gopast_non as gopast non-g
118
+ define r_literalstring as 'xyzzy'
119
+ define r_name as s
120
+ define r_true as true
121
+ define r_false as false
122
+ define r_fail as fail next
123
+ define r_set as set b
124
+ define r_unset as unset b
125
+ define r_assign as $i = 1
126
+ define r_plusassign as $i += 1
127
+ define r_minusassign as $i -= 1
128
+ define r_multiplyassign as $i *= 42
129
+ define r_divideassign as $i /= 6
130
+ define r_tomark as tomark i
131
+ define r_tolimit as tolimit
132
+ define r_hop as hop 2
133
+ define r_next as next
134
+ define r_delete as delete
135
+ define r_insert as insert 'x'
136
+ define r_attach as attach 'y'
137
+ define r_leftslice as [
138
+ define r_rightslice as ]
139
+ define r_sliceto as ->s
140
+ define r_stringassign as ='xyz'
141
+ define r_slicefrom as <-'x'
142
+ define r_atlimit as atlimit
143
+ define r_atmark as atmark i
144
+ define r_setmark as setmark i
File without changes
@@ -0,0 +1,121 @@
1
+ define stem
2
+ (
3
+ set b
4
+ [
5
+ next
6
+ ]
7
+ -> s
8
+ (
9
+ ==
10
+ # number 1
11
+ cursor
12
+ (
13
+ >=
14
+ # number 1
15
+ cursor
16
+ (
17
+ >
18
+ # number 1
19
+ cursor
20
+ (
21
+ <=
22
+ # number 1
23
+ cursor
24
+ (
25
+ <
26
+ # number 1
27
+ cursor
28
+ (
29
+ !=
30
+ # number 1
31
+ cursor
32
+ (
33
+ Boolean test b
34
+ (
35
+ Inverted boolean test b
36
+ (
37
+ grouping g
38
+ (
39
+ non g
40
+ (
41
+ goto grouping g
42
+ (
43
+ gopast grouping g
44
+ (
45
+ goto non g
46
+ (
47
+ gopast non g
48
+ (
49
+ literal 'xyzzy'
50
+ (
51
+ name s
52
+ (
53
+ true
54
+ do
55
+ (
56
+ false
57
+ do
58
+ (
59
+ fail
60
+ next
61
+ (
62
+ set b
63
+ (
64
+ unset b
65
+ (
66
+ = i
67
+ # number 1
68
+ (
69
+ += i
70
+ # number 1
71
+ (
72
+ -= i
73
+ # number 1
74
+ (
75
+ *= i
76
+ # number 42
77
+ (
78
+ /= i
79
+ # number 6
80
+ (
81
+ tomark
82
+ # name i
83
+ (
84
+ tolimit
85
+ (
86
+ hop
87
+ # number 2
88
+ (
89
+ next
90
+ (
91
+ <- ''
92
+ (
93
+ insert 'x'
94
+ (
95
+ attach 'y'
96
+ (
97
+ [
98
+ (
99
+ ]
100
+ (
101
+ -> s
102
+ (
103
+ = 'xyz'
104
+ (
105
+ <- 'x'
106
+ (
107
+ >=
108
+ # limit
109
+ cursor
110
+ (
111
+ ==
112
+ # name i
113
+ cursor
114
+ (
115
+ = i
116
+ # cursor
117
+ call external2
118
+ Function end
119
+ define external2
120
+ true
121
+ Function end
@@ -0,0 +1,17 @@
1
+ // Test legacy commands.
2
+ externals (stem)
3
+ strings (ch)
4
+ stringescapes {}
5
+ stringdef o" decimal '246'
6
+ stringdef o^ hex 'f4'
7
+ define stem as (
8
+ among (
9
+ (next)
10
+ 'a' 'e' 'i' 'o' 'u' (
11
+ [next]
12
+ => ch
13
+ delete
14
+ <+ ch
15
+ )
16
+ )
17
+ )