NLP | Classifier-based tagging
- It is a subclass of ClassifierBasedTagger that uses classification technique to do part-of-speech tagging.
- From the words, features are extracted and then passed to an internal classifier.
- It classifies the features and returns a label i.e. a part-of-speech tag.
- The feature detector finds multiple length suffixes, does some regular expression matching, and looks at the unigram, bigram, and trigram history to produce a fairly complete set of features for each word
Code #1 : Using ClassifierBasedPOSTagger
Accuracy : 0.9309734513274336
ClassifierBasedPOSTagger class inherits from ClassifierBasedTagger and only implements a feature_detector() method. All the training and tagging is done in ClassifierBasedTagger.
Code #2 : Using MaxentClassifier
Accuracy : 0.9258363911072739
custom feature detector detecting features
There are two ways to do it:
- Subclass ClassifierBasedTagger and implement a feature_detector() method.
- Pass a function as the feature_detector keyword argument into ClassifierBasedTagger at initialization.
Code #3 : Custom Feature Detector
Accuracy : 0.8733865745737104