I have an entity called "#material_number" in which two values are stored.
First value is "material_number1" with the pattern (\d{3}).(\d{3})
The second value is "material_number2" with the pattern (\d{3}).(\d{3}).(\d{3})
When the user enters a material number, I store the value with a context variable called "$materialnumber" and I set the value of this variable to "?#material_number.literal?". And at the end the bot responds "Oh okay, the material number is $materialnumber."
The problem is that when the user enters a material number like "123.123.123", the bot thinks that the material number is "123.123". Basically it neglects the last three digits and prompts back "Oh okay, the material number is 123.123".
What can I do in order to fix this confusion?
I quickly tested this and there are two problems. First, the dot (. is a special wildcard and needs to be escaped. Second, Watson Assistant does not support the full regex options and seems to match both numbers when typing in the longer number.
You can simply escape using a \ and change your definition or use mine:
num1: (\d{3}\.){1}\d{3}
num2: (\d{3}\.){2}\d{3}
Because of the trouble with the regex evaluation I solved that in the expression itself. Watson Assistant holds the longer match as second value (if matched). The following expression looks if the long number, material_number2, has been matched, then extracts the correct value for it. It assumes that the shorter (incorrect) match is stored first.
{
"context": {
"materialnumber": "<? #matrial_number:matnum2 ? entities.material_number[1].literal : entities.material_number[0].literal ?>"
}
}
Related
Can anyone help me solve this issue
The screenshot attached below is self explanatory
It is auto-correcting sufyan to Susan
The value for the context variable is
"<? input.text.substring(0, 1).toUpperCase() + input.text.substring(1) ?>"
The motive here is to simply convert lowercase name sufyan to Sufyan
or for that case any Indian name.
But the auto-correct has now become a hindrance.
I want the assistant to interact with the user in the later part using his/her name.
You can configure autocorrection in your bot settings.
Along with Henrik’s answer, it’s good to learn about fuzzy matching in Watson Assistant as it runs before autocorrection
How is spelling autocorrection related to fuzzy matching?
Fuzzy matching helps your assistant recognize dictionary-based entity mentions in user input. It uses a dictionary lookup approach to match a word from the user input to an existing entity value or synonym in the skill's training data. For example, if the user enters boook, and your training data contains a #reading_material entity with a book value, then fuzzy matching recognizes that the two terms (boook and book) mean the same thing.
When you enable both autocorrection and fuzzy matching, the fuzzy matching function runs before autocorrection is triggered. If it finds a term that it can match to an existing dictionary entity value or synonym, it adds the term to the list of words that belong to the skill, and does not correct it.
Check the complete documentation here before turning of autocorrection
You can use the following context variable:
"<? input.original_text.substring(0,1).toUpperCase() + input.original_text.substring(1) ?>"
I try to display a message that contains the number inserted in the question, for example when user inserts a number of 12 digits I want to display that 12 digits and a text.
Until now:
I created an Entity with pattern (/d{12}) named #ticket_number
An Intent named #myTicket that has as example #ticket_number
Dialog that triggers when #myTicket | #ticket_number and has on context TicketNumer "<?#ticket_number.literal?>" and display a message as follows "Do you want to get info for ticket $ticketnumber ?".
The problem is that when I try it the Intent result is irrelevant, the message looks ok but I need to match the Intent. What could I do?
Can you share a picture of your node? There is no need that you match the intent; as indicating the ticket number alone, should not be an intent itself, but the entity. I'd remove the #myTicket | part of the node. And the condition should not include an OR; otherwise, if #myTicket triggers the node, and there is no ticket number, the response would fail.
As mentioned in the IBM documentation
it is not yet possible to use pattern entity in Intents.
Currently, you can only directly reference synonym entities that you
define (pattern values are ignored). You cannot use system entities.
I have been looking through the spice instant answer source code. Yes, I know it is in maintenance mode, but I am still curious.
The documentation makes it fairly clear that the primary spice to API gets its numerical parameters $1, $2, etc. from the handle function.
My question: should there be secondary API calls included with spice alt_to as, say, in the movie spice IA, where do the numerical parameters to that API call come from?
Note, for instance, the $1 in both the movie_image and cast_image secondary API calls in spice alt_to at the preceding link. I am asking which regex capture returns those instances of $1.
I believe I see how this works now. The flow of information is still a bit murky to me, but at least I see how all of the requisite information is there.
I'll take the cryptocurrency instant answer as an example. The alt_to element in the perl package file at that link has a key named cryptonator. The corresponding .js file constructs a matching endpoint:
var endpoint = "/js/spice/cryptonator/" + from + "/" + to;
Note the general shape of the "remainder" past /js/spice/cryptonator: from/to, where from and to will be two strings.
Back in the perl package the hash alt_to->{cryptonator} has a key from which receives, I think, this remainder from/to. The value corresponding to that key is a regex meant to split up that string into its two constituents:
from => '([^/]+)/([^/]*)'
Applied to from/to, that regex will return $1=from and $2=to. These, then, are the $1 and $2 that go into
to => 'https://api.cryptonator.com/api/full/$1-$2'
in alt_to.
In short:
The to field of alt_to->{blah} receives its numerical parameters by having the from regex operate on the remainder past /js/spice/blah/ of the name of the corresponding endpoint constructed in the relevant .js file.
Please, I wanted to know if it is possible to catch different entities on Watson conversation without defining their values.
For example, I am working on a Mobile up for room booking in my company and I can't define all the room's names so I want that my Bot recognize the name just according to the used pattern for example
"Book #room for tomorrow"
and whatever I put in place of #room it takes it as a room name.
thank you
Its now available check out https://console.bluemix.net/docs/services/conversation/entities.html#pattern-entities
A pattern must be entered as a regular expression in the field.
For instance internationalPhone: ^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$, e.g., +44 1962 815000
EDIT: The solution below still works but right now the pattern entities as discussed by Dudi are more systematic solution. Leaving this here for legacy reasons.
Right now the regexp support inside Watson Conversation Service is probably the est bet.
For your particular example, you can use the following expression inside the dialog node condition:
input.text.matches('^[bB]ook[^\w]+(\w+).+ (tomorrow|today)$')
and inside that node you can add the following regexp to node context to extract the second word (or the word after "Book") to a variable:
"room" : "<? input.text.extract('^[bB]ook[^\\w]+(\\w+).+ (tomorrow|today)$',1) ?>"
(note that in context unlike in conditions you need to actually escape \ with another \)
This will match inputs such as "book bathroom for today" or "book r101 for tomorrow".
A good place where you can try your regexp expressions is https://regex101.com/
I am trying to send a search input to a REST service. In some cases the form input is a long string of numbers (example: 1234567890000000000123456789). I am getting 500 error, and it looks like something is trying the convert the string to a number. The data type for the source database is a string.
Is there something that can be done in building the query string that will force the input to be interpreted as a string?
The service is an implementation of ArcGIS server.
More information on this issue per request.
To test, I have been using a client form provided with the service installation (see illustration below).
I have attempted to add single and double quotes, plus wildcard characters in the form entry. The form submission does not error, but no results are found. If I shorten the number("1234"), or add some alpha numeric characters ("1234A"), the form submission does not error.
The problem surfaced after a recent upgrade to 10.1. I have looked for information that would tie this to a known problem, but not found anything yet.
In terms of forcing the input to be interpreted as a string, you enclose the input in single quotes (e.g., '1234567890000000000123456789'). Though if you are querying a field of type string then you need to enclose all search strings in single quotes, and in that case none of your queries should be working. So it's a little hard to tell from the information you've provided what exactly you are doing and what might be going wrong. Can you provide more detail and/or code? Are you formatting a where clause that you are using in a Query object via one of Esri's client side API's (such as the JavaScript API)? In that case, for fields of data type string you definitely need to enclose the search text in single quotes. For example if the field you are querying were called 'FIELD', this is how you'd format the where clause:
FIELD = '1234'
or
FIELD Like '1234%'
for a wildcard search. If you are trying to enter query criteria directly into the Query form of a published ArcGIS Server service/layer, then there too you need to enclose the search in single quotes, as in the above examples.
According to an Esri help technician, this is known bug.