Add ?Keyword command to work around Unicode keyword bug #256
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This feature alleviates a huge pain point that a lot of users have experienced with Unicode keyword triggers.
The Bug
Users wanted to be able to write things like this in their RiveScript code:
The intention is that the word
你好
appearing anywhere in a message should be able to match that trigger, as it does when using standard ASCII characters. However, the regexps that make "optional wildcards" like[*]
work have problems matching against Unicode characters outside the ASCII range.The Feature
This adds a new
?Keyword
command to complement the+Trigger
as a workaround for this very common use case:Under the hood, the
?Keyword
is re-written into a+Trigger
which includes the keyword text in every variation of wildcard, optional wildcard, and verbatim text. This makes sure that the keyword matches as expected in all messages that contain it, in a way that works with Unicode.The JavaScript version gets this feature first because it's the most popular edition of RiveScript.
This will be included in the
v1.19.0
release ofrivescript-js
.See Also