I am creating a chatbot. I am trying to find closely matched entities from the question.

I know there are few options like difflib, fuzzywuzzy but they all good for a single word or match entire statements.


word = 'appel'
patterns = ['ape', 'apple', 'peach', 'puppy'] 

difflib.get_close_matches(word, patterns)

But in my case I have an entire statement

statment = 'I want to buy 2 red appl'

entities = ['red apple','green grapes','red orange','yellow mango']

So I had to set cutoff value very low as it considers whole statement and it will result in extracting entities even if they are not present.

If I had single word entities, I could have simply use word_tokenizer but my that is not the case. I have entities with 2-3 words as mentioned in above case.

So I will have to create bigrams and trigrams to match which will slow down the process and create delay in the response.

Is there a way to deal with it?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.