#Evaluate Accuracy of tagger print("Skipping Accuracy") #print("Evaluating Accuracy") #print("Accuracy: " + str(tagger.evaluate(test_sents))) #Evaluate Accuracy/Precision/Recall of Chunker print("Evaluating Accuracy/Precision/Recall of Chunker") score = chunker.evaluate(conll_test) print("Accuracy: " + str(score.accuracy())) print("Precision: " + str(score.precision())) print("Recall: " + str(score.recall())) # assign pos tagged_sents = tagger.tag_sents(word_list) # assign chunks tagged_sents = [chunker.parse(tagged_sent) for tagged_sent in tagged_sents] #From www.nltk.org/_modules/nltk/grammar.html pcfg_demo() # import nltk.grammar as gram # productions = [] # for tree in tagged_sents: # tree.collapse_unary(collapsePOS = False) # tree.chomsky_normal_form(horzMarkov = 2) # production += tree.productions() # S = gram.Nonterminal('S') # grammar = gram.induce_pcfg(S,productions) # #This generates a grammar derived from the tagger and the trained chunker