How to create different answers depending on an entity value in Dialogflow - dialogflow-es

Here is an example of what I am trying to do.
Assume I have an entity called Animal with values Dog, Cat, Fish, Parrot
I would like the bot to answer to:
How long does #Animal live?
How many legs does #Animal have?
Does #Animal fly?
etc.
I am trying to create a table of values associated with each of the Animal.
Thank you

The best option here is to create one intent per question you want to answer.
So, given your examples
1) Animal - life expectancy
Training phrases
# - How long does #Animal:Animal live?
# - How many years do #Animal:Animal live?
# - #Animal life expectancy
" - How long do elephants live
Webhook answer
Elephants can live up to 70 years in the wild
2) Animal - Legs
Training phrases
" - How many legs does dogs have?
# - How many legs does #Animal have?
# - leg count of #Animal
Webhook answer
Dogs have 4 legs.
3) Animal - Fly
Training phrases
# - Does #Animal fly?
" - Can cats fly?
Webhook answer
No, cats can't fly.
Entity
Intent
Legend:
" - example mode
# - Template mode

Related

A way to Dialogflow handle two or more intent in the same sentence

For instance, I've created two Intents on Dialogflow, A and B:
A - Question: It's going to rain? -> Answer: yes, it is.
B - Question: what is the color of the sky ? -> Answer: blue
If I ask separately A or B, the answer it's right, but if I ask: "It's going to rain and what is the color of the sky?" It's just answer one of the questions.
It's there a way where the dialogflow can understand the two intents?
Thanks.
Currently, this feature is not present in the dialogflow (or any NLP engine i guess). Dialogflow takes an input sentence and maps it to an intent based on confidence score.
Even if you the NLP engine gives you confidence score of all the intents, you would have problem in combining them.
One solution could be making an intent C which would contain such training phrases, but that would require thorough planning about what users might ask, and what intents should be grouped together to make new intents.

LUIS List entity

I am using "list" entity. However, I do not achieve my expected result.
Here is what I have for LUIS intent:
getAnimal
I want to get a cat**[animal]**.
Here is what I have with LUIS entities:
List Entities [animal]
cat: russian blue, persian cat, british shorthair
dog: bulldog, german shepard, beagle
rabbit: holland lop, american fuzzy lop, florida white
Here is what I have with LUIS Phrase lists:
Phrase lists [animal_phrase]
cat, russian blue, persian cat, british shorthair, dog, bulldog, german shepard, beagle, etc
Desired:
When user enters "I want to get a beagle." It will be match with "getAnimal" intent.
Actual:
When user enters "I want to get a beagle." It will be match with "None" intent.
Please help. Your help will be appreciated.
So using a phrase list is a good way to start, however you need to make sure you provide enough data for LUIS to be able to learn the intents as well as the entities separate from the phrase list. Most likely you need to add more utterances.
Additionally, if your end goal is to have LUIS recognize the getAnimal intent, I would do away with the list entity, and instead use a simple entity to take advantage of LUIS's machine learning, and do so in combination with a phrase list to boost the signal to what an animal may look like.
As the documentation on phrase lists states,
Features help LUIS recognize both intents and entities, but features
are not intents or entities themselves. Instead, features might
provide examples of related terms.
--Features, in machine learning, being a distinguishing trait or attribute of data that your system observes, and what you add to a group/class when using a phrase list
Start by
1. Creating a simple entity called Animal
2. Add more utterances to your getAnimal intent.
Following best practices outlined here, you should include at least 15 utterances per intent. Make sure to include plenty of examples of the Animal entity.
3. Be mindful to include variation in your utterances that are valuable to LUIS's learning (different word order, tense, grammatical correctness, length of utterance and entities themselves). Highly recommend reading this StackOverflow answer I wrote on how to build your app properly get accurate entity detection if you want more elaboration.
above blue highlighted words are tokens labeled to the simple Animal entity
3. Use a phrase list.
Be sure to include values that are not just 1 word long, but 2, 3, and 4 words long in length, as different animal names may possibly be that long in length (e.g. cavalier king charles spaniel, irish setter, english springer spaniel, etc.) I also included 40 animal breed names. Don't be shy about adding Related Values suggested to you into your phrase list.
After training your app to update it with your changes, prosper!
Below "I want a beagle" reaches the proper intent. LUIS will even be able to detect animals that were not entered in the app in entity extraction.

Multiple intents handling approach - email parsing

