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 *
# 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'
>>>
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.
-- http://mail.python.org/mailman/listinfo/python-list