diff --git a/types/natural/index.d.ts b/types/natural/index.d.ts index 3615a50fce..255d8d4dca 100644 --- a/types/natural/index.d.ts +++ b/types/natural/index.d.ts @@ -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[][]; +} diff --git a/types/natural/natural-tests.ts b/types/natural/natural-tests.ts index c8650c6308..f994928f80 100644 --- a/types/natural/natural-tests.ts +++ b/types/natural/natural-tests.ts @@ -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);