Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 08d9c73

Browse files
authored
🔀 Merge pull request #93 from rmtuckerphx/v4/feature/nlpjs
✨ Add regex entity type to NLP.js
2 parents b2e3a72 + 839a6a1 commit 08d9c73

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/jovo-model-nlpjs/src/Interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ export interface NlpjsModelFile {
1616
name: string;
1717
locale: string;
1818
data: NlpjsData[];
19-
entities?: Record<string, NlpjsEntity>;
19+
entities?: Record<string, NlpjsEntity | string>;
2020
}

packages/jovo-model-nlpjs/src/JovoModelNlpjs.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
} from '@jovotech/model';
99
import { NlpjsData, NlpjsModelFile } from '.';
1010

11+
const REGEX_PREFIX = 'regex:';
12+
1113
export class JovoModelNlpjs extends JovoModel {
1214
static MODEL_KEY = 'nlpjs';
1315

@@ -87,6 +89,12 @@ export class JovoModelNlpjs extends JovoModel {
8789
if (JovoModelHelper.hasEntityTypes(model)) {
8890
returnData.entities = {};
8991
for (const [entityKey, entityTypeName] of Object.entries(entitiesMap)) {
92+
93+
if (entityTypeName.startsWith(REGEX_PREFIX)) {
94+
returnData.entities![entityKey] = entityTypeName.slice(REGEX_PREFIX.length);
95+
continue;
96+
}
97+
9098
const relatedEntityType = JovoModelHelper.getEntityTypeByName(model, entityTypeName);
9199
if (!relatedEntityType?.values?.length) {
92100
continue;

0 commit comments

Comments
 (0)