TaggedCorpusReader and UnigramTagger in nltk (python)
Question: I'm trying to use nltk to auto-categorize news articles in a very lo-fi way.
I've created a custom corpus of word/tag pairs correlating to my categories
(ie. teacher/EDU, computer/TECH, etc.) I've been reading around and [this
question](http://stackoverflow.com/questions/5919355/custom-tagging-with-nltk)
got me pretty close, but I'm still stuck.

Based on my code so far, how do I use my tagger to tag my sentence?

    
    
    import nltk
    
    # Loads my custom word/tag corpus
    from nltk.corpus.reader import TaggedCorpusReader
    reader = TaggedCorpusReader('taggers','.*')
    
    #Sets up the UnigramTagger
    default_tagger = nltk.data.load(nltk.tag._POS_TAGGER)
    tagger = nltk.tag.UnigramTagger(model=reader.tagged_words(), backoff=default_tagger)
    
    #Sample content
    sent = 'The students went to school to ask their teacher what the homework for the day was but she told them to check their email.'
    tokens = nltk.tokenize.word_tokenize(sent)
    
    # Sad Panda
    tagged = tagger.tag(tokens) 
    # ^ produces AttributeError: 'ConcatenatedCorpusView' object has no attribute 'get'
    

It's also very possible that this is a poor way to go about doing what I'm
trying to do, but it seems good enough for a first run. Thanks in advance.


Answer: Taggers are for part-of-speech tagging, not text classification. Take a look
at the reuters corpus - it categorizes news articles into multiple categories
using a category file. Then look at the nltk.classify module and read up on
how to train text classifiers.

