Book Image

Mastering Python for Data Science

By : Samir Madhavan
Book Image

Mastering Python for Data Science

By: Samir Madhavan

Overview of this book

Table of Contents (19 chapters)
Mastering Python for Data Science
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
7
Estimating the Likelihood of Events
Index

The Stanford Named Entity Recognizer


The Named Entity Recognizer is a task that classifies the elements of a sentence into categories, such as person, organization, location, and so on. Stanford Named Entity Recognizer is one of the most popular out there and can be found at http://nlp.stanford.edu/.

The Stanford Named Entity Recognizer can be downloaded at http://nlp.stanford.edu/software/stanford-ner-2014-06-16.zip.

The following code shows the Stanford Named Entity Recognizer in action:

>>> from nltk.tag.stanford import NERTagger.

>>> st = NERTagger('./lib/stanford-ner/classifiers/english.all.3class.distsim.crf.ser.gz', './lib/stanford-ner/stanford-ner.jar')

>>> st.tag('''Barrack Obama is the president of the United States of America . His father is from Kenya and Mother from United States of America. 
           He has two daughters with his wife. He has strong opposition in Congress due to Republicans'''.split()) 


[[(u'Barrack', u'PERSON'),
  (u'Obama',...