edwin
edwin

Reputation: 1252

Extract information from sentence

I'm creating a simple chatbot. I want to obtain the information from the user response. An example scenario:

Bot : Hi, what is your name?
User: My name is Edwin.

I wish to extract the name Edwin from the sentence. However, the user can response in different ways such as

User: Edwin is my name.
User: I am Edwin.
User: Edwin. 

I'm tried to rely on the dependency relations between words but the result does not do well.

Any idea on what technique I could use to tackle this problem?

Upvotes: 0

Views: 681

Answers (4)

Daniel
Daniel

Reputation: 6039

I'd suggest using NER:

enter image description here

You can play with it yourself: http://nlp.cogcomp.org/

Upvotes: 1

James
James

Reputation: 18379

Detecting names can be complicated if you consider things like "My name is not important", "My name is very long", etc.

Here is public domain script in Self that attempts to parse a name, you may be able to adapt it to python, it also does some crazy stuff like lookup the words on Wiktionary to see if they are classified as names,

https://www.botlibre.com/script?id=525804

Upvotes: 0

Minelli
Minelli

Reputation: 419

There are many alternatives, over only 2 'models':

  • Based on NLP training; uses HTTP for integration/delivery:

  • based on pattern matching; uses an interpreter (needs an native implementation or a bridge from other implementation)

This is not an extensive listing of current options.

Upvotes: 0

Right leg
Right leg

Reputation: 16710

First off, I think a complete name detection is really heavy to set up. If you want your bot to be able to detect a name in like 99% of the cases, you've got some work. And I suppose the name detection is only the very beginning of your plans...

This said, here are the first ideas that came to my mind:

  • Names are, grammatically speaking, nouns. So if one can perform a grammatical analysis of the sentence, some candidates to the name can be found.
  • Names are supposed to begin with a cap, although on a chat this is likely not to be respected, so it might be of little use... However, if one came across a word beginning with a cap, it is likely to be someone's name (though it could be a place's name...).
  • The patterns you could reasonably think of when introducing yourself are not that numerous, so you could "hard-code" them, with of course a little tolerance towards typos.
  • If you are expecting an actual name, you could use a database holding a huge amount of names, but have fun with the Hawaiian or Chinese names. Still, this appears as a viable solution in the case of European names.

However, I am no AI specialist, and I'm looking forward to seeing other proposals.

Upvotes: 1

Related Questions