another error in tagging program

enas khalil enas_khalil at yahoo.com
Wed Oct 12 12:01:33 CEST 2005


hello all
i have run  the following code :

# the taggerI interface
from nltk.tagger import *
from nltk.tokenizer import WhitespaceTokenizer
from nltk.tokenizer import *
from nltk.token import *

# Using UnigramTagger
##Before aUnigramTagger can be used to tag data ,it must be trained on training corpus,
# it uses this corpus to determine which tags are most common for each word . UnigramTaggers
# are trained using the train method which takes a tagged corpus:
# tag2.txt is a tagged trainning corpus
tagged_txt_str=open('tag2.txt').read()
tagged_txt_token=Token(TEXT=tagged_txt_str)
WhitespaceTokenizer().tokenize(tagged_txt_token)
#TaggedTokenizer().tokenize(tagged_txt_token)
#Tagger().tokenize(tagged_txt_token)
tagger=UnigramTagger()
tagger.train(tagged_txt_token) 
 
and got the following error :
Traceback (most recent call last):
  File "F:\MSC first Chapters\error correct.py", line 19, in -toplevel-
    tagger.train(tagged_txt_token)
  File "C:\Python24\Lib\site-packages\nltk\tagger\__init__.py", line 332, in train
    tag = subtok[TAG]
KeyError: 'TAG'
>>> 
please help 
thanks 
enas

		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051012/a458f43c/attachment.html>


More information about the Python-list mailing list