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.
Asked
Active
Viewed 1,010 times
0
-
Can you show the code you already have? – Xan-Kun Clark-Davis Feb 21 '18 at 10:32
2 Answers
1
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.

Rohit
- 187
- 6
-
then how would i do this - " show me the imdb rating of iron man"... want that movie name "iron man" to be stored in a variable – Vinay Nair Feb 23 '18 at 18:27
-
-
no i am not. This is the right way to do this.Your method is incorrect.Suppose if your text contains 2 times "of" then what will u do? – Rohit Mar 31 '18 at 09:01
0
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

matsair
- 51
- 1
- 5