The
part of speech tags in the 9/11 report were automatically generated ,
and some of the tags are incorrect. We are going to try to correct at
least some of the errors.
Download
report911_tagged
from the
course
data directory. In nltk, create a reader for the 9/11 corpus
using the following code (replace
[path-to-your-data]
as appropriate):
>>> report911 =
nltk.corpus.TaggedCorpusReader("[path-to-your-data]911_tagged",'.*',".txt")Now
you can see the tagged text with
>>> report911.tagged_words()
[('WE', 'NNP'), ('HAVE', 'NNP'),
('SOME', 'NNP'), ...]Now,
try to improve the tagging. Here is a set of steps you can follow, but
you can use any method you'd like. For example, you might try to use
probabilities or other information to improve a tagger's accuracy, use
nltk's HMM tagger, use the regExp tagger, etc. The more inventive (and
successful), the better your grade will be!
Write a routine that does
cross-validation of the 9/11 tagged corpus. The routine should take as
input two sub-corpora, one for training and one for testing, and output
the accuracy of the test tagging. Run this routine repeatedly, using 10
different 90% / 10% subsets for training and testing respectively.
Average the accuracy for each run and print the final result.
Train
your taggers using the Penn Treebank, which is also tagged with the
Penn tagset. For example, this code uses 100000 sentences from the
treebank for training and applies it to the 9/11 report:
from
nltk.corpus import treebank
>>> unigram_tagger
= nltk.UnigramTagger(treebank.tagged_sents() [:100000])
>>>
unigram_tagger.tag(report911.words())
Generate
the accuracies for your taggers using the performance routine. How do
the results differ from the accuracy when the 9/11 report is used to
train?
Repeat step 4 from above using the corpus
tagged using the Penn Treebank for training. How do the results compare?