def score_new_words sent tweets new_sent norms for entry in tweets tem

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def score_new_words(sent, tweets, new_sent, norms):
for entry in tweets:
temp_sent = 0 # temporary sentimentality for each tweet
for word in sent.items():
if 'text' in entry:
if word[0] in entry['text'].encode("utf-8"):
temp_sent += word[1]
for word in sent.items():
if 'text' in entry:
for new_word in entry['text'].encode("utf-8").split(" "):
if not sent.has_key(new_word):
if new_sent.has_key(new_word):
new_sent[new_word] += temp_sent
norms[new_word] += 1
else:
new_sent[new_word] = temp_sent
norms[new_word] = 1