I am novice in Python and NLP, and my problem is how to finding out Intent of given questions, for example I have sets of questions and answers like this :
question:What is NLP; answer: NLP stands for Natural Language Processing
I did some basic POS tagger
on given questions in above question I get entety [NLP]
I also did String Matching
using this algo.
Basically I faced following issues :
what is NLP
then it will return exact answersmeaning of NLP
then it failDefinition of NLP
then it failWhat is Natural Language Processing
then it failSo how I should identify user intent of given questions because in my case String matching or pattern matching not works.
Intent recognition — sometimes called intent classification — is the task of taking a written or spoken input, and classifying it based on what the user wants to achieve. Intent recognition forms an essential component of chatbots and finds use in sales conversions, customer support, and many other areas.
Intent Detection is a vital component of any task-oriented conversational system. In order to understand the user's current goal, the system must leverage its intent detector to classify the user's utterance (provided in varied natural language) into one of several predefined classes, that is, intents.
Intent extraction is a type of Natural-Language-Understanding (NLU) task that helps to understand the type of action conveyed in the sentences and all its participating parts. An example of a sentence with intent could be: Siri, can you please remind me to pickup my laundry on my way home?
You can do intent identification with DeepPavlov, it supports multi-label classification. More information can be found in http://docs.deeppavlov.ai/en/master/components/classifiers.html The demo page https://demo.ipavlov.ai
you can use spacy for training a custom parser for chat intent semantics.
spaCy's parser component can be used to trained to predict any type of tree structure over your input text. You can also predict trees over whole documents or chat logs, with connections between the sentence-roots used to annotate discourse structure.
for example: "show me the best hotel in berlin"
('show', 'ROOT', 'show')
('best', 'QUALITY', 'hotel') --> hotel with QUALITY best
('hotel', 'PLACE', 'show') --> show PLACE hotel
('berlin', 'LOCATION', 'hotel') --> hotel with LOCATION berlin
To train the model you need data in this format:
# training data: texts, heads and dependency labels
# for no relation, we simply chose an arbitrary dependency label, e.g. '-'
TRAIN_DATA = [
("find a cafe with great wifi", {
'heads': [0, 2, 0, 5, 5, 2], # index of token head
'deps': ['ROOT', '-', 'PLACE', '-', 'QUALITY', 'ATTRIBUTE']
}),
("find a hotel near the beach", {
'heads': [0, 2, 0, 5, 5, 2],
'deps': ['ROOT', '-', 'PLACE', 'QUALITY', '-', 'ATTRIBUTE']
})]
TEST_DATA:
input : show me the best hotel in berlin
output: [
('show', 'ROOT', 'show'),
('best', 'QUALITY', 'hotel'),
('hotel', 'PLACE', 'show'),
('berlin', 'LOCATION', 'hotel')
]
for more details Please check the below link. https://spacy.io/usage/examples#intent-parser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With