natural 6.12.0 → 7.0.0

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 (108) hide show
  1. package/.env +2 -1
  2. package/.eslintrc.json +13 -0
  3. package/.github/workflows/node.js.yml +3 -6
  4. package/lib/natural/analyzers/SenType.ts +30 -0
  5. package/lib/natural/analyzers/index.d.ts +6 -10
  6. package/lib/natural/brill_pos_tagger/index.d.ts +23 -14
  7. package/lib/natural/brill_pos_tagger/index.js +1 -1
  8. package/lib/natural/classifiers/bayes_classifier.js +1 -1
  9. package/lib/natural/classifiers/classifier.js +11 -34
  10. package/lib/natural/classifiers/classifier_train_parallel.js +7 -5
  11. package/lib/natural/classifiers/index.d.ts +36 -15
  12. package/lib/natural/classifiers/maxent/Classifier.js +5 -3
  13. package/lib/natural/distance/index.d.ts +11 -14
  14. package/lib/natural/inflectors/count_inflector.js +18 -21
  15. package/lib/natural/inflectors/fr/count_inflector.js +18 -19
  16. package/lib/natural/inflectors/index.d.ts +12 -3
  17. package/lib/natural/inflectors/index.js +3 -0
  18. package/lib/natural/ngrams/index.d.ts +5 -5
  19. package/lib/natural/normalizers/index.d.ts +24 -1
  20. package/lib/natural/normalizers/index.js +4 -1
  21. package/lib/natural/normalizers/normalizer_ja.js +109 -72
  22. package/lib/natural/phonetics/dm_soundex.js +52 -51
  23. package/lib/natural/phonetics/double_metaphone.js +397 -399
  24. package/lib/natural/phonetics/index.d.ts +42 -12
  25. package/lib/natural/phonetics/metaphone.js +134 -157
  26. package/lib/natural/phonetics/phonetic.js +5 -29
  27. package/lib/natural/phonetics/soundex.js +45 -54
  28. package/lib/natural/sentiment/index.d.ts +6 -6
  29. package/lib/natural/spellcheck/index.d.ts +2 -0
  30. package/lib/natural/stemmers/index.d.ts +43 -1
  31. package/lib/natural/stemmers/index.js +1 -0
  32. package/lib/natural/stemmers/token.js +131 -132
  33. package/lib/natural/tfidf/index.d.ts +7 -7
  34. package/lib/natural/tfidf/tfidf.js +7 -1
  35. package/lib/natural/tokenizers/index.d.ts +2 -2
  36. package/lib/natural/trie/index.d.ts +1 -1
  37. package/lib/natural/util/index.d.ts +8 -0
  38. package/lib/natural/util/index.js +2 -0
  39. package/lib/natural/util/storage/index.d.ts +39 -0
  40. package/lib/natural/util/storage/index.js +24 -0
  41. package/package.json +22 -9
  42. package/ts_spec/MaxEntClassifier_spec.ts +130 -0
  43. package/ts_spec/SentimentAnalyzer_spec.ts +232 -0
  44. package/ts_spec/WordPunctTokenizer_spec.ts +57 -0
  45. package/ts_spec/aggressive_tokenizer_de_spec.ts +36 -0
  46. package/ts_spec/aggressive_tokenizer_es_spec.ts +39 -0
  47. package/ts_spec/aggressive_tokenizer_fr_spec.ts +111 -0
  48. package/ts_spec/aggressive_tokenizer_hi_spec.ts +70 -0
  49. package/ts_spec/aggressive_tokenizer_nl_spec.ts +39 -0
  50. package/ts_spec/aggressive_tokenizer_pt_spec.ts +48 -0
  51. package/ts_spec/aggressive_tokenizer_spec.ts +57 -0
  52. package/ts_spec/aggressive_tokenizer_sv_spec.ts +52 -0
  53. package/ts_spec/aggressive_tokenizer_vi_spec.ts +48 -0
  54. package/ts_spec/bayes_classifier_spec.ts +165 -0
  55. package/ts_spec/brill_pos_tagger_spec.ts +79 -0
  56. package/ts_spec/brill_pos_trainer_spec.ts +107 -0
  57. package/ts_spec/carry_stemmer_fr_spec.ts +97 -0
  58. package/ts_spec/classifier_spec.ts +104 -0
  59. package/ts_spec/count_inflector_fr_spec.ts +47 -0
  60. package/ts_spec/count_inflector_spec.ts +76 -0
  61. package/ts_spec/damerau_levenshtein_spec.ts +53 -0
  62. package/ts_spec/dice_coefficient_spec.ts +37 -0
  63. package/ts_spec/double_metaphone_spec.ts +739 -0
  64. package/ts_spec/hamming_distance_spec.ts +66 -0
  65. package/ts_spec/jaro-winkler_spec.ts +79 -0
  66. package/ts_spec/lancaster_stemmer_spec.ts +63 -0
  67. package/ts_spec/levenshtein_spec.ts +107 -0
  68. package/ts_spec/logistic_regression_classifier_spec.ts +93 -0
  69. package/ts_spec/longest_path_tree_spec.ts +111 -0
  70. package/ts_spec/metaphone_spec.ts +258 -0
  71. package/ts_spec/ngram_spec.ts +145 -0
  72. package/ts_spec/ngram_zh_spec.ts +124 -0
  73. package/ts_spec/normalizer_ja_spec.ts +165 -0
  74. package/ts_spec/normalizer_no_spec.ts +112 -0
  75. package/ts_spec/normalizer_spec.ts +141 -0
  76. package/ts_spec/noun_inflector_fr_spec.ts +472 -0
  77. package/ts_spec/noun_inflector_ja_spec.ts +116 -0
  78. package/ts_spec/noun_inflector_spec.ts +369 -0
  79. package/ts_spec/orthography_tokenizer_spec.ts +47 -0
  80. package/ts_spec/porter_stemmer_de_spec.ts +53 -0
  81. package/ts_spec/porter_stemmer_es_spec.ts +63 -0
  82. package/ts_spec/porter_stemmer_fr_spec.ts +103 -0
  83. package/ts_spec/porter_stemmer_it_spec.ts +56 -0
  84. package/ts_spec/porter_stemmer_nl_spec.ts +73 -0
  85. package/ts_spec/porter_stemmer_no_spec.ts +148 -0
  86. package/ts_spec/porter_stemmer_pt_spec.ts +50 -0
  87. package/ts_spec/porter_stemmer_ru_spec.ts +67 -0
  88. package/ts_spec/porter_stemmer_spec.ts +202 -0
  89. package/ts_spec/porter_stemmer_sv_spec.ts +41 -0
  90. package/ts_spec/present_verb_inflector_spec.ts +127 -0
  91. package/ts_spec/remove_diacritics_spec.ts +30 -0
  92. package/ts_spec/sentence_analyzer_spec.ts +293 -0
  93. package/ts_spec/sentence_tokenizer_parser_spec.ts +200 -0
  94. package/ts_spec/sentence_tokenizer_spec.ts +189 -0
  95. package/ts_spec/shortest_path_tree_spec.ts +141 -0
  96. package/ts_spec/soundex_spec.ts +162 -0
  97. package/ts_spec/spellcheck_spec.ts +112 -0
  98. package/ts_spec/stemmer_id_spec.ts +374 -0
  99. package/ts_spec/stemmer_ja_spec.ts +69 -0
  100. package/ts_spec/stemmer_token_spec.ts +163 -0
  101. package/ts_spec/tfidf_spec.ts +275 -0
  102. package/ts_spec/tokenizer_case_spec.ts +242 -0
  103. package/ts_spec/tokenizer_ja_spec.ts +63 -0
  104. package/ts_spec/transliterator_ja_spec.ts +105 -0
  105. package/ts_spec/treebank_word_tokenizer_spec.ts +38 -0
  106. package/ts_spec/trie_spec.ts +197 -0
  107. package/tsconfig.json +5 -3
  108. package/example.txt +0 -1
