mirror of
https://github.com/gsi-upm/senpy
synced 2025-08-24 02:22:20 +00:00
tweaks for py2/py3 compatibility
This commit is contained in:
@@ -17,10 +17,15 @@ For example:
|
||||
'''
|
||||
|
||||
import os, math, re, sys, fnmatch, string
|
||||
reload(sys)
|
||||
import codecs
|
||||
|
||||
def make_lex_dict(f):
|
||||
return dict(map(lambda (w, m): (w, float(m)), [wmsr.strip().split('\t')[0:2] for wmsr in open(f) ]))
|
||||
maps = {}
|
||||
with codecs.open(f, encoding='iso-8859-1') as f:
|
||||
for wmsr in f:
|
||||
w, m = wmsr.strip().split('\t')[:2]
|
||||
maps[w] = m
|
||||
return maps
|
||||
|
||||
f = 'vader_sentiment_lexicon.txt' # empirically derived valence ratings for words, emoticons, slang, swear words, acronyms/initialisms
|
||||
try:
|
||||
@@ -356,8 +361,8 @@ if __name__ == '__main__':
|
||||
]
|
||||
sentences.extend(tricky_sentences)
|
||||
for sentence in sentences:
|
||||
print sentence,
|
||||
print(sentence)
|
||||
ss = sentiment(sentence)
|
||||
print "\t" + str(ss)
|
||||
print("\t" + str(ss))
|
||||
|
||||
print "\n\n Done!"
|
||||
print("\n\n Done!")
|
||||
|
Reference in New Issue
Block a user