Skip to content

Commit

Permalink
fix axa-group#1081: Allow parenthesis in say actions
Browse files Browse the repository at this point in the history
When having a dialog which includes a `say` action text within brackets, the text inside brackets is removed and assumed to be settings of the `say` action.

The [trimBetween()](https://github.com/axa-group/nlp.js/blob/master/packages/bot/src/dialog-parse.js#L37) function parses everything inside brackets as settings:

```
dialog my_dialog
  say Something (clarifying) whatever
```

Would be parsed as the following actions:
```json
[
    {
        "type": "dialog",
        "srcLine": "dialog my_dialog",
        "line": "my_dialog",
        "condition": "",
        "settings": ""
    },
    {
        "type": "say",
        "srcLine": "say Something (clarifying) whatever",
        "line": "Something  whatever",
        "condition": "",
        "settings": "clarifying"
    }
]
```
  • Loading branch information
miqmago authored Feb 21, 2022
1 parent 152c714 commit 0631d4b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/bot/src/dialog-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const CARD_LINK_REGEX = /!?\[.{0,100}\]\(https?:\/\/.{0,2048}\)/gi;
function trimLine(line) {
const trimmedCondition = trimBetween(line.trim(), '[', ']', true);
let trimmedSettings;
if (CARD_LINK_REGEX.test(line)) {
if (CARD_LINK_REGEX.test(line) || line.toLowerCase().startsWith('say ')) {
trimmedSettings = {
line,
trimmed: '',
Expand Down

0 comments on commit 0631d4b

Please sign in to comment.