nltk.tag.StanfordPOSTagger

class nltk.tag.StanfordPOSTagger(*args, **kwargs)[source]
A class for pos 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 StanfordPOSTagger
>>> st = StanfordPOSTagger('english-bidirectional-distsim.tagger') 
>>> st.tag('What is the airspeed of an unladen swallow ?'.split()) 
[('What', 'WP'), ('is', 'VBZ'), ('the', 'DT'), ('airspeed', 'NN'), ('of', 'IN'), ('an', 'DT'), ('unladen', 'JJ'), ('swallow', 'VB'), ('?', '.')]

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)