diff --git a/packages/node-nlp/package.json b/packages/node-nlp/package.json index 006da26b6..6ce989d0d 100644 --- a/packages/node-nlp/package.json +++ b/packages/node-nlp/package.json @@ -21,6 +21,7 @@ ], "license": "MIT", "main": "src/index.js", + "types": "src/index.d.ts", "scripts": { "test": "echo \"Error: run tests from root\" && exit 1" }, diff --git a/packages/node-nlp/src/index.d.ts b/packages/node-nlp/src/index.d.ts new file mode 100644 index 000000000..12cac5c6f --- /dev/null +++ b/packages/node-nlp/src/index.d.ts @@ -0,0 +1,63 @@ +declare module "node-nlp" { + interface Explanation { + token: string; + stem: string; + weight: number; + } + + interface Classification { + intent: string; + score: number; + } + + interface Answer { + answer: string; + } + + interface Sentiment { + score: number; + numWords: number; + numHits: number; + average: number; + type: string; + locale: string; + vote: string; + } + + interface NluAnswer { + classifications: Classification[]; + } + + interface NlpResult { + locale: string; + utterance: string; + languageGuessed: boolean; + localeIso2: string; + language: string; + explanation: Explanation[]; + classifications: Classification[]; + intent: string; + score: number; + domain: string; + entities: any[]; + sourceEntities: any[]; + answers: Answer[]; + answer: string; + actions: any[]; + sentiment: Sentiment; + nluAnswer?: NluAnswer; + } + + interface NlpManagerOptions { + languages: string[]; + } + + class NlpManager { + constructor(options?: NlpManagerOptions); + + addDocument(locale: string, utterance: string, intent: string): void; + addAnswer(locale: string, intent: string, answer: string): void; + process(locale: string, utterance: string): Promise; + train(): Promise; + } +} \ No newline at end of file diff --git a/packages/node-nlp/tsconfig.json b/packages/node-nlp/tsconfig.json new file mode 100644 index 000000000..8c3413766 --- /dev/null +++ b/packages/node-nlp/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "strict": true, + "module": "commonjs", + "target": "es6", + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "baseUrl": ".", + "paths": { + "*": ["src/*"] + } + }, + "include": ["src/**/*"] +}