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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/README.md +2 -2
- data/Rakefile +10 -3
- 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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
struct token {
|
|
2
|
+
byte code; /* Token code (from enum token_code) */
|
|
3
|
+
byte s_size; /* Size of token */
|
|
4
|
+
const char s[14]; /* Token */
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/* List of alphabetical tokens and their corresponding codes (symbol tokens are
|
|
8
|
+
* instead handled using `switch` in tokenise.c).
|
|
9
|
+
*
|
|
10
|
+
* Tokens below are ordered primarily by length, then by ASCII collating
|
|
11
|
+
* order amongst tokens of the same length.
|
|
12
|
+
*/
|
|
13
|
+
static const struct token alpha_tokens[] = {
|
|
14
|
+
{ c_as, 2, "as" },
|
|
15
|
+
{ c_do, 2, "do" },
|
|
16
|
+
{ c_or, 2, "or" },
|
|
17
|
+
{ c_and, 3, "and" },
|
|
18
|
+
{ c_for, 3, "for" },
|
|
19
|
+
{ c_get, 3, "get" },
|
|
20
|
+
{ c_hex, 3, "hex" },
|
|
21
|
+
{ c_hop, 3, "hop" },
|
|
22
|
+
{ c_len, 3, "len" },
|
|
23
|
+
{ c_non, 3, "non" },
|
|
24
|
+
{ c_not, 3, "not" },
|
|
25
|
+
{ c_set, 3, "set" },
|
|
26
|
+
{ c_try, 3, "try" },
|
|
27
|
+
{ c_fail, 4, "fail" },
|
|
28
|
+
{ c_goto, 4, "goto" },
|
|
29
|
+
{ c_loop, 4, "loop" },
|
|
30
|
+
{ c_next, 4, "next" },
|
|
31
|
+
{ c_size, 4, "size" },
|
|
32
|
+
{ c_test, 4, "test" },
|
|
33
|
+
{ c_true, 4, "true" },
|
|
34
|
+
{ c_among, 5, "among" },
|
|
35
|
+
{ c_false, 5, "false" },
|
|
36
|
+
{ c_lenof, 5, "lenof" },
|
|
37
|
+
{ c_limit, 5, "limit" },
|
|
38
|
+
{ c_unset, 5, "unset" },
|
|
39
|
+
{ c_atmark, 6, "atmark" },
|
|
40
|
+
{ c_attach, 6, "attach" },
|
|
41
|
+
{ c_cursor, 6, "cursor" },
|
|
42
|
+
{ c_define, 6, "define" },
|
|
43
|
+
{ c_delete, 6, "delete" },
|
|
44
|
+
{ c_gopast, 6, "gopast" },
|
|
45
|
+
{ c_insert, 6, "insert" },
|
|
46
|
+
{ c_maxint, 6, "maxint" },
|
|
47
|
+
{ c_minint, 6, "minint" },
|
|
48
|
+
{ c_repeat, 6, "repeat" },
|
|
49
|
+
{ c_sizeof, 6, "sizeof" },
|
|
50
|
+
{ c_tomark, 6, "tomark" },
|
|
51
|
+
{ c_atleast, 7, "atleast" },
|
|
52
|
+
{ c_atlimit, 7, "atlimit" },
|
|
53
|
+
{ c_decimal, 7, "decimal" },
|
|
54
|
+
{ c_reverse, 7, "reverse" },
|
|
55
|
+
{ c_setmark, 7, "setmark" },
|
|
56
|
+
{ c_strings, 7, "strings" },
|
|
57
|
+
{ c_tolimit, 7, "tolimit" },
|
|
58
|
+
{ c_booleans, 8, "booleans" },
|
|
59
|
+
{ c_integers, 8, "integers" },
|
|
60
|
+
{ c_routines, 8, "routines" },
|
|
61
|
+
{ c_setlimit, 8, "setlimit" },
|
|
62
|
+
{ c_backwards, 9, "backwards" },
|
|
63
|
+
{ c_externals, 9, "externals" },
|
|
64
|
+
{ c_groupings, 9, "groupings" },
|
|
65
|
+
{ c_stringdef, 9, "stringdef" },
|
|
66
|
+
{ c_substring, 9, "substring" },
|
|
67
|
+
{ c_backwardmode, 12, "backwardmode" },
|
|
68
|
+
{ c_stringescapes, 13, "stringescapes" }
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
#define NUM_ALPHA_TOKENS ((int)(sizeof(alpha_tokens) / sizeof(alpha_tokens[0])))
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
// Copyright (c) 2001, Dr Martin Porter
|
|
2
2
|
// Copyright (c) 2002, Richard Boulton
|
|
3
3
|
// Copyright (c) 2015, Cesar Souza
|
|
4
|
+
// Copyright (c) 2025, Olly Betts
|
|
4
5
|
// All rights reserved.
|
|
5
6
|
//
|
|
6
7
|
// Redistribution and use in source and binary forms, with or without
|
|
7
8
|
// modification, are permitted provided that the following conditions are met:
|
|
8
9
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
10
|
+
// 1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
// this list of conditions and the following disclaimer.
|
|
12
|
+
// 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
// notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
// documentation and/or other materials provided with the distribution.
|
|
15
|
+
// 3. Neither the name of the Snowball project nor the names of its contributors
|
|
16
|
+
// may be used to endorse or promote products derived from this software
|
|
17
|
+
// without specific prior written permission.
|
|
17
18
|
//
|
|
18
19
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
20
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
@@ -56,10 +57,10 @@ namespace Snowball
|
|
|
56
57
|
public int Result { get; private set; }
|
|
57
58
|
|
|
58
59
|
/// <summary>
|
|
59
|
-
///
|
|
60
|
+
/// Condition function index (or 0 for no condition).
|
|
60
61
|
/// </summary>
|
|
61
62
|
///
|
|
62
|
-
public
|
|
63
|
+
public int Condition { get; private set; }
|
|
63
64
|
|
|
64
65
|
/// <summary>
|
|
65
66
|
/// Initializes a new instance of the <see cref="Among"/> class.
|
|
@@ -68,27 +69,14 @@ namespace Snowball
|
|
|
68
69
|
/// <param name="str">The search string.</param>
|
|
69
70
|
/// <param name="index">The index to the longest matching substring.</param>
|
|
70
71
|
/// <param name="result">The result of the lookup.</param>
|
|
72
|
+
/// <param name="condition">The index of the condition function (0 if none).</param>
|
|
71
73
|
///
|
|
72
|
-
public Among(String str, int index, int result)
|
|
73
|
-
: this(str, index, result, null)
|
|
74
|
-
{
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/// <summary>
|
|
78
|
-
/// Initializes a new instance of the <see cref="Among"/> class.
|
|
79
|
-
/// </summary>
|
|
80
|
-
///
|
|
81
|
-
/// <param name="str">The search string.</param>
|
|
82
|
-
/// <param name="index">The index to the longest matching substring.</param>
|
|
83
|
-
/// <param name="result">The result of the lookup.</param>
|
|
84
|
-
/// <param name="action">The action to be performed, if any.</param>
|
|
85
|
-
///
|
|
86
|
-
public Among(String str, int index, int result, Func<bool> action)
|
|
74
|
+
public Among(String str, int index, int result, int condition)
|
|
87
75
|
{
|
|
88
76
|
this.SearchString = str;
|
|
89
77
|
this.MatchIndex = index;
|
|
90
78
|
this.Result = result;
|
|
91
|
-
this.
|
|
79
|
+
this.Condition = condition;
|
|
92
80
|
}
|
|
93
81
|
|
|
94
82
|
/// <summary>
|
|
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|
|
10
10
|
[assembly: AssemblyConfiguration("")]
|
|
11
11
|
[assembly: AssemblyCompany("")]
|
|
12
12
|
[assembly: AssemblyProduct("Snowball")]
|
|
13
|
-
[assembly: AssemblyCopyright("Copyright © 2015-
|
|
13
|
+
[assembly: AssemblyCopyright("Copyright © 2015-2025")]
|
|
14
14
|
[assembly: AssemblyTrademark("")]
|
|
15
15
|
[assembly: AssemblyCulture("")]
|
|
16
16
|
|
|
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|
|
32
32
|
// You can specify all the values or you can default the Build and Revision Numbers
|
|
33
33
|
// by using the '*' as shown below:
|
|
34
34
|
// [assembly: AssemblyVersion("1.0.*")]
|
|
35
|
-
[assembly: AssemblyVersion(/*SNOWBALL_VERSION*/"3.
|
|
36
|
-
[assembly: AssemblyFileVersion(/*SNOWBALL_VERSION*/"3.
|
|
35
|
+
[assembly: AssemblyVersion(/*SNOWBALL_VERSION*/"3.1.1.0")]
|
|
36
|
+
[assembly: AssemblyFileVersion(/*SNOWBALL_VERSION*/"3.1.1.0")]
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// Copyright (c) 2001, Dr Martin Porter
|
|
2
2
|
// Copyright (c) 2002, Richard Boulton
|
|
3
3
|
// Copyright (c) 2015, Cesar Souza
|
|
4
|
-
// Copyright (c) 2018, Olly Betts
|
|
4
|
+
// Copyright (c) 2018-2026, Olly Betts
|
|
5
5
|
// All rights reserved.
|
|
6
6
|
//
|
|
7
7
|
// Redistribution and use in source and binary forms, with or without
|
|
8
8
|
// modification, are permitted provided that the following conditions are met:
|
|
9
9
|
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
10
|
+
// 1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
// this list of conditions and the following disclaimer.
|
|
12
|
+
// 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
// notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
// documentation and/or other materials provided with the distribution.
|
|
15
|
+
// 3. Neither the name of the Snowball project nor the names of its contributors
|
|
16
|
+
// may be used to endorse or promote products derived from this software
|
|
17
|
+
// without specific prior written permission.
|
|
18
18
|
//
|
|
19
19
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
20
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
namespace Snowball
|
|
31
31
|
{
|
|
32
32
|
using System;
|
|
33
|
+
using System.Diagnostics;
|
|
33
34
|
using System.Linq;
|
|
34
35
|
using System.Text;
|
|
35
36
|
|
|
@@ -48,7 +49,7 @@ namespace Snowball
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
/// <summary>
|
|
51
|
-
///
|
|
52
|
+
/// The current string.
|
|
52
53
|
/// </summary>
|
|
53
54
|
///
|
|
54
55
|
protected StringBuilder current;
|
|
@@ -72,13 +73,13 @@ namespace Snowball
|
|
|
72
73
|
protected int limit_backward;
|
|
73
74
|
|
|
74
75
|
/// <summary>
|
|
75
|
-
///
|
|
76
|
+
/// Start of the slice.
|
|
76
77
|
/// </summary>
|
|
77
78
|
///
|
|
78
79
|
protected int bra;
|
|
79
80
|
|
|
80
81
|
/// <summary>
|
|
81
|
-
///
|
|
82
|
+
/// End of the slice.
|
|
82
83
|
/// </summary>
|
|
83
84
|
///
|
|
84
85
|
protected int ket;
|
|
@@ -114,6 +115,12 @@ namespace Snowball
|
|
|
114
115
|
///
|
|
115
116
|
public abstract class Stemmer : Env
|
|
116
117
|
{
|
|
118
|
+
/// <summary>
|
|
119
|
+
/// Among function being called.
|
|
120
|
+
/// </summary>
|
|
121
|
+
///
|
|
122
|
+
protected int af;
|
|
123
|
+
|
|
117
124
|
/// <summary>
|
|
118
125
|
/// Initializes a new instance of the <see cref="Stemmer"/> class.
|
|
119
126
|
/// </summary>
|
|
@@ -390,7 +397,7 @@ namespace Snowball
|
|
|
390
397
|
/// forward.
|
|
391
398
|
/// </summary>
|
|
392
399
|
///
|
|
393
|
-
protected int find_among(Among[] v)
|
|
400
|
+
protected int find_among(Among[] v, Func<bool> call_among_func)
|
|
394
401
|
{
|
|
395
402
|
int i = 0;
|
|
396
403
|
int j = v.Length;
|
|
@@ -465,14 +472,14 @@ namespace Snowball
|
|
|
465
472
|
{
|
|
466
473
|
cursor = c + w.SearchString.Length;
|
|
467
474
|
|
|
468
|
-
if (w.
|
|
475
|
+
if (w.Condition == 0)
|
|
469
476
|
return w.Result;
|
|
470
477
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
if (res)
|
|
478
|
+
af = w.Condition;
|
|
479
|
+
if (call_among_func()) {
|
|
480
|
+
cursor = c + w.SearchString.Length;
|
|
475
481
|
return w.Result;
|
|
482
|
+
}
|
|
476
483
|
}
|
|
477
484
|
|
|
478
485
|
i = w.MatchIndex;
|
|
@@ -488,7 +495,7 @@ namespace Snowball
|
|
|
488
495
|
/// backwards.
|
|
489
496
|
/// </summary>
|
|
490
497
|
///
|
|
491
|
-
protected int find_among_b(Among[] v)
|
|
498
|
+
protected int find_among_b(Among[] v, Func<bool> call_among_func)
|
|
492
499
|
{
|
|
493
500
|
int i = 0;
|
|
494
501
|
int j = v.Length;
|
|
@@ -558,14 +565,14 @@ namespace Snowball
|
|
|
558
565
|
{
|
|
559
566
|
cursor = c - w.SearchString.Length;
|
|
560
567
|
|
|
561
|
-
if (w.
|
|
568
|
+
if (w.Condition == 0)
|
|
562
569
|
return w.Result;
|
|
563
570
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
if (res)
|
|
571
|
+
af = w.Condition;
|
|
572
|
+
if (call_among_func()) {
|
|
573
|
+
cursor = c - w.SearchString.Length;
|
|
568
574
|
return w.Result;
|
|
575
|
+
}
|
|
569
576
|
}
|
|
570
577
|
|
|
571
578
|
i = w.MatchIndex;
|
|
@@ -597,25 +604,26 @@ namespace Snowball
|
|
|
597
604
|
/// </summary>
|
|
598
605
|
protected void slice_check()
|
|
599
606
|
{
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
607
|
+
Debug.Assert(bra >= 0);
|
|
608
|
+
Debug.Assert(bra <= ket);
|
|
609
|
+
Debug.Assert(ket <= limit);
|
|
610
|
+
Debug.Assert(limit <= current.Length);
|
|
604
611
|
}
|
|
605
612
|
|
|
606
613
|
/// <summary>
|
|
607
|
-
/// Replaces the contents of the
|
|
614
|
+
/// Replaces the contents of the slice with the string s.
|
|
608
615
|
/// </summary>
|
|
609
616
|
///
|
|
610
|
-
/// <param name="s">The
|
|
617
|
+
/// <param name="s">The string.</param>
|
|
611
618
|
protected void slice_from(String s)
|
|
612
619
|
{
|
|
613
620
|
slice_check();
|
|
614
621
|
replace_s(bra, ket, s);
|
|
622
|
+
ket = bra + s.Length;
|
|
615
623
|
}
|
|
616
624
|
|
|
617
625
|
/// <summary>
|
|
618
|
-
/// Removes the current
|
|
626
|
+
/// Removes the current slice contents.
|
|
619
627
|
/// </summary>
|
|
620
628
|
///
|
|
621
629
|
protected void slice_del()
|
|
@@ -635,18 +643,7 @@ namespace Snowball
|
|
|
635
643
|
}
|
|
636
644
|
|
|
637
645
|
/// <summary>
|
|
638
|
-
/// Replaces the contents of
|
|
639
|
-
/// </summary>
|
|
640
|
-
///
|
|
641
|
-
protected void insert(int c_bra, int c_ket, StringBuilder s)
|
|
642
|
-
{
|
|
643
|
-
int adjustment = replace_s(c_bra, c_ket, s.ToString());
|
|
644
|
-
if (c_bra <= bra) bra += adjustment;
|
|
645
|
-
if (c_bra <= ket) ket += adjustment;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/// <summary>
|
|
649
|
-
/// Replaces the contents of the bracket with the string s.
|
|
646
|
+
/// Replaces the contents of s with the slice.
|
|
650
647
|
/// </summary>
|
|
651
648
|
///
|
|
652
649
|
protected void slice_to(StringBuilder s)
|
|
@@ -669,11 +666,10 @@ namespace Snowball
|
|
|
669
666
|
/// <summary>
|
|
670
667
|
/// Replaces a specific region of the buffer with another text.
|
|
671
668
|
/// </summary>
|
|
672
|
-
public static
|
|
669
|
+
public static void Replace(StringBuilder sb, int index, int length, string text)
|
|
673
670
|
{
|
|
674
671
|
sb.Remove(index, length - index);
|
|
675
672
|
sb.Insert(index, text);
|
|
676
|
-
return sb;
|
|
677
673
|
}
|
|
678
674
|
|
|
679
675
|
}
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
// Redistribution and use in source and binary forms, with or without
|
|
8
8
|
// modification, are permitted provided that the following conditions are met:
|
|
9
9
|
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
10
|
+
// 1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
// this list of conditions and the following disclaimer.
|
|
12
|
+
// 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
// notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
// documentation and/or other materials provided with the distribution.
|
|
15
|
+
// 3. Neither the name of the Snowball project nor the names of its contributors
|
|
16
|
+
// may be used to endorse or promote products derived from this software
|
|
17
|
+
// without specific prior written permission.
|
|
18
18
|
//
|
|
19
19
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
20
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
@@ -86,16 +86,22 @@ namespace Snowball
|
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
Console.WriteLine("Using " + stemmer.GetType());
|
|
90
|
-
|
|
91
|
-
TextWriter output = System.Console.Out;
|
|
92
|
-
if (outputName != null)
|
|
93
|
-
output = new StreamWriter(outputName);
|
|
94
|
-
|
|
95
89
|
TextReader input = System.Console.In;
|
|
96
90
|
if (inputName != null)
|
|
97
91
|
input = new StreamReader(inputName);
|
|
98
92
|
|
|
93
|
+
TextWriter output;
|
|
94
|
+
if (outputName != null) {
|
|
95
|
+
output = new StreamWriter(outputName);
|
|
96
|
+
} else {
|
|
97
|
+
// For some reason this is much faster than using
|
|
98
|
+
// System.Console.Out, at least with mono on Linux.
|
|
99
|
+
//
|
|
100
|
+
// `make check_sharp_tamil` takes 0.842s wallclock instead of
|
|
101
|
+
// 1.848s.
|
|
102
|
+
output = new StreamWriter(Console.OpenStandardOutput());
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
while (true)
|
|
100
106
|
{
|
|
101
107
|
var line = input.ReadLine();
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env perl
|
|
2
|
+
use strict;
|
|
3
|
+
use 5.006;
|
|
4
|
+
use warnings;
|
|
5
|
+
|
|
6
|
+
my $progname = $0;
|
|
7
|
+
|
|
8
|
+
if (scalar @ARGV != 2) {
|
|
9
|
+
print "Usage: $progname <outfile> <modules description file>\n";
|
|
10
|
+
exit 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
my $outname = shift(@ARGV);
|
|
14
|
+
my $modules = shift(@ARGV);
|
|
15
|
+
|
|
16
|
+
my @algorithms_by_length = ();
|
|
17
|
+
|
|
18
|
+
my %algorithm_name = ();
|
|
19
|
+
|
|
20
|
+
sub add_name {
|
|
21
|
+
my ($alias, $name) = @_;
|
|
22
|
+
$algorithm_name{$alias} = $name;
|
|
23
|
+
push @{$algorithms_by_length[length($alias)]}, $alias;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
open my $out, '>', $outname or die "Can't open output file '$outname': $!\n";
|
|
27
|
+
|
|
28
|
+
print $out <<END;
|
|
29
|
+
#include "stemmer.h"
|
|
30
|
+
END
|
|
31
|
+
|
|
32
|
+
open my $in, '<', $modules or die $!;
|
|
33
|
+
while (<$in>) {
|
|
34
|
+
next if m/^\s*#/;
|
|
35
|
+
next if m/^\s*$/;
|
|
36
|
+
my ($alg, $encstr, $aliases) = split(/\s+/, $_);
|
|
37
|
+
|
|
38
|
+
print $out <<END;
|
|
39
|
+
#include "${alg}_stemmer.h"
|
|
40
|
+
END
|
|
41
|
+
foreach my $alias (split(/,/, $aliases)) {
|
|
42
|
+
add_name($alias, $alg);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
close $in;
|
|
46
|
+
|
|
47
|
+
print $out <<END;
|
|
48
|
+
// $outname: Snowball stemmer factory
|
|
49
|
+
//
|
|
50
|
+
// This file is generated by $0 from a list of module names.
|
|
51
|
+
// Do not edit manually.
|
|
52
|
+
|
|
53
|
+
#include <string.h>
|
|
54
|
+
|
|
55
|
+
namespace Snowball {
|
|
56
|
+
|
|
57
|
+
Stemmer* make_stemmer(const char* language)
|
|
58
|
+
{
|
|
59
|
+
switch (strlen(language)) {
|
|
60
|
+
END
|
|
61
|
+
|
|
62
|
+
for (my $i = 1; $i < @algorithms_by_length; ++$i) {
|
|
63
|
+
my $l = $algorithms_by_length[$i];
|
|
64
|
+
next unless defined $l;
|
|
65
|
+
print $out <<END;
|
|
66
|
+
case $i:
|
|
67
|
+
END
|
|
68
|
+
for (@$l) {
|
|
69
|
+
my $class = $algorithm_name{$_};
|
|
70
|
+
$class =~ s/_(.)/\U$1/g;
|
|
71
|
+
$class = ucfirst $class . "Stemmer";
|
|
72
|
+
print $out <<END;
|
|
73
|
+
if (memcmp(language, "$_", $i) == 0) return new Snowball::$class();
|
|
74
|
+
END
|
|
75
|
+
}
|
|
76
|
+
print $out <<END;
|
|
77
|
+
break;
|
|
78
|
+
END
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
print $out <<END;
|
|
82
|
+
}
|
|
83
|
+
return NULL;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
END
|