Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatito",
"version": "2.4.0",
"version": "2.4.1",
"description": "Generate training datasets for NLU chatbots using a simple DSL",
"bin": {
"chatito": "./dist/bin.js"
Expand Down
17 changes: 16 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ export const getVariationsFromEntity = async <T>(
return [];
}
const sentence = ed.inner[sentenceIndex].sentence;
// Apply removing slots variation without replacement
if (ed.type == "SlotDefinition" && ed['variation'] !== null){
const slotKeyInEntities = ed.key + "#" + ed.variation
// if one sentences left in the slot , then refill
if (entities.Slot[slotKeyInEntities].inner.length < 2){
entities.Slot[slotKeyInEntities].inner = operatorDefinitionsOriginal.Slot[slotKeyInEntities].inner.slice()
}
else{
entities.Slot[slotKeyInEntities].inner.splice(sentenceIndex, 1)
}
}

let accumulator: ISentenceTokens[] = [];
// For slots where a sentence is composed of only one alias, we add the synonym tag,
// to denote that the generated alias is a synonym of its alias name
Expand Down Expand Up @@ -626,13 +638,15 @@ export const definitionsFromAST = (initialAst: IChatitoEntityAST[], importHandle
return operatorDefinitions;
};

let operatorDefinitionsOriginal: {[key: string]: any;} = {}
export const datasetFromAST = async (
initialAst: IChatitoEntityAST[],
writterFn: IUtteranceWriter,
importHandler?: IFileImporter,
currPath?: string
) => {
const operatorDefinitions = definitionsFromAST(initialAst, importHandler, currPath);
let operatorDefinitions = definitionsFromAST(initialAst, importHandler, currPath);
operatorDefinitionsOriginal = JSON.parse(JSON.stringify(operatorDefinitions));
if (!operatorDefinitions) {
return;
}
Expand Down Expand Up @@ -709,6 +723,7 @@ export const datasetFromAST = async (
false,
globalCache
);

const utterance = chatitoFormatPostProcess(intentSentence);
const utteranceString = utterance.reduce((p, n) => p + n.value, '');
if (!collitionsCache[utteranceString]) {
Expand Down