mittens 0.3.3 → 0.3.5
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/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/ext/mittens/ext.c +68 -30
- data/ext/mittens/extconf.rb +2 -0
- data/lib/mittens/version.rb +1 -1
- data/vendor/snowball/.github/workflows/ci.yml +43 -3
- data/vendor/snowball/.github/workflows/coverage.yml +8 -5
- data/vendor/snowball/GNUmakefile +46 -16
- data/vendor/snowball/NEWS +437 -13
- data/vendor/snowball/README.rst +4 -4
- data/vendor/snowball/algorithms/earlymodernenglish.sbl +301 -0
- data/vendor/snowball/algorithms/french.sbl +1 -1
- data/vendor/snowball/algorithms/ukrainian.sbl +1251 -0
- data/vendor/snowball/compiler/analyser.c +460 -156
- data/vendor/snowball/compiler/driver.c +41 -36
- data/vendor/snowball/compiler/generator.c +24 -1
- data/vendor/snowball/compiler/generator_ada.c +46 -45
- data/vendor/snowball/compiler/generator_c.c +1094 -187
- data/vendor/snowball/compiler/generator_csharp.c +34 -11
- data/vendor/snowball/compiler/generator_dart.c +39 -11
- data/vendor/snowball/compiler/generator_go.c +6 -6
- data/vendor/snowball/compiler/generator_java.c +29 -8
- data/vendor/snowball/compiler/generator_js.c +65 -38
- data/vendor/snowball/compiler/generator_pascal.c +69 -26
- data/vendor/snowball/compiler/generator_php.c +33 -12
- data/vendor/snowball/compiler/generator_python.c +23 -4
- data/vendor/snowball/compiler/generator_rust.c +37 -13
- data/vendor/snowball/compiler/generator_zig.c +6 -6
- data/vendor/snowball/compiler/header.h +85 -14
- data/vendor/snowball/compiler/space.c +67 -38
- data/vendor/snowball/compiler/tokeniser.c +28 -16
- data/vendor/snowball/csharp/Snowball/AssemblyInfo.cs +2 -2
- data/vendor/snowball/csharp/Snowball/Stemmer.cs +1 -4
- data/vendor/snowball/cxx/generate_algorithms.pl +5 -4
- data/vendor/snowball/cxx/{utilities.cxx → snowball_runtime.cxx} +1 -1
- data/vendor/snowball/cxx/stemmer.h +4 -0
- data/vendor/snowball/cxx/stemwords.cxx +36 -6
- data/vendor/snowball/dart/lib/src/snowball.dart +2 -2
- data/vendor/snowball/dart/pubspec.yaml +1 -1
- data/vendor/snowball/doc/libstemmer_c_README +3 -0
- data/vendor/snowball/doc/libstemmer_php_README +1 -1
- data/vendor/snowball/doc/libstemmer_python_README +8 -6
- data/vendor/snowball/examples/stemwords.c +4 -14
- data/vendor/snowball/go/env.go +16 -4
- data/vendor/snowball/include/libstemmer.h +0 -3
- data/vendor/snowball/java/org/tartarus/snowball/SnowballProgram.java +4 -4
- data/vendor/snowball/javascript/base-stemmer.js +27 -40
- data/vendor/snowball/javascript/stemwords.js +34 -10
- data/vendor/snowball/libstemmer/libstemmer_c.in +5 -5
- data/vendor/snowball/libstemmer/mkmodules.pl +5 -3
- data/vendor/snowball/libstemmer/modules.txt +4 -2
- data/vendor/snowball/pascal/SnowballProgram.pas +2 -2
- data/vendor/snowball/php/base-stemmer.php +2 -2
- data/vendor/snowball/python/setup.py +5 -1
- data/vendor/snowball/python/snowballstemmer/basestemmer.py +1 -2
- data/vendor/snowball/runtime/api.c +14 -3
- data/vendor/snowball/runtime/api.h +13 -9
- data/vendor/snowball/runtime/{utilities.c → snowball_runtime.c} +115 -181
- data/vendor/snowball/runtime/snowball_runtime.h +35 -24
- data/vendor/snowball/rust/src/snowball/snowball_env.rs +1 -1
- data/vendor/snowball/tests/compilertest +3 -3
- data/vendor/snowball/tests/runtime/among.sbl +96 -2
- data/vendor/snowball/tests/runtime/attachinsert.sbl +4 -0
- data/vendor/snowball/tests/runtime/debug.out +7 -0
- data/vendor/snowball/tests/runtime/debug.sbl +9 -0
- data/vendor/snowball/tests/runtime/integertests.sbl +22 -0
- data/vendor/snowball/tests/runtime/marklimit.sbl +30 -0
- data/vendor/snowball/tests/runtime/naming.sbl +20 -0
- data/vendor/snowball/tests/runtime/reverse.sbl +11 -0
- data/vendor/snowball/tests/stemtest.c +2 -5
- data/vendor/snowball/tests/syntax/aeslicefrom.sbl +7 -0
- data/vendor/snowball/tests/syntax/canon.sbl +14 -0
- data/vendor/snowball/tests/syntax/canon.syntax +36 -0
- data/vendor/snowball/tests/syntax/inline.syntax +4 -4
- data/vendor/snowball/tests/syntax/localvar.sbl +38 -0
- data/vendor/snowball/tests/syntax/localvar.stderr +3 -0
- data/vendor/snowball/tests/syntax/localvar.syntax +76 -0
- data/vendor/snowball/tests/syntax/unused.sbl +5 -1
- data/vendor/snowball/tests/syntax/unused.stderr +3 -1
- data/vendor/snowball/zig/env.zig +24 -4
- metadata +14 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc9a43dbea4ac1069238dd003f295c3fec249d658f1aa911e7da3e8abeea246f
|
|
4
|
+
data.tar.gz: d2c745ba5dea06757c857787cf89891a38f118cbecbd12720b577216605d09cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 326722dc85ee85717aa395d7bef8d9cab953172f598fdf2fe26622fc3ab1b2e96bba1005c773a0f2ac4ae0b684b55e116f84e611c1643cc3941f30577e220fcc
|
|
7
|
+
data.tar.gz: 0113f43ea4d07fe4f5f77ffc5a7b9b6f1a5ad6b85208876878c5a0cd378686c8b344d095d93957455757b33bf9c73aae63e72288effc8bf0c8c26b5b868fa3d0
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Copyright (c) 2001, Dr Martin Porter
|
|
2
2
|
Copyright (c) 2004,2005, Richard Boulton
|
|
3
3
|
Copyright (c) 2013, Yoshiki Shibukawa
|
|
4
|
-
Copyright (c) 2006
|
|
4
|
+
Copyright (c) 2006-2025, Olly Betts
|
|
5
5
|
Copyright (c) 2022-2025, Andrew Kane
|
|
6
6
|
All rights reserved.
|
|
7
7
|
|
data/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Specify the language
|
|
|
36
36
|
stemmer = Mittens::Stemmer.new(language: "french")
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Supports `arabic`, `armenian`, `basque`, `catalan`, `czech`, `danish`, `dutch`, `dutch_porter`, `english`, `esperanto`, `estonian`, `finnish`, `french`, `german`, `greek`, `hindi`, `hungarian`, `indonesian`, `irish`, `italian`, `lithuanian`, `nepali`, `norwegian`, `persian`, `polish`, `porter`, `portuguese`, `romanian`, `russian`, `serbian`, `sesotho`, `spanish`, `swedish`, `tamil`, `turkish`, and `yiddish`
|
|
39
|
+
Supports `arabic`, `armenian`, `basque`, `catalan`, `czech`, `danish`, `dutch`, `dutch_porter`, `earlymodernenglish`, `english`, `esperanto`, `estonian`, `finnish`, `french`, `german`, `greek`, `hindi`, `hungarian`, `indonesian`, `irish`, `italian`, `lithuanian`, `nepali`, `norwegian`, `persian`, `polish`, `porter`, `portuguese`, `romanian`, `russian`, `serbian`, `sesotho`, `spanish`, `swedish`, `tamil`, `turkish`, `ukrainian`, and `yiddish`
|
|
40
40
|
|
|
41
41
|
## History
|
|
42
42
|
|
data/ext/mittens/ext.c
CHANGED
|
@@ -3,21 +3,35 @@
|
|
|
3
3
|
#include "libstemmer.h"
|
|
4
4
|
#include "ruby/ruby.h"
|
|
5
5
|
|
|
6
|
+
#define GetAlgorithm(language) (NIL_P(language) ? "english" : StringValueCStr(language))
|
|
7
|
+
#define GetStemmer(obj, ptr) TypedData_Get_Struct((obj), stemmer_t, &stemmer_data_type, (ptr))
|
|
8
|
+
|
|
6
9
|
typedef struct stemmer {
|
|
7
10
|
struct sb_stemmer* stemmer;
|
|
11
|
+
VALUE language;
|
|
8
12
|
} stemmer_t;
|
|
9
13
|
|
|
14
|
+
static void stemmer_mark(void* ptr)
|
|
15
|
+
{
|
|
16
|
+
stemmer_t* stemmer = (stemmer_t*) ptr;
|
|
17
|
+
rb_gc_mark(stemmer->language);
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
static void stemmer_free(void* ptr)
|
|
11
21
|
{
|
|
12
22
|
stemmer_t* stemmer = (stemmer_t*) ptr;
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
|
|
24
|
+
// safe to pass null pointer, but check anyways
|
|
25
|
+
if (stemmer->stemmer != NULL)
|
|
26
|
+
sb_stemmer_delete(stemmer->stemmer);
|
|
27
|
+
|
|
15
28
|
xfree(ptr);
|
|
16
29
|
}
|
|
17
30
|
|
|
18
31
|
const rb_data_type_t stemmer_data_type = {
|
|
19
|
-
.wrap_struct_name = "
|
|
32
|
+
.wrap_struct_name = "Mittens::Stemmer",
|
|
20
33
|
.function = {
|
|
34
|
+
.dmark = stemmer_mark,
|
|
21
35
|
.dfree = stemmer_free,
|
|
22
36
|
},
|
|
23
37
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
@@ -28,38 +42,37 @@ static VALUE stemmer_allocate(VALUE klass)
|
|
|
28
42
|
stemmer_t* stemmer;
|
|
29
43
|
VALUE obj = TypedData_Make_Struct(klass, stemmer_t, &stemmer_data_type, stemmer);
|
|
30
44
|
stemmer->stemmer = NULL;
|
|
45
|
+
stemmer->language = Qnil;
|
|
31
46
|
return obj;
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
static VALUE stemmer_initialize(int argc, VALUE* argv, VALUE self)
|
|
35
50
|
{
|
|
51
|
+
stemmer_t* stemmer;
|
|
52
|
+
GetStemmer(self, stemmer);
|
|
53
|
+
|
|
54
|
+
if (stemmer->stemmer != NULL)
|
|
55
|
+
rb_raise(rb_eRuntimeError, "stemmer already initialized");
|
|
56
|
+
|
|
36
57
|
VALUE opts;
|
|
37
58
|
rb_scan_args(argc, argv, ":", &opts);
|
|
38
59
|
|
|
39
60
|
VALUE language = Qnil;
|
|
40
|
-
|
|
41
|
-
if (!NIL_P(opts)) {
|
|
61
|
+
if (!NIL_P(opts))
|
|
42
62
|
language = rb_hash_aref(opts, ID2SYM(rb_intern("language")));
|
|
43
|
-
if (!NIL_P(language)) {
|
|
44
|
-
Check_Type(language, T_STRING);
|
|
45
|
-
algorithm = RSTRING_PTR(language);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
stemmer_t* stemmer;
|
|
50
|
-
TypedData_Get_Struct(self, stemmer_t, &stemmer_data_type, stemmer);
|
|
51
|
-
|
|
52
|
-
// in case called multiple times
|
|
53
|
-
sb_stemmer_delete(stemmer->stemmer);
|
|
54
63
|
|
|
55
64
|
// if adding support for encoding, may want to change encoding returned from stem
|
|
56
|
-
stemmer->stemmer = sb_stemmer_new(
|
|
57
|
-
if (stemmer->stemmer == NULL)
|
|
58
|
-
|
|
65
|
+
stemmer->stemmer = sb_stemmer_new(GetAlgorithm(language), NULL);
|
|
66
|
+
if (stemmer->stemmer == NULL)
|
|
67
|
+
{
|
|
68
|
+
if (!NIL_P(language))
|
|
69
|
+
rb_raise(rb_eArgError, "unknown language: %" PRIsVALUE, language);
|
|
70
|
+
|
|
71
|
+
rb_raise(rb_eNoMemError, "failed to allocate memory");
|
|
59
72
|
}
|
|
60
73
|
|
|
61
|
-
//
|
|
62
|
-
|
|
74
|
+
// copy (after GetAlgorithm) in case string is modified in future
|
|
75
|
+
stemmer->language = rb_obj_dup(language);
|
|
63
76
|
|
|
64
77
|
return self;
|
|
65
78
|
}
|
|
@@ -67,17 +80,43 @@ static VALUE stemmer_initialize(int argc, VALUE* argv, VALUE self)
|
|
|
67
80
|
static VALUE stemmer_stem(VALUE self, VALUE value)
|
|
68
81
|
{
|
|
69
82
|
stemmer_t* stemmer;
|
|
70
|
-
|
|
83
|
+
GetStemmer(self, stemmer);
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
if (stemmer->stemmer == NULL)
|
|
86
|
+
rb_raise(rb_eRuntimeError, "stemmer not initialized");
|
|
73
87
|
|
|
74
|
-
const
|
|
88
|
+
const char* word = StringValuePtr(value);
|
|
75
89
|
long size = RSTRING_LEN(value);
|
|
76
90
|
if (size > INT_MAX)
|
|
77
91
|
rb_raise(rb_eArgError, "string exceeds max length");
|
|
78
|
-
const sb_symbol* pointer_out = sb_stemmer_stem(stemmer->stemmer, word, (int) size);
|
|
79
92
|
|
|
80
|
-
|
|
93
|
+
const sb_symbol* pointer_out = sb_stemmer_stem(stemmer->stemmer, (const sb_symbol*) word, (int) size);
|
|
94
|
+
int length_out = sb_stemmer_length(stemmer->stemmer);
|
|
95
|
+
|
|
96
|
+
// place after last use of word
|
|
97
|
+
RB_GC_GUARD(value);
|
|
98
|
+
|
|
99
|
+
return rb_utf8_str_new((char*) pointer_out, (long) length_out);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static VALUE stemmer_initialize_copy(VALUE self, VALUE orig)
|
|
103
|
+
{
|
|
104
|
+
stemmer_t* stemmer;
|
|
105
|
+
GetStemmer(self, stemmer);
|
|
106
|
+
|
|
107
|
+
stemmer_t* orig_stemmer;
|
|
108
|
+
GetStemmer(orig, orig_stemmer);
|
|
109
|
+
|
|
110
|
+
if (stemmer->stemmer != NULL)
|
|
111
|
+
rb_raise(rb_eRuntimeError, "stemmer already initialized");
|
|
112
|
+
|
|
113
|
+
stemmer->stemmer = sb_stemmer_new(GetAlgorithm(orig_stemmer->language), NULL);
|
|
114
|
+
if (stemmer->stemmer == NULL)
|
|
115
|
+
rb_raise(rb_eNoMemError, "failed to allocate memory");
|
|
116
|
+
|
|
117
|
+
stemmer->language = orig_stemmer->language;
|
|
118
|
+
|
|
119
|
+
return self;
|
|
81
120
|
}
|
|
82
121
|
|
|
83
122
|
static VALUE stemmer_languages(VALUE klass)
|
|
@@ -85,10 +124,8 @@ static VALUE stemmer_languages(VALUE klass)
|
|
|
85
124
|
VALUE out = rb_ary_new();
|
|
86
125
|
|
|
87
126
|
const char** language = sb_stemmer_list();
|
|
88
|
-
while (*language != NULL)
|
|
89
|
-
rb_ary_push(out, rb_utf8_str_new_cstr(*language));
|
|
90
|
-
language++;
|
|
91
|
-
}
|
|
127
|
+
while (*language != NULL)
|
|
128
|
+
rb_ary_push(out, rb_utf8_str_new_cstr(*language++));
|
|
92
129
|
|
|
93
130
|
return out;
|
|
94
131
|
}
|
|
@@ -100,5 +137,6 @@ void Init_ext(void)
|
|
|
100
137
|
rb_define_alloc_func(cStemmer, stemmer_allocate);
|
|
101
138
|
rb_define_method(cStemmer, "initialize", stemmer_initialize, -1);
|
|
102
139
|
rb_define_method(cStemmer, "stem", stemmer_stem, 1);
|
|
140
|
+
rb_define_method(cStemmer, "initialize_copy", stemmer_initialize_copy, 1);
|
|
103
141
|
rb_define_singleton_method(cStemmer, "languages", stemmer_languages, 0);
|
|
104
142
|
}
|
data/ext/mittens/extconf.rb
CHANGED
|
@@ -10,6 +10,8 @@ output, status = Open3.capture2(make_cmd, "CFLAGS=#{cflags}", chdir: vendor)
|
|
|
10
10
|
puts output
|
|
11
11
|
raise "Command failed" unless status.success?
|
|
12
12
|
|
|
13
|
+
append_cflags("-Wall -Wextra -Wpedantic -Wconversion")
|
|
14
|
+
|
|
13
15
|
$INCFLAGS += " -I$(srcdir)/../../vendor/snowball/include"
|
|
14
16
|
$LDFLAGS += " $(srcdir)/../../vendor/snowball/libstemmer.a"
|
|
15
17
|
|
data/lib/mittens/version.rb
CHANGED
|
@@ -48,6 +48,10 @@ jobs:
|
|
|
48
48
|
- name: "C++"
|
|
49
49
|
CXX: g++
|
|
50
50
|
WERROR: '-pedantic -Werror'
|
|
51
|
+
- name: "C++ widechars"
|
|
52
|
+
CXX: g++
|
|
53
|
+
MAKE: 'make SNOWBALL_WIDE=1'
|
|
54
|
+
WERROR: '-pedantic -Werror'
|
|
51
55
|
- name: java
|
|
52
56
|
JAVA: java
|
|
53
57
|
JAVAC: javac
|
|
@@ -112,6 +116,11 @@ jobs:
|
|
|
112
116
|
os: 'ubuntu-24.04'
|
|
113
117
|
apt_packages: 'python3.12'
|
|
114
118
|
THIN_FACTOR: 1
|
|
119
|
+
- name: Python 3.14
|
|
120
|
+
PYTHON: python3.14
|
|
121
|
+
os: 'ubuntu-26.04'
|
|
122
|
+
apt_packages: 'python3.14'
|
|
123
|
+
THIN_FACTOR: 1
|
|
115
124
|
- name: Python (pypy3)
|
|
116
125
|
PYTHON: pypy3
|
|
117
126
|
apt_packages: 'pypy3'
|
|
@@ -128,6 +137,32 @@ jobs:
|
|
|
128
137
|
MAKE: mingw32-make
|
|
129
138
|
mingw64_packages: 'mingw-w64-ucrt-x86_64-go'
|
|
130
139
|
ccache: sccache
|
|
140
|
+
- name: Windows MSVC (C)
|
|
141
|
+
os: windows-latest
|
|
142
|
+
c_tests: check
|
|
143
|
+
ccache: sccache
|
|
144
|
+
CC: cl
|
|
145
|
+
CFLAGS: -nologo -std:c11 -W3 -WX
|
|
146
|
+
- name: Windows MSVC clatest (C)
|
|
147
|
+
os: windows-latest
|
|
148
|
+
c_tests: check
|
|
149
|
+
ccache: sccache
|
|
150
|
+
CC: cl
|
|
151
|
+
CFLAGS: -nologo -std:clatest -W3 -WX
|
|
152
|
+
- name: Windows MSVC2026 arm (C)
|
|
153
|
+
os: windows-11-vs2026-arm
|
|
154
|
+
msvc_arch: arm64
|
|
155
|
+
c_tests: check
|
|
156
|
+
ccache: sccache
|
|
157
|
+
CC: cl
|
|
158
|
+
CFLAGS: -nologo -std:c11 -W3 -WX
|
|
159
|
+
- name: Windows MSVC2026 clatest arm (C)
|
|
160
|
+
os: windows-11-vs2026-arm
|
|
161
|
+
msvc_arch: arm64
|
|
162
|
+
c_tests: check
|
|
163
|
+
ccache: sccache
|
|
164
|
+
CC: cl
|
|
165
|
+
CFLAGS: -nologo -std:clatest -W3 -WX
|
|
131
166
|
|
|
132
167
|
fail-fast: false
|
|
133
168
|
|
|
@@ -188,6 +223,11 @@ jobs:
|
|
|
188
223
|
git clone "$UPSTREAM_REPO_URL"
|
|
189
224
|
fi
|
|
190
225
|
fi
|
|
226
|
+
- name: Set up Visual Studio shell
|
|
227
|
+
if: ${{ endsWith(matrix.CC, 'cl') }}
|
|
228
|
+
uses: egor-tensin/vs-shell@v2
|
|
229
|
+
with:
|
|
230
|
+
arch: ${{ matrix.msvc_arch || 'x64' }}
|
|
191
231
|
- name: Hook up runtime testing
|
|
192
232
|
if: ${{ inputs.runtime-tests }}
|
|
193
233
|
run: |
|
|
@@ -229,7 +269,7 @@ jobs:
|
|
|
229
269
|
msystem: ucrt64
|
|
230
270
|
install: base-devel ${{ matrix.mingw64_packages }}
|
|
231
271
|
- name: Build
|
|
232
|
-
run: $MAKE CC="${{ matrix.ccache || 'ccache' }} $CC"
|
|
272
|
+
run: $MAKE CC="${{ matrix.ccache || 'ccache' }} $CC" ${{ format('{0}{1}{2}', matrix.CFLAGS && 'CFLAGS="', matrix.CFLAGS, matrix.CFLAGS && '"') }}
|
|
233
273
|
- name: Test C dist
|
|
234
274
|
if: matrix.CFLAGS_DIST_BUILD
|
|
235
275
|
run: |
|
|
@@ -249,7 +289,7 @@ jobs:
|
|
|
249
289
|
case '${{ matrix.c_tests }}' in
|
|
250
290
|
*generate*) mkdir ada/bin && ln -s /bin/true ada/bin/generate ;;
|
|
251
291
|
esac
|
|
252
|
-
$MAKE ${{ matrix.c_tests }} CC="$CC"
|
|
292
|
+
$MAKE ${{ matrix.c_tests }} CC="$CC" ${{ format('{0}{1}{2}', matrix.CFLAGS && 'CFLAGS="', matrix.CFLAGS, matrix.CFLAGS && '"') }}
|
|
253
293
|
- name: Test C++
|
|
254
294
|
if: matrix.CXX
|
|
255
295
|
run: |
|
|
@@ -277,7 +317,7 @@ jobs:
|
|
|
277
317
|
if: ${{ startsWith(matrix.JSRUN, 'deno') }}
|
|
278
318
|
run: |
|
|
279
319
|
deno lint javascript/*.js js_out/*.js
|
|
280
|
-
deno check javascript/*.js js_out/*.js
|
|
320
|
+
deno check --check-js javascript/*.js js_out/*.js
|
|
281
321
|
- name: Test Rust
|
|
282
322
|
if: matrix.RUST
|
|
283
323
|
run: $MAKE check_rust RUST="${{ matrix.RUST }}"
|
|
@@ -90,7 +90,8 @@ jobs:
|
|
|
90
90
|
ls -1 algorithms|sed 's,\.sbl$,,p;d'
|
|
91
91
|
elif [ -n "$GITHUB_HEAD_REF" ] ; then
|
|
92
92
|
# Pull-request.
|
|
93
|
-
git
|
|
93
|
+
git fetch --depth=1 origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"
|
|
94
|
+
git diff --numstat "$GITHUB_BASE_REF" HEAD -- algorithms|sed 's,^[0-9].*/\([^ ]*\)\.sbl$,\1,p;d'
|
|
94
95
|
else
|
|
95
96
|
# Push.
|
|
96
97
|
#
|
|
@@ -109,9 +110,11 @@ jobs:
|
|
|
109
110
|
# That size means generating a coverage report for it takes something
|
|
110
111
|
# like 20-25 minutes.
|
|
111
112
|
if [ -f "${STEMMING_DATA}/$a/voc.txt" ] ; then
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
if grep -q "^$a " libstemmer/modules.txt ; then
|
|
114
|
+
$MAKE -s "check_utf8_$a" 2> coverage.log
|
|
115
|
+
echo ; echo "=== Coverage report for $a ===" ; echo
|
|
116
|
+
sort -k2,2 -k3,3n -k3,3 -k5,5g coverage.log |
|
|
117
|
+
uniq -c |awk '{$1=sprintf("% 8d",$1-1);print}'
|
|
118
|
+
fi
|
|
116
119
|
fi
|
|
117
120
|
done
|
data/vendor/snowball/GNUmakefile
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# After changing this, run `make update_version` to update various sources
|
|
4
4
|
# which hard-code it.
|
|
5
|
-
SNOWBALL_VERSION = 3.
|
|
5
|
+
SNOWBALL_VERSION = 3.2.0
|
|
6
6
|
|
|
7
7
|
ifeq ($(OS),Windows_NT)
|
|
8
8
|
EXEEXT = .exe
|
|
@@ -34,6 +34,20 @@ ada_src_dir = $(ada_src_main_dir)/algorithms
|
|
|
34
34
|
|
|
35
35
|
ARFLAGS = -cr
|
|
36
36
|
c_src_dir = src_c
|
|
37
|
+
ifeq '$(filter %cl,$(CC))' ''
|
|
38
|
+
o_for_obj = -o
|
|
39
|
+
o_for_exe = -o
|
|
40
|
+
ARFLAGS_ = $(ARFLAGS) # Includes a trailing space.
|
|
41
|
+
else
|
|
42
|
+
o_for_obj = -Fo:
|
|
43
|
+
o_for_exe = -Fe:
|
|
44
|
+
AR = lib -nologo
|
|
45
|
+
# Frustratingly, LIB.EXE's `-out:` option doesn't allow a space to follow
|
|
46
|
+
# (unlike CL.EXE's `-Fo:` and `-Fe:` options) so ARFLAGS_ has to be used
|
|
47
|
+
# without a space after it. For more sensible compilers ARFLAGS_ is set
|
|
48
|
+
# to include a trailing space.
|
|
49
|
+
ARFLAGS_ = -out:
|
|
50
|
+
endif
|
|
37
51
|
|
|
38
52
|
# C++
|
|
39
53
|
|
|
@@ -41,6 +55,13 @@ CXX ?= c++
|
|
|
41
55
|
CXXFLAGS=-g -O2 -W -Wall -Wcast-qual -Wmissing-declarations -Wshadow $(WERROR)
|
|
42
56
|
cxx_src_dir = cxx
|
|
43
57
|
|
|
58
|
+
ifdef SNOWBALL_WIDE
|
|
59
|
+
CXXFLAGS += -DSNOWBALL_WIDE
|
|
60
|
+
cxx_encoding_opt := -w
|
|
61
|
+
else
|
|
62
|
+
cxx_encoding_opt := -u
|
|
63
|
+
endif
|
|
64
|
+
|
|
44
65
|
# C#
|
|
45
66
|
|
|
46
67
|
MONO ?= mono
|
|
@@ -182,7 +203,7 @@ COMPILER_HEADERS = compiler/header.h \
|
|
|
182
203
|
# C
|
|
183
204
|
|
|
184
205
|
RUNTIME_SOURCES = runtime/api.c \
|
|
185
|
-
runtime/
|
|
206
|
+
runtime/snowball_runtime.c
|
|
186
207
|
|
|
187
208
|
RUNTIME_HEADERS = runtime/api.h \
|
|
188
209
|
runtime/snowball_runtime.h
|
|
@@ -198,7 +219,7 @@ STEMTEST_SOURCES = tests/stemtest.c
|
|
|
198
219
|
# C++
|
|
199
220
|
|
|
200
221
|
CXX_STEMWORDS_SOURCES = $(cxx_src_dir)/stemwords.cxx
|
|
201
|
-
CXX_RUNTIME_SOURCES = $(cxx_src_dir)/stemmer.cxx $(cxx_src_dir)/
|
|
222
|
+
CXX_RUNTIME_SOURCES = $(cxx_src_dir)/stemmer.cxx $(cxx_src_dir)/snowball_runtime.cxx
|
|
202
223
|
CXX_SOURCES = $(libstemmer_algorithms:%=$(cxx_src_dir)/%_stemmer.cxx)
|
|
203
224
|
CXX_HEADERS = $(libstemmer_algorithms:%=$(cxx_src_dir)/%_stemmer.h)
|
|
204
225
|
|
|
@@ -369,7 +390,7 @@ $(STEMMING_DATA)/% $(STEMMING_DATA_ABS)/%:
|
|
|
369
390
|
@[ -f '$@' ] || { echo '$@: Test data not found'; echo 'Checkout the snowball-data repo as "$(STEMMING_DATA_ABS)"'; exit 1; }
|
|
370
391
|
|
|
371
392
|
snowball$(EXEEXT): $(COMPILER_OBJECTS)
|
|
372
|
-
$(CC) $(CFLAGS) $(LDFLAGS)
|
|
393
|
+
$(CC) $(CFLAGS) $(LDFLAGS) $(o_for_exe) $@ $^
|
|
373
394
|
|
|
374
395
|
$(COMPILER_OBJECTS): $(COMPILER_HEADERS)
|
|
375
396
|
|
|
@@ -424,19 +445,19 @@ libstemmer/modules_utf8.h libstemmer/mkinc_utf8.mak: libstemmer/mkmodules.pl $(M
|
|
|
424
445
|
libstemmer/libstemmer.o: libstemmer/modules.h $(C_LIB_HEADERS)
|
|
425
446
|
|
|
426
447
|
libstemmer.a: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
|
|
427
|
-
$(AR) $(
|
|
448
|
+
$(AR) $(ARFLAGS_)$@ $^
|
|
428
449
|
|
|
429
450
|
examples/%.o: examples/%.c
|
|
430
|
-
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c
|
|
451
|
+
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c $(o_for_obj) $@ $<
|
|
431
452
|
|
|
432
453
|
stemwords$(EXEEXT): $(STEMWORDS_OBJECTS) libstemmer.a
|
|
433
|
-
$(CC) $(CFLAGS) $(LDFLAGS)
|
|
454
|
+
$(CC) $(CFLAGS) $(LDFLAGS) $(o_for_exe) $@ $^
|
|
434
455
|
|
|
435
456
|
tests/%.o: tests/%.c
|
|
436
|
-
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c
|
|
457
|
+
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c $(o_for_obj) $@ $<
|
|
437
458
|
|
|
438
459
|
stemtest$(EXEEXT): $(STEMTEST_OBJECTS) libstemmer.a
|
|
439
|
-
$(CC) $(CFLAGS) $(LDFLAGS)
|
|
460
|
+
$(CC) $(CFLAGS) $(LDFLAGS) $(o_for_exe) $@ $^
|
|
440
461
|
|
|
441
462
|
$(c_src_dir)/stem_UTF_8_%.c $(c_src_dir)/stem_UTF_8_%.h: $(ALGORITHMS)/%.sbl snowball$(EXEEXT)
|
|
442
463
|
@mkdir -p $(c_src_dir)
|
|
@@ -455,7 +476,7 @@ $(c_src_dir)/stem_ISO_8859_2_%.c $(c_src_dir)/stem_ISO_8859_2_%.h: $(ALGORITHMS)
|
|
|
455
476
|
$(SNOWBALL_COMPILE) charsets/ISO-8859-2.sbl $< -o $@ -eprefix $*_ISO_8859_2_ -r ../runtime
|
|
456
477
|
|
|
457
478
|
$(c_src_dir)/stem_%.o: $(c_src_dir)/stem_%.c $(c_src_dir)/stem_%.h
|
|
458
|
-
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c
|
|
479
|
+
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c $(o_for_obj) $@ $<
|
|
459
480
|
|
|
460
481
|
# C++
|
|
461
482
|
|
|
@@ -467,7 +488,7 @@ $(cxx_src_dir)/stemwords$(EXEEXT): $(CXX_STEMWORDS_OBJECTS) $(CXX_RUNTIME_OBJECT
|
|
|
467
488
|
|
|
468
489
|
$(cxx_src_dir)/%_stemmer.cxx $(cxx_src_dir)/%_stemmer.h: $(ALGORITHMS)/%.sbl snowball$(EXEEXT)
|
|
469
490
|
@mkdir -p $(cxx_src_dir)
|
|
470
|
-
$(SNOWBALL_COMPILE) -c++ -cheader '"stemmer.h"' $< -o $@ -r ../runtime
|
|
491
|
+
$(SNOWBALL_COMPILE) -c++ -cheader '"stemmer.h"' $< -o $@ -r ../runtime $(cxx_encoding_opt)
|
|
471
492
|
|
|
472
493
|
$(cxx_src_dir)/%stemmer.o: $(cxx_src_dir)/%stemmer.h
|
|
473
494
|
|
|
@@ -477,6 +498,8 @@ $(cxx_src_dir)/%.o: $(cxx_src_dir)/%.cxx
|
|
|
477
498
|
$(cxx_src_dir)/stemmer.cxx: GNUmakefile $(cxx_src_dir)/generate_algorithms.pl $(MODULES)
|
|
478
499
|
$(cxx_src_dir)/generate_algorithms.pl $@ $(MODULES)
|
|
479
500
|
|
|
501
|
+
$(cxx_src_dir)/snowball_runtime.cxx: runtime/snowball_runtime.c
|
|
502
|
+
|
|
480
503
|
# C#
|
|
481
504
|
|
|
482
505
|
csharp_stemwords$(EXEEXT): $(CSHARP_STEMWORDS_SOURCES) $(CSHARP_RUNTIME_SOURCES) $(CSHARP_SOURCES)
|
|
@@ -818,7 +841,13 @@ CLEANDIRS += $(ada_src_dir) ada/bin ada/obj
|
|
|
818
841
|
|
|
819
842
|
.PHONY: check check_compilertest check_stemtest check_utf8 check_iso_8859_1 check_iso_8859_2 check_koi8r
|
|
820
843
|
|
|
821
|
-
|
|
844
|
+
# We don't run these when runtime tests are enabled (for stemtest, because it
|
|
845
|
+
# contains tests of the shipped algorithms; for compilertest, because it is
|
|
846
|
+
# orthogonal to the algorithms and so redundant to run it in both
|
|
847
|
+
# configuations).
|
|
848
|
+
EXTRA_TESTS ?= check_compilertest check_stemtest
|
|
849
|
+
|
|
850
|
+
check: $(EXTRA_TESTS) check_utf8 check_iso_8859_1 check_iso_8859_2 check_koi8r
|
|
822
851
|
|
|
823
852
|
check_compilertest: tests/compilertest
|
|
824
853
|
cd tests && ./compilertest
|
|
@@ -1199,14 +1228,14 @@ CLEANFILES += $(ZIG_SOURCES) zig/stemwords$(EXEEXT)
|
|
|
1199
1228
|
# Runtime test integration is currently a bit clunky, and you need to switch
|
|
1200
1229
|
# your tree to a different state to run runtime tests.
|
|
1201
1230
|
#
|
|
1202
|
-
# make
|
|
1231
|
+
# make setup_runtime_tests
|
|
1203
1232
|
#
|
|
1204
1233
|
# Then targets like `check_utf8`, `check_python`, etc will run the runtime
|
|
1205
1234
|
# tests for a particular target language.
|
|
1206
1235
|
#
|
|
1207
1236
|
# Once you're done, switch the tree back to the normal state:
|
|
1208
1237
|
#
|
|
1209
|
-
# make
|
|
1238
|
+
# make clean_runtime_tests
|
|
1210
1239
|
|
|
1211
1240
|
.PHONY: setup_runtime_tests clean_runtime_tests
|
|
1212
1241
|
|
|
@@ -1219,12 +1248,13 @@ setup_runtime_tests: clean_runtime_tests
|
|
|
1219
1248
|
d=`echo "$$t"|sed 's/\.sbl$$//'` ;\
|
|
1220
1249
|
mkdir $$r/$$d ;\
|
|
1221
1250
|
echo ok > $$r/$$d/voc.txt ;\
|
|
1222
|
-
echo ok > $$r/$$d/output.txt ;\
|
|
1251
|
+
if [ -f $$d.out ] ; then cp $$d.out $$r/$$d/output.txt ; else echo ok > $$r/$$d/output.txt ; fi ;\
|
|
1223
1252
|
echo "$$d UTF_8,ISO_8859_1 $$d" >> $$r/modules.txt ;\
|
|
1224
1253
|
done
|
|
1225
1254
|
printf '%s:=%s\n' \
|
|
1226
1255
|
ALGORITHMS 'tests/runtime' \
|
|
1227
1256
|
BASELINE 'rbaseline' \
|
|
1257
|
+
EXTRA_TESTS '' \
|
|
1228
1258
|
MODULES '$(RUNTIME_DATA_DIR)/modules.txt' \
|
|
1229
1259
|
other_algorithms '' \
|
|
1230
1260
|
SNOWBALL_FLAGS '-comments' \
|
|
@@ -1234,5 +1264,5 @@ setup_runtime_tests: clean_runtime_tests
|
|
|
1234
1264
|
rm -f algorithms.mk
|
|
1235
1265
|
$(MAKE) algorithms.mk
|
|
1236
1266
|
|
|
1237
|
-
clean_runtime_tests:
|
|
1267
|
+
clean_runtime_tests: clean
|
|
1238
1268
|
rm -rf $(RUNTIME_DATA_DIR) overrides.mk
|