Reputation: 3
I'm new in Python and need it for PoS tagging. Therefore I tried to use the standard tools. I tried to create a tagger and get a ValueError, that I don't understand. My code:
import nltk
tagged_sents = nltk.corpus.brown.tagged_sents(categories = 'reviews')
tagger =nltk.ClassifierBasedTagger(tagged_sents)
I have already checked, that tagged_sents is a list of all sentences. Each sentence self is a list of tuples (word, PoS), like in the documentation:
:param train: A tagged corpus consisting of a list of tagged sentences, where each sentence is a list of (word, tag) tuples.
Why do I get the Value Error?
ValueError: Must specify either training data or trained model.
Upvotes: 0
Views: 940
Reputation:
You've passed tagged_sents
positionally, so it is being used as the feature_detector
argument. You should construct the tagger like this:
tagger = nltk.ClassifierBasedTagger(train=tagged_sents)
See http://www.nltk.org/api/nltk.tag.html#nltk.tag.sequential.ClassifierBasedTagger
Upvotes: 2