我採取一個文件中,它看起來像循環列表蟒蛇不增加
12 125 "neg" Won the match #getin . P
,然後做句子的單詞分析標準輸入。
我不知道爲什麼,但函數「unigrams_nrc」中的循環沒有增加。 i value is still 0
下面是代碼:
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)
即使我在參數傳遞i
的功能..仍然沒有改變。
哪個功能? – aIKid
unigrams_nrc是函數 – fscore
它不是'我',它是0,它是'句子[我]'。 – aIKid