diff --git a/.gitignore b/.gitignore index 775f6ee..948ede5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ SentiStrength.jar -SentiStrengthData/ \ No newline at end of file +SentiStrengthData/ +__pycache__ \ No newline at end of file diff --git a/sentistrength/__init__.py b/sentistrength/__init__.py index 4f6a692..76d4726 100644 --- a/sentistrength/__init__.py +++ b/sentistrength/__init__.py @@ -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)] diff --git a/setup.py b/setup.py index fc19354..be6a472 100644 --- a/setup.py +++ b/setup.py @@ -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.",