You can use Rivescript to add flexibility to a keyword question by adding:
Advanced Keywords are still based on pattern-matching, rather than natural language processing. They just allow you to be more flexible and powerful in what phrases your keywords match.
Advanced Keywords (Rivescript) are enabled individually per keyword question.
Wildcards match any text. This is useful when you want to a question to match when certain words are used, but the words may not always be in the same order or next to each other. There are three types of wildcards:
Character wildcards (*)
Character wildcards match any number of characters, ignoring whether they are numbers, characters or whole words.
"payment * missed" matches phrases that include "payment" and then "missed", regardless of what text is between them:
- "I made a payment but my account says it was missed please help"
- "my payment was missed what do I do"
- "help payment missed"
"missed * payment" matches phrases that include "missed" and then "payment", regardless of what text is between them:
- "I missed my payment will I get a fine"
- "it says I have a missed payment but I paid on time"
- "missed payment help"
If we add both phrases to a question, the question will match when a phrase contains both the words “missed” and “payment” regardless of how they're used.
- You don't need to add separate-word wildcards at the beginning and end of phrases: “* cook *” is equivalent to “cook”. However, “cook*” (note the lack of space before the asterisk) is different, as it allows extensions of the word cook, like cooking, cooked, and cooks.
- One wildcard character matches any amount of text: “**” is the same as “*”
Word Wildcards (_)
Word wildcards match exactly one alphabetical word. A "word" contains only the letters a-z, without spaces. Words with non-alphabetical characters, including numbers and emoji, will not be matched:
“My name is _” matches “My name is Alice” or “My name is Bob”, but not “My name is HAL9000”.
Numeric Wildcards (#)
Numeric wildcards match any whole number, but will not match numbers with decimal points.
“I am # years old” matches “I am 24 years old”, but does not match “I am 2.4 years old” or “I am twenty years old”.
A union will match if at least one of the tokens inside the parentheses is matched. This is useful if you want to match different variations of the same word, such as different tenses.
"cook(ing|ed)" matches both “cooking” and “cooked”, but does not match “cook”
"cook(s|ing|ed)" matches all of “cooks”, “cooking”, and “cooked” but does not match “cook”
Do not use unions for whole keyword phrases, only where you need to match small variations to the same keyword.
Use optional matches if part of a keyword may or may not be used. This is useful if you have similar questions where the user may or may not add a more specific word.
By default, only the character immediately before the ? is considered optional. If you want to make a string of characters optional, enclose them in parentheses ().
"Repay (home)? Loan" matches both “repay loan” and “repay home loan”
"Repay loans?" matches both “repay loan” and “repay loans”
"cook(s|ing|ed)?" matches “cooks”, “cooking”, “cooked”, and “cook”. The optional-match applies to everything in the parentheses, including the union.