Reputation: 61
for e.g. "show me an image of Eiffel tower" ... so i want Eiffel tower to be stored in the variable. that is i want any word after "of" to be stored. how to do this? . Thanks in advance.
Upvotes: 0
Views: 1057
Reputation: 51
You can use regular expressions to capture entity values from user input. To capture the one or two words after of, use of ([a-z]+\s*[a-z]+)
as the regular expression. Regular expressions are called patterns in WCS. Here is how a definition could look:
Then save the what the user says into the context variable using:
{
"context": {
"thing": "<? @thing.groups[1] ?>"
}
}
To test it you can use the context variable in an answer, for example:
{
"output": {
"text": {
"values": [
"Getting a picture of $thing"
]
}
}
}
More information can be found at: https://console.bluemix.net/docs/services/conversation/entities.html#defining-entities
Upvotes: 0
Reputation: 187
Simple way to do this is by creating an entity which contains values like Eiffel Tower. Then you can store that in any context variable.
{
"context": {
"xyz":"@Place"
},
"output": {}
}
Here Place is your entity.You can use your context variable anywhere.
Upvotes: 1