@@ -0,0 +1,105 @@
1
+ /*
2
+ Copyright (c) 2012, Guillaume Marty
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+ */
22
+
23
+ 'use strict'
24
+
25
+ import { TransliterateJa as transliterateJa } from 'lib/natural'
26
+
27
+ describe('transliterateJa', function () {
28
+ it('should transliterate hiragana', function () {
29
+ expect(transliterateJa('あいうえお かきくけこ')).toEqual('aiueo kakikukeko')
30
+ expect(transliterateJa('さしすせそ たちつてと')).toEqual('sashisuseso tachitsuteto')
31
+ })
32
+
33
+ it('should transliterate katakana', function () {
34
+ expect(transliterateJa('アイウエオ カキクケコ')).toEqual('aiueo kakikukeko')
35
+ expect(transliterateJa('サシスセソ タチツテト')).toEqual('sashisuseso tachitsuteto')
36
+ })
37
+
38
+ it('should transliterate small tsu differently depending on context', function () {
39
+ expect(transliterateJa('まっか ざっし たった はっぱ')).toEqual('makka zasshi tatta happa')
40
+ expect(transliterateJa('マッカ ザッシ タッタ ハッパ')).toEqual('makka zasshi tatta happa')
41
+ })
42
+
43
+ it('should transliterate final small tsu', function () {
44
+ expect(transliterateJa('ああっ')).toEqual('aat')
45
+ expect(transliterateJa('アアッ')).toEqual('aat')
46
+ })
47
+
48
+ it('should transliterate n differently depending on context', function () {
49
+ expect(transliterateJa('まんと ばんび ほんや')).toEqual("manto bambi hon'ya")
50
+ expect(transliterateJa('マント バンビ ホンヤ')).toEqual("manto bambi hon'ya")
51
+ })
52
+
53
+ it('should transliterate long vowels', function () {
54
+ expect(transliterateJa('ああ いい うう ええ おお おう')).toEqual('aa ii ū ee oo ō')
55
+ expect(transliterateJa('あー いー うー えー おー')).toEqual('ā ī ū ē ō')
56
+ expect(transliterateJa('アア イイ ウウ エエ オオ オウ')).toEqual('aa ii ū ee oo ō')
57
+ expect(transliterateJa('アー イー ウー エー オー')).toEqual('ā ī ū ē ō')
58
+ })
59
+
60
+ it('should leave non fullwidth kana unchanged', function () {
61
+ expect(transliterateJa('abc ABC 漢字 (.)')).toEqual('abc ABC 漢字 (.)')
62
+ expect(transliterateJa('アイウエオ カキクケコ')).toEqual('アイウエオ カキクケコ')
63
+ })
64
+
65
+ it('should transliterate misc. words correctly', function () {
66
+ expect(transliterateJa('アヴァンギャルド')).toEqual('avangyarudo') // Avant-garde
67
+ expect(transliterateJa('アクサン・スィルコンフレックス')).toEqual('akusan sirukonfurekkusu') // Accent circonflexe
68
+ expect(transliterateJa('アドレシッング')).toEqual('adoreshinngu') // Addressing
69
+ expect(transliterateJa('イェス')).toEqual('yesu') // Yes
70
+ expect(transliterateJa('インテリジェンス')).toEqual('interijensu') // Intelligence
71
+ expect(transliterateJa('インテルメッツォ')).toEqual('interumettso') // Intermezzo
72
+ expect(transliterateJa('グァテマラ')).toEqual('gwatemara') // Guatemala
73
+ expect(transliterateJa('クァルテット')).toEqual('kwarutetto') // Quartet
74
+ expect(transliterateJa('クィンテット')).toEqual('kwintetto') // Quintet
75
+ expect(transliterateJa('クォーター')).toEqual('kwōtā') // Quarter
76
+ expect(transliterateJa('サブウーファー')).toEqual('sabuūfā') // Sub woofer
77
+ expect(transliterateJa('ソフトウェア')).toEqual('sofutowea') // Software
78
+ expect(transliterateJa('ツィーター')).toEqual('tsītā') // Tweeter
79
+ expect(transliterateJa('デューティー')).toEqual('dyūtī') // Duty
80
+ expect(transliterateJa('ドキュメントィンドウ')).toEqual('dokyumentwindō') // Document window
81
+ expect(transliterateJa('ヌーヴェルヴァーグ')).toEqual('nūveruvāgu') // Nouvelle vague
82
+ expect(transliterateJa('ハイジャッンプ')).toEqual('haijanmpu') // High jump
83
+ expect(transliterateJa('バッファ')).toEqual('baffa') // Buffer
84
+ expect(transliterateJa('フーホェア')).toEqual('fūhwea') // WhoWhere?
85
+ expect(transliterateJa('フェイズィング')).toEqual('feizingu') // Phasing
86
+ expect(transliterateJa('フッロピー')).toEqual('furropī') // Floppy (alternative transcription)
87
+ expect(transliterateJa('ブュー')).toEqual('byū') // View
88
+ expect(transliterateJa('フューチャー')).toEqual('fyūchā') // Future
89
+ expect(transliterateJa('フロッピィ')).toEqual('furoppī') // Floppy
90
+ expect(transliterateJa('ボージョレー・ヌーヴォー')).toEqual('bōjorē nūvō') // Beaujolais nouveau
91
+ expect(transliterateJa('ボスニア・ヘルツェゴビナ')).toEqual('bosunia herutsegobina') // Bosnia and Herzegovina
92
+ expect(transliterateJa('マッハ')).toEqual('mahha') // Mach
93
+ expect(transliterateJa('レヴュー')).toEqual('revyū') // Review
94
+ expect(transliterateJa('レクリェーション')).toEqual('rekuryēshon') // Recreation
95
+ })
96
+
97
+ it('should use fallback for small vowels on special case', function () {
98
+ // These words use rare combination of small vowels.
99
+ expect(transliterateJa('アゲィンスト')).toEqual('ageinsuto') // Against (alternative transcription)
100
+ expect(transliterateJa('エッセィ')).toEqual('essei') // Essay (alternative transcription)
101
+ expect(transliterateJa('ゾゥアラジィ')).toEqual('zouarajī') // Zoology (alternative transcription)
102
+ expect(transliterateJa('ゾゥァラジカル')).toEqual('zouarajikaru') // Zoological (alternative transcription)
103
+ expect(transliterateJa('ボランテァ')).toEqual('borantea') // Volunteer (alternative transcription)
104
+ })
105
+ })
@@ -0,0 +1,38 @@
1
+ /*
2
+ Copyright (c) 2011, Chris Umbel
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+ */
22
+
23
+ 'use strict'
24
+
25
+ import { TreebankWordTokenizer as Tokenizer } from 'lib/natural'
26
+ const tokenizer = new Tokenizer()
27
+
28
+ describe('treebank', function () {
29
+ it('should tokenize', function () {
30
+ let tokens = tokenizer.tokenize("If we 'all' can't go. I'll stay home.")
31
+ expect(tokens).toEqual(['If', 'we', "'all", "'", 'ca', "n't", 'go.',
32
+ 'I', "'ll", 'stay', 'home', '.'])
33
+
34
+ tokens = tokenizer.tokenize("If we 'all' can't go. I'll stay home. If we 'all' can't go. I'll stay home.")
35
+ expect(tokens).toEqual(['If', 'we', "'all", "'", 'ca', "n't", 'go.',
36
+ 'I', "'ll", 'stay', 'home.', 'If', 'we', "'all", "'", 'ca', "n't", 'go.', 'I', "'ll", 'stay', 'home', '.'])
37
+ })
38
+ })
@@ -0,0 +1,197 @@
1
+ /*
2
+ Copyright (c) 2014 Ken Koch
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+ */
22
+
23
+ 'use strict'
24
+
25
+ import { Trie } from 'lib/natural'
26
+
27
+ describe('trie', function () {
28
+ describe('adding strings', function () {
29
+ it('should add words one at a time', function () {
30
+ const trie = new Trie()
31
+ trie.addString('test')
32
+ expect(trie.contains('test')).toBe(true)
33
+
34
+ trie.addString('abcd')
35
+ expect(trie.contains('abcd')).toBe(true)
36
+ })
37
+
38
+ it('should return true if a string is added that already existed', function () {
39
+ const trie = new Trie()
40
+ expect(trie.addString('test')).toBe(false)
41
+ expect(trie.addString('test')).toBe(true)
42
+ })
43
+
44
+ it('Should add an array of strings', function () {
45
+ const trie = new Trie()
46
+ const testWords = ['test', 'abcd', 'ffff']
47
+ trie.addStrings(testWords)
48
+
49
+ for (let i = testWords.length - 1; i >= 0; i--) {
50
+ expect(trie.contains(testWords[i])).toBe(true)
51
+ };
52
+ })
53
+ })
54
+
55
+ describe('getSize', function () {
56
+ it('should return 1 for an empty trie', function () {
57
+ const trie = new Trie()
58
+ expect(trie.getSize()).toBe(1)
59
+ })
60
+
61
+ it('should return the correct size', function () {
62
+ const trie = new Trie()
63
+ trie.addString('a')
64
+ expect(trie.getSize()).toBe(2)
65
+
66
+ trie.addString('ab')
67
+ expect(trie.getSize()).toBe(3)
68
+ })
69
+
70
+ it('should count all branches', function () {
71
+ const trie = new Trie()
72
+ trie.addString('a')
73
+ expect(trie.getSize()).toBe(2)
74
+
75
+ trie.addString('ba')
76
+ expect(trie.getSize()).toBe(4)
77
+ })
78
+ })
79
+
80
+ describe('searching', function () {
81
+ it("should not find words that haven't been added", function () {
82
+ const trie = new Trie()
83
+ expect(trie.contains('aaaaa')).toBe(false)
84
+ })
85
+
86
+ it('should not return prefixes of words that have been added as words', function () {
87
+ const trie = new Trie()
88
+ trie.addString('test')
89
+ expect(trie.contains('test')).toBe(true)
90
+ expect(trie.contains('tes')).toBe(false)
91
+ })
92
+
93
+ it('should not return suffixes of words that have been added as words', function () {
94
+ const trie = new Trie()
95
+ trie.addString('test')
96
+ expect(trie.contains('test')).toBe(true)
97
+ expect(trie.contains('est')).toBe(false)
98
+ })
99
+
100
+ it('should not find a word that falls in between two other words but has not been added', function () {
101
+ const trie = new Trie()
102
+ trie.addString('test')
103
+ trie.addString('tested')
104
+ expect(trie.contains('test')).toBe(true)
105
+ expect(trie.contains('tested')).toBe(true)
106
+ expect(trie.contains('teste')).toBe(false)
107
+ })
108
+ })
109
+
110
+ function expectResults (results: string[]): void {
111
+ expect(results).toContain('a')
112
+ expect(results).toContain('ab')
113
+ expect(results).toContain('abc')
114
+ expect(results).not.toContain('bc')
115
+ expect(results).not.toContain('cd')
116
+ }
117
+
118
+ describe('prefix searching', function () {
119
+ it('should be able to find all full prefix matched words along a path.', function () {
120
+ const trie = new Trie()
121
+ trie.addStrings(['a', 'ab', 'bc', 'cd', 'abc'])
122
+ const results = trie.findMatchesOnPath('abcd')
123
+ expectResults(results)
124
+ })
125
+
126
+ it('should be able to guess all full prefix matched words.', function () {
127
+ const trie = new Trie()
128
+ trie.addStrings(['a', 'ab', 'bc', 'cd', 'abc'])
129
+ let results = trie.keysWithPrefix('a')
130
+ expectResults(results)
131
+ results = trie.keysWithPrefix('ab')
132
+ expect(results).toContain('ab')
133
+ expect(results).toContain('abc')
134
+ expect(results).not.toContain('a')
135
+ expect(results).not.toContain('bc')
136
+ expect(results).not.toContain('cd')
137
+ })
138
+
139
+ it('should be able to execute the find_prefix search with a match', function () {
140
+ const trie = new Trie()
141
+ trie.addStrings(['their', 'and', 'they'])
142
+ const results = trie.findPrefix('theyre')
143
+ expect(results[0]).toBe('they')
144
+ expect(results[1]).toBe('re')
145
+ })
146
+
147
+ it('should return empty array if no full prefix matches found.', function () {
148
+ const trie = new Trie()
149
+ trie.addStrings(['a', 'ab', 'bc', 'cd', 'abc'])
150
+ const results = trie.keysWithPrefix('not-found')
151
+ expect(results.length).toEqual(0)
152
+ })
153
+
154
+ it('should be able to execute the find_prefix search without a match', function () {
155
+ const trie = new Trie()
156
+ trie.addStrings(['their', 'and'])
157
+ const results = trie.findPrefix('theyre')
158
+ expect(results[0]).toBe(null)
159
+ expect(results[1]).toBe('yre')
160
+ })
161
+ })
162
+
163
+ describe('case sensitivity', function () {
164
+ it('should be case sensitive by default', function () {
165
+ const trie = new Trie()
166
+ trie.addString('test')
167
+ expect(trie.contains('TEST')).toBe(false)
168
+ })
169
+
170
+ it('should have contains in case-insensitive mode', function () {
171
+ const trie = new Trie(false)
172
+ trie.addString('test')
173
+ expect(trie.contains('TEST')).toBe(true)
174
+ })
175
+
176
+ it('should have case-insensitive contains when the strings are added with case', function () {
177
+ const trie = new Trie(false)
178
+ trie.addString('teSt')
179
+ expect(trie.contains('test')).toBe(true)
180
+ })
181
+
182
+ it('should have findMatchesOnPath in case-insensitive mode', function () {
183
+ const trie = new Trie(false)
184
+ trie.addStrings(['a', 'ab', 'bc', 'cd', 'abc'])
185
+ const results = trie.findMatchesOnPath('ABcD')
186
+ expectResults(results)
187
+ })
188
+
189
+ it('should have findPrefix in case-insensitive mode', function () {
190
+ const trie = new Trie(false)
191
+ trie.addStrings(['thEIr', 'And', 'theY'])
192
+ const results = trie.findPrefix('ThEyRe')
193
+ expect(results[0]).toBe('they')
194
+ expect(results[1]).toBe('re')
195
+ })
196
+ })
197
+ })
package/tsconfig.json CHANGED
@@ -7,6 +7,7 @@
7
7
  ],
8
8
  "module": "commonjs",
9
9
  "rootDir": "./",
10
+ "baseUrl": "./",
10
11
  "moduleResolution": "node",
11
12
  "allowJs": true,
12
13
  "outDir": "./dist",
@@ -15,9 +16,10 @@
15
16
  "strict": true
16
17
  },
17
18
  "include": [
18
- "lib/natural/**/*",
19
- "spec/*"
20
- , "io_spec/StorageBackend_spec.js" ],
19
+ "lib/natural/**/*.ts",
20
+ "ts_spec/*.ts",
21
+ "io_spec/*.ts"
22
+ , "lib/natural/analyzers/SenType.ts" ],
21
23
  "exclude": [
22
24
  "./node_modules"
23
25
  ]
package/example.txt DELETED
@@ -1 +0,0 @@
1
- {"attr1":"val1","attr2":"val2"}