nltk.StanfordNERTagger

class nltk.StanfordNERTagger(*args, **kwargs)[source]

A class for Named-Entity Tagging with Stanford Tagger. The input is the paths to:

  • a model trained on training data
  • (optionally) the path to the stanford tagger jar file. If not specified here, then this jar file must be specified in the CLASSPATH envinroment variable.
  • (optionally) the encoding of the training data (default: UTF-8)

Example:

>>> from nltk.tag import StanfordNERTagger
>>> st = StanfordNERTagger('english.all.3class.distsim.crf.ser.gz') 
>>> st.tag('Rami Eid is studying at Stony Brook University in NY'.split()) 
[('Rami', 'PERSON'), ('Eid', 'PERSON'), ('is', 'O'), ('studying', 'O'),
 ('at', 'O'), ('Stony', 'ORGANIZATION'), ('Brook', 'ORGANIZATION'),
 ('University', 'ORGANIZATION'), ('in', 'O'), ('NY', 'LOCATION')]

Methods

__init__(*args, **kwargs)
evaluate(gold) Score the accuracy of the tagger against the gold standard.
parse_output(text, sentences)
tag(tokens)
tag_sents(sentences)