1

I want to check if name, industry, title or geograpic info, any of these are present in a sentence. I couldn't find a way to do this, so I decided to check the tags of the words, if Proper Noun (NNP), I consider it as a Personalized sentence.

My logic is as below

def pers(sentence):
    for sent in nltk.sent_tokenize(sentence):
        for chunk in nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(sent))):
            if hasattr(chunk, 'label'):
                print(chunk.label(), ' '.join(c[0] for c in chunk))

Now when I pass

sentence = "Hey Marsh We saw you checking out the new collection."

It gives this output

PERSON Hey

Why is it considering Hey as a Person? And Why is it not considering Marsh as a Person?

Also when I pass sentence = "this could be you Jana"

It does not detect any name, While Jana is a name of a person.

Is there any way I can fix this? Any help would be appreciated, Thank you.

user18148705
  • 215
  • 1
  • 11

0 Answers0