natural 6.10.3 → 6.10.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.
package/.gitconfig
ADDED
|
@@ -23,6 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
import { Feature } from '../classifiers'
|
|
27
|
+
|
|
26
28
|
declare interface RuleTemplatesItem {
|
|
27
29
|
function: (sentence: Sentence, i: number, parameter1?: string, parameter2?: string) => boolean
|
|
28
30
|
window: number[]
|
|
@@ -93,8 +95,12 @@ export class Lexicon {
|
|
|
93
95
|
setDefaultCategories (category: string, categoryCapitalised: string): void
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
declare class Corpus {
|
|
97
99
|
constructor (data: string | Corpus, typeOfCorpus: number, SentenceClass: typeof Sentence)
|
|
100
|
+
private readonly wordCount: number
|
|
101
|
+
private readonly sentences: Sentence[]
|
|
102
|
+
private readonly tagFrequencies: { [key: string]: string[] | undefined }
|
|
103
|
+
private readonly posTags: { [key: string]: string[] | undefined }
|
|
98
104
|
parseBrownCorpus (data: string, SentenceClass: typeof Sentence): void
|
|
99
105
|
getTags (): string[]
|
|
100
106
|
splitInTrainAndTest (percentageTrain: number): [Corpus, Corpus]
|
|
@@ -103,8 +109,8 @@ export class Corpus {
|
|
|
103
109
|
tag (lexicon: Lexicon): void
|
|
104
110
|
nrSentences (): number
|
|
105
111
|
nrWords (): number
|
|
106
|
-
|
|
107
|
-
//
|
|
112
|
+
private generateFeatures (): Feature[]
|
|
113
|
+
// Incomplete method:
|
|
108
114
|
// prettyPrint
|
|
109
115
|
}
|
|
110
116
|
|
|
@@ -122,8 +128,8 @@ export class Sentence {
|
|
|
122
128
|
|
|
123
129
|
export class BrillPOSTagger {
|
|
124
130
|
constructor (lexicon: Lexicon, ruleSet: RuleSet)
|
|
125
|
-
lexicon: Lexicon
|
|
126
|
-
ruleSet: RuleSet
|
|
131
|
+
private readonly lexicon: Lexicon
|
|
132
|
+
private readonly ruleSet: RuleSet
|
|
127
133
|
tag (sentence: string[]): Sentence
|
|
128
134
|
tagWithLexicon (sentence: string[]): Sentence
|
|
129
135
|
applyRules (sentence: Sentence): Sentence
|
|
@@ -131,32 +137,32 @@ export class BrillPOSTagger {
|
|
|
131
137
|
|
|
132
138
|
export class BrillPOSTester {
|
|
133
139
|
constructor (lexicon: Lexicon, ruleSet: RuleSet)
|
|
134
|
-
lexicon: Lexicon
|
|
135
|
-
ruleSet: RuleSet
|
|
140
|
+
private readonly lexicon: Lexicon
|
|
141
|
+
private readonly ruleSet: RuleSet
|
|
136
142
|
test (corpus: Corpus, tagger: BrillPOSTagger): [number, number]
|
|
137
143
|
}
|
|
138
144
|
|
|
139
145
|
export class BrillPOSTrainer {
|
|
140
146
|
constructor (ruleScoreThreshold: number)
|
|
141
|
-
ruleScoreThreshold: number
|
|
142
|
-
corpus: Corpus
|
|
143
|
-
templates: RuleTemplates
|
|
144
|
-
positiveRules: RuleSet
|
|
145
|
-
mapRuleToSites: { [key: string]: { [key: number ]: { [key: number ]: boolean | undefined } | undefined } | undefined }
|
|
146
|
-
mapSiteToRules: { [key: number]: { [key: number ]: { [key: string ]: TransformationRule | undefined } | undefined } | undefined }
|
|
147
|
-
selectHighRule (): TransformationRule
|
|
148
|
-
mapRuleToSite (rule: TransformationRule, i: number, j: number): void
|
|
149
|
-
mapSiteToRule (i: number, j: number, rule: TransformationRule): void
|
|
150
|
-
associateSiteWithRule (i: number, j: number, rule: TransformationRule): void
|
|
151
|
-
siteIsAssociatedWithRule (i: number, j: number, rule: TransformationRule): boolean
|
|
152
|
-
getSites (rule: TransformationRule): Array<[number, number]>
|
|
153
|
-
getRules (i: number, j: number): TransformationRule[]
|
|
154
|
-
disconnectSiteFromRule (i: number, j: number, rule: TransformationRule): void
|
|
155
|
-
scoreRule (rule: TransformationRule, i: number, j: number): void
|
|
156
|
-
generatePositiveRules (i: number, j: number): RuleSet
|
|
157
|
-
scanForPositiveRules (): void
|
|
158
|
-
scanForSites (): void
|
|
159
|
-
neighbourhood (i: number, j: number): Array<[number, number]>
|
|
147
|
+
private readonly ruleScoreThreshold: number
|
|
148
|
+
private readonly corpus: Corpus
|
|
149
|
+
private readonly templates: RuleTemplates
|
|
150
|
+
private readonly positiveRules: RuleSet
|
|
151
|
+
private readonly mapRuleToSites: { [key: string]: { [key: number ]: { [key: number ]: boolean | undefined } | undefined } | undefined }
|
|
152
|
+
private readonly mapSiteToRules: { [key: number]: { [key: number ]: { [key: string ]: TransformationRule | undefined } | undefined } | undefined }
|
|
153
|
+
private selectHighRule (): TransformationRule
|
|
154
|
+
private mapRuleToSite (rule: TransformationRule, i: number, j: number): void
|
|
155
|
+
private mapSiteToRule (i: number, j: number, rule: TransformationRule): void
|
|
156
|
+
private associateSiteWithRule (i: number, j: number, rule: TransformationRule): void
|
|
157
|
+
private siteIsAssociatedWithRule (i: number, j: number, rule: TransformationRule): boolean
|
|
158
|
+
private getSites (rule: TransformationRule): Array<[number, number]>
|
|
159
|
+
private getRules (i: number, j: number): TransformationRule[]
|
|
160
|
+
private disconnectSiteFromRule (i: number, j: number, rule: TransformationRule): void
|
|
161
|
+
private scoreRule (rule: TransformationRule, i: number, j: number): void
|
|
162
|
+
private generatePositiveRules (i: number, j: number): RuleSet
|
|
163
|
+
private scanForPositiveRules (): void
|
|
164
|
+
private scanForSites (): void
|
|
165
|
+
private neighbourhood (i: number, j: number): Array<[number, number]>
|
|
160
166
|
train (corpus: Corpus, templates: RuleTemplates, lexicon: Lexicon): RuleSet
|
|
161
167
|
printRulesWithScores (): string
|
|
162
168
|
}
|
|
@@ -43,12 +43,12 @@ class BayesClassifier extends Classifier {
|
|
|
43
43
|
return classifier
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
load (filename, stemmer, callback) {
|
|
46
|
+
static load (filename, stemmer, callback) {
|
|
47
47
|
Classifier.load(filename, function (err, classifier) {
|
|
48
48
|
if (err) {
|
|
49
49
|
return callback(err)
|
|
50
50
|
} else {
|
|
51
|
-
callback(err,
|
|
51
|
+
callback(err, BayesClassifier.restore(classifier, stemmer))
|
|
52
52
|
}
|
|
53
53
|
})
|
|
54
54
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natural",
|
|
3
3
|
"description": "General natural language (tokenizing, stemming (English, Russian, Spanish), part-of-speech tagging, sentiment analysis, classification, inflection, phonetics, tfidf, WordNet, jaro-winkler, Levenshtein distance, Dice's Coefficient) facilities for node.",
|
|
4
|
-
"version": "6.10.
|
|
4
|
+
"version": "6.10.5",
|
|
5
5
|
"homepage": "https://github.com/NaturalNode/natural",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|