Reputation: 75
I am trying to retrieve the quantity property from users text input with IBM Watson AI. I have tried to use alchemy API service but the entity parameter is not able to retrieve the quantity from user input.
Eg: User Input - "I want to order for 2 packets of coffee". I want to retrieve the quantity as 2 packets from user input mentioned above.
Can you please help me out with the issue I am facing?
Upvotes: 2
Views: 288
Reputation: 122
These types of Named Entity Recognition are hard to extract as you have to define new metrics.
In your example, "packets" is the unit of measure and so that needs to be first trained and understood by the system. Once that is complete, the numeric quantity that is associated with this metric needs to be extracted. Once again coming back to your example, "2" would be the quantity that needs to be extracted.
With the IBM Watson KNowledge studio, you will be able to define such types of custom entities by creating examples and annotating them. You can then train the model to have the capability to identify newer metrics such as packets, cups, etc.
Here is a youtube video from IBM that will guide you on how to define custom entities and use it in your application to enable an NER that suits your need: https://www.youtube.com/watch?v=EQcEk2TX79c
Upvotes: 0
Reputation: 5855
Watson Developer Cloud's Relationship Extraction service can help with this kind of analysis.
Add the Relationship Extraction service to your Bluemix account, then try the following curl command:
curl -u username:password https://gateway.watsonplatform.net/relationship-extraction-beta/api/v1/sire/0 -d "sid=ie-en-news" -d "txt=I want to order for 2 packets of coffee"
This will result in output similar to:
...
<entities>
<entity eid="-E0" type="FOOD" generic="0" class="SPC" level="NOM" subtype="OTHER" score="1">
<mentref mid="-M2">coffee</mentref>
</entity>
<entity eid="-E1" type="CARDINAL" generic="0" class="SPC" level="NONE" subtype="OTHER" score="1">
<mentref mid="-M1">2</mentref>
</entity>
<entity eid="-E2" type="PERSON" generic="0" class="SPC" level="PRO" subtype="OTHER" score="1">
<mentref mid="-M0">I</mentref>
</entity>
</entities>
...
As you can see, the "2" is identified as a cardinal. Take a look at the documentation for full details of interpreting the output.
Disclosure: I am an evangelist for IBM Watson.
Upvotes: 1