My bot reads and replies in simple mail conversation. More like in chat manner, one or 2 sentences only done through email. My backend is taking care of reading emails, interpreting api.ai responses, storing locally useful data and sending next questions. Before sending to api.ai, messages are split in sentences.
What I've seen from example conversations already done by humans is that the end users are quite often sending several significant information in one sentence. That means that from e.g. 8 possible peaces of information I totally can have (mostly non required) I can get in one sentence any 2 of them.
How to organize that?
I started with one intent for each field I require. But to solve case with any two intents in one sentence, I am extending user says examples with other field too. At the end I will have 8 intents which are actually filled with similar examples.
Now I am thinking to have just one intent and cover all in it. That might work, but the real question is that really way to do it?
Here are example conversations to describe issue better
v1 - simple way like in api.ai examples
- u: Hi. I need notebook bellow $700.
- b: Great. What size should it be?
- u: 17'
- b: I have gaming one at $590 and one professional for $650.
- u: I more to gaming one.
v2 - what I can expect from real life examples
- u: Hi I would like to buy 15 inch gaming laptop.
- great, what price range?
- ...
Api.ai has a feature called slot filling that allows to collect parameter values within a single intent. It's great for building conversational interfaces. You can see if it's compatible with you use case.
Here's how such intent could look like for the examples you provided:
See the "book_notebook" intent:
and how it would work in conversation:
See a test for the "book_notebook" intent:

IBM watson natural langage classification

I know you can create categories for words using IBM Watson NLP classification. But would it be possible to train or create categories based on quantities of a word. For example, one pack of cigarette is bad category, 2 packs is harmful category, 3 packs is lethal category. Thank you in advance.
In case you are interested, you can still use the NLC to classify text that does not contain numbers associated.
For example:
Text: "I never smoke"
Class: healthy
Text: "I smoke sometimes"
Class: not_so_healthy
Text: "I smoke a lot of cigarettes everyday"
Class: harmful
Text: "I never stop smoking"
Class: lethal
Watson NLU doesn't provide slot or word categories as do the NLU solutions e.g. from Nuance/Vocon or Inferret. That means that you can classify complete utterances as the older answer below illustrates as a class/intent, but you cannot group words of similar paradigmatical meaning into word classes - e.g. class "vehicle" = car, truck, bicycle.

Identifying the context of word in sentence

I created classifier to classy the class of nouns,adjectives, Named entities in given sentence. I have used large Wikipedia dataset for classification.
Like :
Where Abraham Lincoln was born?
So classifier will give this short of result - word - class
Where - question
Abraham Lincoln - Person, Movie, Book (because classifier find Abraham Lincoln in all there categories)
born - time
When Titanic was released?
when - question
Titanic - Song, movie, Vehicle, Game (Titanic
classified in all these categories)
Is there any way to identify exact context for word?
Please see :
Word sense disambiguation would not help here. Because there might not be near by word in sentence which can help
Lesk algorithm with wordnet or sysnet also does not help. Because it for suppose word Bank lesk algo will behave like this
======== TESTING simple_lesk ===========
TESTING simple_lesk() ...
Context: I went to the bank to deposit my money
Sense: Synset('depository_financial_institution.n.01')
Definition: a financial institution that accepts deposits and channels the money into lending activities
TESTING simple_lesk() with POS ...
Context: The river bank was full of dead fishes
Sense: Synset('bank.n.01')
Definition: sloping land (especially the slope beside a body of water)
Here for word bank it suggested as financial institute and slopping land. While in my case I am already getting such prediction like Titanic then it can be movie or game.
I want to know is there any other approach apart from Lesk algo, baseline algo, traditional word sense disambiguation which can help me to identify which class is correct for particular keyword?
Titanic -
Thanks for using the pywsd examples. With regards to wsd, there are many other variants and i'm coding them by myself during my free time. So if you want to see it improve do join me in coding the open source tool =)
Meanwhile, you will find the following technologies more relevant to your task, such as:
Knowledge base population (http://www.nist.gov/tac/2014/KBP/) where tokens/segments of text are assigned an entity and the task is to link them or to solve a simplified question and answer task.
Knowledge representation (http://groups.csail.mit.edu/medg/ftp/psz/k-rep.html)
Knowledge extraction (https://en.wikipedia.org/wiki/Knowledge_extraction)
The above technologies usually includes several sub-tasks such as:
Wikification (http://nlp.cs.rpi.edu/kbp/2014/elreading.html)
Entity linking
Slot filling (http://surdeanu.info/kbp2014/def.php)
Essentially you're asking for a tool that is an NP-complete AI system for language/text processing, so I don't really think such a tool exists as of yet. Maybe it's IBM Watson.
if you're looking for the field to look into, the field is out there but if you're looking at tools, most probably wikification tools are closest to what you might need. (http://nlp.cs.rpi.edu/paper/WikificationProposal.pdf)

Resources