Fix path issues

This commit is contained in:
zhunhung
2019-11-09 10:11:37 +08:00
parent 4c4b29c133
commit 98dabb3ff7
3 changed files with 10 additions and 3 deletions
+2 -1
View File
@@ -1,2 +1,3 @@
SentiStrength.jar
SentiStrengthData/
SentiStrengthData/
__pycache__
+7 -1
View File
@@ -16,6 +16,9 @@ class PySentiStr:
self.SentiStrengthLocation = ss_Path
def setSentiStrengthLanguageFolderPath(self, sslf_Path):
# Ensure it has a forward slash at the end
if sslf_Path[-1] != '/':
sslf_Path += '/'
self.SentiStrengthLanguageFolder = sslf_Path
def getSentiment(self, df_text, score='scale'):
@@ -37,7 +40,10 @@ class PySentiStr:
stdout_text = stdout_text.rstrip().replace("\t"," ")
stdout_text = stdout_text.replace('\r\n','')
senti_score = stdout_text.split(' ')
senti_score = list(map(float, senti_score))
try:
senti_score = list(map(float, senti_score))
except ValueError:
raise ValueError("SentiStrengthLanguageFolderPath is set as '{}'. Ensure it is correct and ends with a forward slash '/'".format( self.SentiStrengthLanguageFolder))
senti_score = [int(i) for i in senti_score]
if score == 'scale':
senti_score = [sum(senti_score[i:i+2])/4 for i in range(0, len(senti_score), 2)]
+1 -1
View File
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="sentistrength",
version="0.0.3",
version="0.0.5",
author="Zhun Hung",
author_email="yongzhunhung@gmail.com",
description="Python 3 Wrapper for SentiStrength, reads a single or multiple input with options for binary class or scale output.",