diff --git a/server/src/core/nlp/language.ts b/server/src/core/nlp/language.ts deleted file mode 100644 index 70b786d1..00000000 --- a/server/src/core/nlp/language.ts +++ /dev/null @@ -1 +0,0 @@ -// TODO diff --git a/server/src/core/nlp/nlg.ts b/server/src/core/nlp/nlg.ts deleted file mode 100644 index 70b786d1..00000000 --- a/server/src/core/nlp/nlg.ts +++ /dev/null @@ -1 +0,0 @@ -// TODO diff --git a/server/src/core/nlp/nlu/nlu.ts b/server/src/core/nlp/nlu/nlu.ts index 36e01d22..6623c6fa 100644 --- a/server/src/core/nlp/nlu/nlu.ts +++ b/server/src/core/nlp/nlu/nlu.ts @@ -4,7 +4,7 @@ import { spawn } from 'node:child_process' import kill from 'tree-kill' import type { Language, ShortLanguageCode } from '@/types' -import type { NLPAction, NLPDomain, NLPSkill, NLPUtterance, NLUResult } from '@/core/nlp/types' +import type { NLPAction, NLPDomain, NLPJSProcessResult, NLPSkill, NLPUtterance, NLUResult } from '@/core/nlp/types' import { langs } from '@@/core/langs.json' import { TCP_SERVER_BIN_PATH } from '@/constants' import { TCP_CLIENT, BRAIN, SOCKET_SERVER, MODEL_LOADER, NER } from '@/core' @@ -117,7 +117,7 @@ export default class NLU { } } - const result = await MODEL_LOADER.mainNLPContainer.process(utterance) + const result: NLPJSProcessResult = await MODEL_LOADER.mainNLPContainer.process(utterance) const { locale, answers, classifications } = result let { score, intent, domain } = result @@ -149,8 +149,8 @@ export default class NLU { answers, // For dialog action type classification: { domain, - skill: skillName, - action: actionName, + skill: skillName || '', + action: actionName || '', confidence: score } } diff --git a/server/src/core/nlp/nlu/resolver.ts b/server/src/core/nlp/nlu/resolver.ts deleted file mode 100644 index 70b786d1..00000000 --- a/server/src/core/nlp/nlu/resolver.ts +++ /dev/null @@ -1 +0,0 @@ -// TODO diff --git a/server/src/core/nlp/types.ts b/server/src/core/nlp/types.ts index e8dc450d..38c33a1d 100644 --- a/server/src/core/nlp/types.ts +++ b/server/src/core/nlp/types.ts @@ -1,3 +1,5 @@ +import type { ShortLanguageCode } from '@/types' + /** * NLP types */ @@ -7,6 +9,39 @@ export type NLPSkill = string export type NLPAction = string export type NLPUtterance = string +export interface NLPJSProcessResult { + locale: ShortLanguageCode + utterance: NLPUtterance + settings: unknown + languageGuessed: boolean + localeIso2: ShortLanguageCode + language: string + explanation: [] + classifications: { + intent: string + score: number + }[] + intent: string // E.g. "greeting.run" + score: number + domain: NLPDomain + sourceEntities: unknown[] + entities: NEREntity[] + answers: { + answer: string + }[] + answer: string | undefined + actions: NLPAction[] + sentiment: { + score: number + numWords: number + numHits: number + average: number + type: string + locale: ShortLanguageCode + vote: string + } +} + /** * NLU types */ @@ -231,6 +266,7 @@ export interface CustomEnumEntity extends CustomEntity<'enum'> { resolution: { value: string } + alias?: string // E.g. "location:country_0"; "location:country_1" } type GlobalEntity = CustomEnumEntity export interface CustomRegexEntity extends CustomEntity<'regex'> { @@ -247,7 +283,7 @@ interface CustomTrimEntity extends CustomEntity<'trim'> { } /** - * spaCy entity types + * spaCy's entity types */ interface SpacyEntity extends CustomEnumEntity {