Code Monkey home page Code Monkey logo

pysentiment's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pysentiment's Issues

utf-8 codec cannot decode error

I got the following error:

Traceback (most recent call last):
File "sentiment_test.py", line 4, in
lm = ps.LM()
File "/usr/local/lib/python3.5/dist-packages/pysentiment-0.1.2.1-py3.5.egg/pysentiment/base.py", line 54, in init
self._tokenizer = Tokenizer()
File "/usr/local/lib/python3.5/dist-packages/pysentiment-0.1.2.1-py3.5.egg/pysentiment/utils.py", line 39, in init
self._stopset = self.get_stopset()
File "/usr/local/lib/python3.5/dist-packages/pysentiment-0.1.2.1-py3.5.egg/pysentiment/utils.py", line 56, in get_stopset
for line in fin.readlines():
File "/usr/lib/python3.5/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 184: invalid continuation byte

new LM dictionary? which computation?

Hello there!

Thanks for this very useful package. I see there hasnt been any update for quite a long time. A few questions if you have 5 min.

  • Do you plan on updating the LM dictionary? Their dictionary has been updated in 2015 according to their website.

  • Also, could you please provide us with a little bit more details about how you compute the sentiment over a sentence? Do you take the ratio of positives / (positives + negative) terms?

Thanks!

Removing Pandas dependency

Thanks for creating this library. While installing, I notice that this project requires pandas (which in turn requires numpy). You seem to be using pandas to parse the csv file. I feel that removing the dependency can be beneficial.

Error with Installation.

(py36) bash-3.2$ pip install pysentiment
Collecting pysentiment
Using cached https://files.pythonhosted.org/packages/3d/32/b9822555aeafd949ba2e1e5f0ca9a7aea857802965c61a6290e711b11e6c/pysentiment-0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/2n/3jnbv29510n3ld2t0fqk6xhm0000gn/T/pip-install-cjoj1h33/pysentiment/setup.py", line 8, in
install_req = [e.strip() for e in open(path_req).readlines()]
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/2n/3jnbv29510n3ld2t0fqk6xhm0000gn/T/pip-install-cjoj1h33/pysentiment/requirements.txt'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/2n/3jnbv29510n3ld2t0fqk6xhm0000gn/T/pip-install-cjoj1h33/pysentiment/
(py36) bash-3.2$

ERROR: Command "python setup.py egg_info" failed

$ pip install pysentiment
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pysentiment
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/3d/32/b9822555aeafd949ba2e1e5f0ca9a7aea857802965c61a6290e711b11e6c/pysentiment-0.2.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\LIJIAX~1\AppData\Local\Temp\pip-install-lqrdhnbk\pysentiment\setup.py", line 8, in <module>
        install_req = [e.strip() for e in open(path_req).readlines()]
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\LIJIAX~1\\AppData\\Local\\Temp\\pip-install-lqrdhnbk\\pysentiment\\requirements.txt'
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\LIJIAX~1\AppData\Local\Temp\pip-install-lqrdhnbk\pysentiment\
$ pip --version
pip 19.1.1 from D:\install\miniconda\lib\site-packages\pip (python 3.7)

Unable to download - FileNotFoundError - Not finding requirements.txt

Using python 3.6.5 - using pip install pysentiment - I am getting the following error:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\...\AppData\Local\Temp\pip-install-1h2p8ypv\pysentiment\setup.py", line 8, in <module>
        install_req = [e.strip() for e in open(path_req).readlines()]
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\User...Local\\Temp\\pip-install-1h2p8ypv\\pysentiment\\requirements.txt'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\...\AppData\Local\Temp\pip-install-1h2p8ypv\pysentiment\

Could anyone help me better understand whats going on here? I updated the setuptools and it still is not working.

FileNotFoundError: 'Currencies.txt'

The error message is FileNotFoundError: [Errno 2] No such file or directory: 'D:\\install\\miniconda\\lib\\site-packages\\pysentiment\\static/Currencies.txt'

When I use pysentiment.LM(), the full error message:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-17-208ee0b7ec88> in <module>
----> 1 lm = pysentiment.LM()
      2 lm.get_score(lm.tokenize(text=df["Headline"][0])).values()

D:\install\miniconda\lib\site-packages\pysentiment\base.py in __init__(self, tokenizer)
     53         self._negset = set()
     54         if tokenizer is None:
---> 55             self._tokenizer = Tokenizer()
     56         else:
     57             self._tokenizer = tokenizer

D:\install\miniconda\lib\site-packages\pysentiment\utils.py in __init__(self)
     34     def __init__(self):
     35         self._stemmer = nltk.PorterStemmer()
---> 36         self._stopset = self.get_stopset()
     37 
     38     def tokenize(self, text):

D:\install\miniconda\lib\site-packages\pysentiment\utils.py in get_stopset(self)
     50         stopset = set()
     51         for f in files:
---> 52             fin = open('%s/%s'%(STATIC_PATH, f), 'rb')
     53             for line in fin.readlines():
     54                 line = line.decode(encoding='latin-1')

FileNotFoundError: [Errno 2] No such file or directory: 'D:\\install\\miniconda\\lib\\site-packages\\pysentiment\\static/Currencies.txt'

I install the package locally, because pip install pysentiment with error #10

Tokenizing issue with 3-char "e" in abbreviations

I can't see the pattern to this issue yet. But this hits error as long as you have "xED" in the query, where x can be anything.

s = 'Just ued is good enough'
tokens = lm.tokenize(s)

Error message:

    212         """
    213         return (
--> 214             word[-1] == word[-2] and
    215             self._is_consonant(word, len(word)-1)
    216         )

IndexError: string index out of range

Currencies.txt is not ASCII or UTF-8 encoded.

In pysentiment/static there are some helper files. But Currencies.txt is encoded with ISO8859 instead of ASCII or UTF-8, which can cause an unexpected encoding error in pysentiment/utils.py#L52. Personally, I encountered this problem and manually solved it by changing pysentiment/utils.py#L52 to be fin = open('%s/%s'%(STATIC_PATH, f), 'rb', encoding="iso8859-1"). It's quite annoying as I only need this simple module to do minor text analysis but have to spend a lot of time tracking this internal error. Hope this can be fixed.

install not working with python 2.7

I tried to install from both git and pip, but I'm getting the following:

import pysentiment as ps
  File "pysentiment/utils.py", line 9
    class BaseTokenizer(object, metaclass=abc.ABCMeta):
                                         ^
SyntaxError: invalid syntax

is this compatible with Python 2?

NameError: name '__file__' is not defined

how can I handle it?

NameError Traceback (most recent call last)
in
5
6
----> 7 path_req = os.path.join(os.path.dirname(os.path.abspath(file)), 'requirements.txt')
8 install_req = [e.strip() for e in open(path_req).readlines()]
9

NameError: name 'file' is not defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.