I taking a file at standard input which looks like
12 125 "neg" Won the match #getin . P
and then doing word analysis of the sentence.
I dont know why but the loop is not getting incremented in the function "unigrams_nrc".
i value is still 0
Here is the code:
def unigrams_nrc(file):
for line in file:
(term,score,numPos,numNeg) = re.split("\t", line.strip())
print sentence[i] #=> prints all 0's i does not increment
if re.match(sentence[i],term.lower()):
wordanalysis["unigram"] = found
else:
found = False
if found:
wordanalysis["trail_unigram"] = found if re.match(sentence[(len(sentence)-1)],term.lower()) else not(found)
wordanalysis["lead_unigram"] = found if re.match(sentence[0],term.lower()) else not(found)
wordanalysis["nonzero_sscore"] = float(score) if (float(score) != 0) else 0
wordanalysis["sscore>0"] = (float(score) > 0)
wordanalysis["sscore"] = (float(score) != 0)
if re.match(tweet[len(sentence)-1],term.lower()):
wordanalysis["sscore !=0 last token"] = (float(score) != 0)
for line in sys.stdin:
#12 125 "neg" Won the match #getin . P
(tweetid,num,senti,tweets) = re.split("\t+",line.strip())
sentence = re.split("\s+", tweets.strip())
for i in range(0,len(sentence)):
unigrams_nrc(file)
Even if I pass i in parameter to the function.. still no change.
ithat's 0, it'ssentence[i].for line in file:is not indented, so we don't know what it is in that block and what isn't.