Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Rebuild Brown Corpus tags and rerun tagger evaluations. If you train on treebank it should be fairly accurate when you test on brown. import nltk.tag
Rebuild Brown Corpus tags and rerun tagger evaluations. If you train on treebank it should be fairly accurate when you test on brown.
import nltk.tag as tag word-patterns [ (r'^-2 [0-9]+(. [0-9]+)25', (r ' (The l the l Ala l An I an) $ ' ' 'CD'), ' AT ' ) , # cardinal numbers # articles # adjectives # nouns formed from adjectives # adverbs # plural nouns # gerunds (r'.*ing$ ' , 'VBG ' ), past tense verbs nouns (default) # From the NLTK3 cookbook tag-util.py file def backoff tagger (train sents, taqger classes, backoff-None): for cls in tagger classes: backoff cls (train_sents, backoff-backoff) return backoff inner taggerbackoff tagger (brown train, [tag.AffixTagger, tag.UnigramTagger, Cag Bigramlagger tag.TrigramTagger], backoff-tag.RegexpTagger (word_patterns) ) brill_trainer tag.BrillTaggerTrainer (inner_tagger, tag.brill.bril124 )) brill tagger = brill trainer.train (brown train, max rules=400, min sc re=3) print (brill_tagger.evaluate (treebank_test)) print (brill_tagger.evaluate (brown test)) print (brill tagger.evaluate (conll test)) 0.582085042089359 0.9284236339949421 0.6032014228546021 import nltk.tag as tag word-patterns [ (r'^-2 [0-9]+(. [0-9]+)25', (r ' (The l the l Ala l An I an) $ ' ' 'CD'), ' AT ' ) , # cardinal numbers # articles # adjectives # nouns formed from adjectives # adverbs # plural nouns # gerunds (r'.*ing$ ' , 'VBG ' ), past tense verbs nouns (default) # From the NLTK3 cookbook tag-util.py file def backoff tagger (train sents, taqger classes, backoff-None): for cls in tagger classes: backoff cls (train_sents, backoff-backoff) return backoff inner taggerbackoff tagger (brown train, [tag.AffixTagger, tag.UnigramTagger, Cag Bigramlagger tag.TrigramTagger], backoff-tag.RegexpTagger (word_patterns) ) brill_trainer tag.BrillTaggerTrainer (inner_tagger, tag.brill.bril124 )) brill tagger = brill trainer.train (brown train, max rules=400, min sc re=3) print (brill_tagger.evaluate (treebank_test)) print (brill_tagger.evaluate (brown test)) print (brill tagger.evaluate (conll test)) 0.582085042089359 0.9284236339949421 0.6032014228546021Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started