2

I have this piece of code in JSON editor of Watson:

"context": {
"array": "<? entities['spare_part'].![literal] ?>",
"array_size": "<?$array.size() ?>"

When the input of the user, for example, is "Hello, I need a valve, and the part number of the valve is 1234", the size of the array ends up being 2 since the user mentions the word "valve" twice in his input. Some nodes are being executed depending on size of the array. For instance if the size of the array is 1, some nodes will be ignored because they are only executed only if the size of the array is 2.

I want the array to store only the inputs with different values, which is basically I don`t want the array to store the values of the same type, in my case 2 valves. If it is possible somehow please show me a way.

2 Answers2

0

All that can be done, but the best approach depends on the overall system architecture. Remember that Watson Assistant is a conversation service, not a data processing platform...

You can process JSON in either Watson Assistant directly using the built-in methods and SpEL, see these links to get started:
- https://console.bluemix.net/docs/services/conversation/expression-language.html#expressions-for-accessing-objects
- http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html
- https://console.bluemix.net/docs/services/conversation/dialog-methods.html#expression-language-methods

That would require some coding within the dialog nodes. It could be ok. What I would recommend is to either process in your app that drives the dialog (you need that app anyway) or to code up small server actions to transform data.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
0

If it is the word you are looking for, you can use contextual entities to train for this.

As an example I created the following intent (along with general intents from catalog).

For each example I highlighted the "valve" word that is the one I am interested in, and added to the entity.

enter image description here

Now when I test it I get the following.

enter image description here

All this was done in a couple of minutes. For production level you may want to add more examples, or think about how you want to annotate.

Simon O'Doherty
  • 9,259
  • 3
  • 26
  • 54