nltk.parse.NaiveBayesDependencyScorer
¶
-
class
nltk.parse.
NaiveBayesDependencyScorer
[source]¶ A dependency scorer built around a MaxEnt classifier. In this particular class that classifier is a
NaiveBayesClassifier
. It uses head-word, head-tag, child-word, and child-tag features for classification.>>> from nltk.parse.dependencygraph import DependencyGraph, conll_data2
>>> graphs = [DependencyGraph(entry) for entry in conll_data2.split('\n\n') if entry] >>> npp = ProbabilisticNonprojectiveParser() >>> npp.train(graphs, NaiveBayesDependencyScorer()) >>> parses = npp.parse(['Cathy', 'zag', 'hen', 'zwaaien', '.'], ['N', 'V', 'Pron', 'Adj', 'N', 'Punc']) >>> len(list(parses)) 1
Methods¶
__init__ () |
|
score (graph) |
Converts the graph into a feature-based representation of each edge, and then assigns a score to each based on the confidence of the classifier in assigning it to the positive label. |
train (graphs) |
Trains a NaiveBayesClassifier using the edges present in graphs list as positive examples, the edges not present as negative examples. |