natural 5.2.3 → 6.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.
- package/.github/workflows/linter.yml +2 -1
- package/lib/natural/analyzers/index.d.ts +55 -0
- package/lib/natural/analyzers/sentence_analyzer.js +2 -0
- package/lib/natural/brill_pos_tagger/index.d.ts +73 -0
- package/lib/natural/classifiers/index.d.ts +135 -0
- package/lib/natural/classifiers/maxent/Classifier.js +1 -0
- package/lib/natural/classifiers/maxent/Feature.js +1 -1
- package/lib/natural/distance/index.d.ts +76 -0
- package/lib/natural/distance/jaro-winkler_distance.js +4 -6
- package/lib/natural/distance/levenshtein_distance.js +1 -0
- package/lib/natural/index.d.ts +39 -0
- package/lib/natural/inflectors/index.d.ts +35 -0
- package/lib/natural/ngrams/index.d.ts +35 -0
- package/lib/natural/phonetics/index.d.ts +41 -0
- package/lib/natural/sentiment/index.d.ts +27 -0
- package/lib/natural/spellcheck/index.d.ts +30 -0
- package/lib/natural/stemmers/index.d.ts +44 -0
- package/lib/natural/tfidf/index.d.ts +42 -0
- package/lib/natural/tokenizers/index.d.ts +99 -0
- package/lib/natural/tokenizers/parser_sentence_tokenizer.js +319 -138
- package/lib/natural/tokenizers/pegjs_grammar_sentence_tokenizer.txt +31 -4
- package/lib/natural/tokenizers/sentence_tokenizer_parser.js +0 -3
- package/lib/natural/transliterators/index.d.ts +27 -0
- package/lib/natural/transliterators/index.js +1 -1
- package/lib/natural/trie/index.d.ts +33 -0
- package/lib/natural/util/index.d.ts +44 -0
- package/lib/natural/wordnet/index.d.ts +42 -0
- package/package.json +5 -2
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2022,
|
|
3
|
+
Dylan R. E. Moonfire <https://github.com/dmoonfire>,
|
|
4
|
+
Emily Marigold Klassen <https://github.com/forivall>,
|
|
5
|
+
Hugo W.L. ter Doest <https://github.com/Hugo-ter-Doest>
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export type TfIdfCallback = (i: number, measure: number) => void
|
|
27
|
+
|
|
28
|
+
export interface TfIdfTerm {
|
|
29
|
+
term: string
|
|
30
|
+
tfidf: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export declare class TfIdf {
|
|
34
|
+
constructor (deserialized?: any)
|
|
35
|
+
addDocument (document: string, key?: string, restoreCache?: boolean): void
|
|
36
|
+
addDocument (document: string[], key?: string, restoreCache?: boolean): void
|
|
37
|
+
addFileSync (path: string, encoding?: string, key?: string, restoreCache?: boolean): void
|
|
38
|
+
tfidf (terms: string, d: number): void
|
|
39
|
+
tfidfs (terms: string, callback: TfIdfCallback): void
|
|
40
|
+
tfidfs (terms: string[], callback: TfIdfCallback): void
|
|
41
|
+
listTerms (d: number): TfIdfTerm[]
|
|
42
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2022, Dylan R. E. Moonfire <https://github.com/dmoonfire>, Emily Marigold Klassen <https://github.com/forivall>, Hugo W.L. ter Doest
|
|
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
|
+
// Based on type definitions on Definitely Typed
|
|
24
|
+
|
|
25
|
+
export interface Tokenizer {
|
|
26
|
+
tokenize: (text: string) => string[]
|
|
27
|
+
}
|
|
28
|
+
export declare class WordTokenizer implements Tokenizer {
|
|
29
|
+
tokenize (text: string): string[]
|
|
30
|
+
}
|
|
31
|
+
export declare class TreebankWordTokenizer implements Tokenizer {
|
|
32
|
+
tokenize (text: string): string[]
|
|
33
|
+
}
|
|
34
|
+
export interface RegexTokenizerOptions {
|
|
35
|
+
pattern?: RegExp | undefined
|
|
36
|
+
discardEmpty?: boolean | undefined
|
|
37
|
+
}
|
|
38
|
+
export declare class RegexpTokenizer implements Tokenizer {
|
|
39
|
+
constructor (options: RegexTokenizerOptions)
|
|
40
|
+
tokenize (text: string): string[];
|
|
41
|
+
}
|
|
42
|
+
export declare class OrthographyTokenizer implements Tokenizer {
|
|
43
|
+
constructor (options: RegexTokenizerOptions & { language: string })
|
|
44
|
+
tokenize (text: string): string[]
|
|
45
|
+
}
|
|
46
|
+
export declare class WordPunctTokenizer implements Tokenizer {
|
|
47
|
+
tokenize (text: string): string[]
|
|
48
|
+
}
|
|
49
|
+
export declare class SentenceTokenizer implements Tokenizer {
|
|
50
|
+
tokenize (text: string): string[]
|
|
51
|
+
}
|
|
52
|
+
export declare class SentenceTokenizerNew implements Tokenizer {
|
|
53
|
+
tokenize (text: string): string[]
|
|
54
|
+
}
|
|
55
|
+
export declare class CaseTokenizer implements Tokenizer {
|
|
56
|
+
tokenize (text: string, preserveApostrophy?: boolean): string[]
|
|
57
|
+
}
|
|
58
|
+
export declare class AggressiveTokenizer implements Tokenizer {
|
|
59
|
+
tokenize (text: string): string[]
|
|
60
|
+
}
|
|
61
|
+
export declare class AggressiveTokenizerEs implements Tokenizer {
|
|
62
|
+
tokenize (text: string): string[]
|
|
63
|
+
}
|
|
64
|
+
export declare class AggressiveTokenizerFa implements Tokenizer {
|
|
65
|
+
tokenize (text: string): string[]
|
|
66
|
+
}
|
|
67
|
+
export declare class AggressiveTokenizerFr implements Tokenizer {
|
|
68
|
+
tokenize (text: string): string[]
|
|
69
|
+
}
|
|
70
|
+
export declare class AggressiveTokenizerId implements Tokenizer {
|
|
71
|
+
tokenize (text: string): string[]
|
|
72
|
+
}
|
|
73
|
+
export declare class AggressiveTokenizerIt implements Tokenizer {
|
|
74
|
+
tokenize (text: string): string[]
|
|
75
|
+
}
|
|
76
|
+
export declare class AggressiveTokenizerNl implements Tokenizer {
|
|
77
|
+
tokenize (text: string): string[]
|
|
78
|
+
}
|
|
79
|
+
export declare class AggressiveTokenizerNo implements Tokenizer {
|
|
80
|
+
tokenize (text: string): string[]
|
|
81
|
+
}
|
|
82
|
+
export declare class AggressiveTokenizerPl implements Tokenizer {
|
|
83
|
+
tokenize (text: string): string[]
|
|
84
|
+
}
|
|
85
|
+
export declare class AggressiveTokenizerPt implements Tokenizer {
|
|
86
|
+
tokenize (text: string): string[]
|
|
87
|
+
}
|
|
88
|
+
export declare class AggressiveTokenizerRu implements Tokenizer {
|
|
89
|
+
tokenize (text: string): string[]
|
|
90
|
+
}
|
|
91
|
+
export declare class AggressiveTokenizerSv implements Tokenizer {
|
|
92
|
+
tokenize (text: string): string[]
|
|
93
|
+
}
|
|
94
|
+
export declare class AggressiveTokenizerVi implements Tokenizer {
|
|
95
|
+
tokenize (text: string): string[]
|
|
96
|
+
}
|
|
97
|
+
export declare class TokenizerJa implements Tokenizer {
|
|
98
|
+
tokenize (text: string): string[]
|
|
99
|
+
}
|