mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
@types/natural: added POS Tagger
This commit is contained in:
Vendored
+37
@@ -202,3 +202,40 @@ declare class Spellcheck {
|
||||
isCorrect(word: string): boolean;
|
||||
getCorrections(word: string, maxDistance?: number): string[];
|
||||
}
|
||||
|
||||
declare class Predicate {
|
||||
constructor(name: string, parameter1: string, parameter2?: string);
|
||||
name: string;
|
||||
parameter1: string;
|
||||
parameter2?: string;
|
||||
function?: (tagged_sentence: string[][], i: number, parameter: string) => boolean;
|
||||
evaluate(tagged_sentence: string[][], position: number): boolean;
|
||||
}
|
||||
|
||||
declare class TransformationRule {
|
||||
constructor(c1: string, c2: string, predicate: string, parameter1: string, parameter2?: string);
|
||||
literal: string[];
|
||||
predicate: Predicate;
|
||||
old_category: string;
|
||||
new_category: string;
|
||||
apply(tagged_sentence: string[][], position: number): void;
|
||||
}
|
||||
|
||||
declare class RuleSet {
|
||||
constructor(filename: string);
|
||||
rules: TransformationRule[];
|
||||
}
|
||||
|
||||
declare class Lexicon {
|
||||
constructor(filename: string, defaultCategory: string);
|
||||
defaultCategory: string;
|
||||
parseLexicon(data: string): void;
|
||||
tagWord(word: string): string[];
|
||||
}
|
||||
|
||||
declare class BrillPOSTagger {
|
||||
constructor(lexicon: Lexicon, ruleSet: RuleSet);
|
||||
lexicon: Lexicon;
|
||||
ruleSet: RuleSet;
|
||||
tag(sentence: string[]): string[][];
|
||||
}
|
||||
|
||||
@@ -259,3 +259,16 @@ var spellcheck = new natural.Spellcheck(corpus);
|
||||
spellcheck.isCorrect('cat'); // false
|
||||
spellcheck.getCorrections('soemthing', 1); // ['something']
|
||||
spellcheck.getCorrections('soemthing', 2); // ['something', 'soothing']
|
||||
|
||||
// POS Tagger
|
||||
|
||||
var rulesFilename = 'fileName';
|
||||
var lexiconFilename = 'fileName';
|
||||
var defaultCategory = 'N';
|
||||
|
||||
var lexicon = new natural.Lexicon(lexiconFilename, defaultCategory);
|
||||
var rules = new natural.RuleSet(rulesFilename);
|
||||
var tagger = new natural.BrillPOSTagger(lexicon, rules);
|
||||
|
||||
var sentence = ["I", "see", "the", "man", "with", "the", "telescope"];
|
||||
tagger.tag(sentence);
|
||||
|
||||
Reference in New Issue
Block a user