NLP POS Tagging与NER

POS Tagging

import nltk
s = "Steve Jobs was the CEO of Apple Corp."
tags = nltk.pos_tag(s.split())
tags

[('Steve', 'NNP'), ('Jobs', 'NNP'), ('was', 'VBD'), ('the', 'DT'), ('CEO', 'NNP'), ('of', 'IN'), ('Apple', 'NNP'), ('Corp.', 'NNP')]

NER

nltk.ne_chunk(tags)

Tree('S', [Tree('PERSON', [('Steve', 'NNP')]), Tree('PERSON', [('Jobs', 'NNP')]), ('was', 'VBD'), ('the', 'DT'), Tree('ORGANIZATION', [('CEO', 'NNP')]), ('of', 'IN'), Tree('ORGANIZATION', [('Apple', 'NNP')]), ('Corp.', 'NNP')])

NLP POS Tagging与NER_第1张图片

你可能感兴趣的:(NLP)