<DIV>when i run this script to make a training of some text and so can use condfreqdistributions to guess text in test , my code isas follows:</DIV> <DIV><BR>from nltk.probability import ConditionalFreqDist<BR>from nltk.tokenizer import WhitespaceTokenizer<BR>from nltk.tagger import *<BR>token1 = []<BR>train_tokens = []<BR>cfdist=ConditionalFreqDist()<BR># open the file containning the training tagged data<BR>dd= open("fataha.txt").readlines() # generate a string </DIV> <DIV> </DIV> <DIV># open the file containning the training tagged data<BR>data2= (open("besm.txt").read())# generate a string </DIV> <DIV>corpus=Token(TEXT=data2)# convert string to token to tokenize it <BR>WhitespaceTokenizer(SUBTOKENS='WORDS').tokenize(corpus)<BR>#print unicode('\xc8\xd3\xe3','cp1256')</DIV> <DIV>for xx in corpus['WORDS'] :<BR> token1.append(xx['TEXT'])<BR> <BR>for item in dd:<BR>
train_tokens.append(item)<BR> <BR> l=len(item)<BR> i=int(item.find("="))<BR> <BR> aa=Token(TEXT=item)<BR> aa['WORDS']=item[0:i]<BR> aa['TAG']=item[i+1:l+1]<BR> j=int(item.find('-'))<BR> print j<BR> pos=item[j+1:i]<BR> <BR> word=item[:j]<BR> <BR> train_tokens.append(aa)</DIV> <DIV> for xx in token1:<BR> if word==xx:<BR> print 'hi'<BR> cond=cfdist.conditions()</DIV> <DIV> <FONT style="BACKGROUND-COLOR: #ffffbf"> for cond in word
:cfdist[cond].inc[aa['TAG']]</FONT></DIV> <DIV>i got this error :</DIV> <DIV><FONT face=arial size=3>Traceback (most recent call last):<BR> File "F:\MSC first Chapters\28-11\firstprog1.py", line 53, in -toplevel-<BR> for cond in word :cfdist[cond].inc[aa['TAG']]<BR>TypeError: unsubscriptable object</FONT></DIV> <DIV><FONT size=3></FONT> </DIV> <DIV><FONT size=3> what does unsubscriptable object this means , and how can ihandle it </FONT></DIV> <DIV><FONT size=3></FONT> </DIV> <DIV><FONT size=3>also if you please suggest me a good refrence in how to handle different types of objects in python as token ,and how i can generate different token attributes </FONT></DIV> <DIV><FONT size=3>thanks</FONT></DIV><p>
<hr size=1> <a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/">Yahoo! Music Unlimited - Access over 1 million songs. Try it free.</a>