Multiple phrase options - not working as expected
zivbrachia opened this issue · comments
Hi, I encounter a bug that I want to report about:
As we can see in the the example:
intentUtteranceExpander("(hello|hi) (|mighty) world") - return array size 4, with the result:
0: "hello mighty world"
1: "hello world"
2: "hi mighty world"
3: "hi world"
For the next example, I got the same array size 4, with the result:
intentUtteranceExpander("(hello|hi) (|mighty|wonder) world") - return array size 4
0: "hello mighty world"
1: "hello wonder world"
2: "hi mighty world"
3: "hi wonder world"
While I expect to see, array size 6, with the result:
0: "hello world"
1: "hello mighty world"
2: "hello wonder world"
3: "hi world"
4: "hi mighty world"
5: "hi wonder world"
Thanks.
before "break".
https://github.com/miguelmota/intent-utterance-expander/blob/master/intent-utterance-expander.js#L73
I added the following code:
if (part.startsWith("(|")) {
copy = parts.slice(0);
copy.splice(i, 1);
phrases.push(copy);
} else if (part.endsWith("|)")) {
copy = parts.slice(0);
copy.splice(i, 1);
phrases.push(copy);
} else if (part.includes("||")) {
copy = parts.slice(0);
let a = copy.slice(0, i);
let b = copy.slice(i + 1, 1);
phrases.push(a.concat(b));
}
and removed the if statment on line 66
https://github.com/miguelmota/intent-utterance-expander/blob/master/intent-utterance-expander.js#L66
@zivbrachia thanks for reporting, should be fixed now
Hi, there is a mistake in the code in the version 0.0.7
It's not like I wrote. please fix it, because I need the working version (we already toke out the changes from source control and give full relay on npm version.
copy.splice(i, 1);
let b = copy.slice(i + 1, 1);
@zivbrachia whoops not sure how that happened. It's fixed now on the latest version