benjaminaschultz / shakespeare

Identify relevant scientific papers with simple machine learning techniques
MIT License
8 stars 3 forks source link

ValueError: invalid shape #3

Closed csadorf closed 10 years ago

csadorf commented 10 years ago

After a fresh systemwide install I copied the example files kw.p and nb.p into $HOME/.shakespeare/. When I executed shakespeare -j natnano pnas -o cool_papers.md I get the following output:

Warning: knowledge dir /home/simon/.shakespeare does not contain nb.p (pickled naive bayes object)
Warning: knowledge dir /home/simon/.shakespeare does not contain kw.p (pickled keyword list)
parsing rss feed : natnano
parsing rss feed : pnas
Traceback (most recent call last):
  File "/usr/local/bin/shakespeare", line 5, in <module>
    pkg_resources.run_script('shakespeare==0.1', 'shakespeare')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 505, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1245, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/shakespeare-0.1-py2.7.egg/EGG-INFO/scripts/shakespeare", line 99, in <module>
    good_content = filter_content(new_content,method,nb,kw)
  File "/usr/local/lib/python2.7/dist-packages/shakespeare-0.1-py2.7.egg/shakespeare/__init__.py", line 30, in filter_content
    X = scipy.sparse.lil_matrix((len(new_samples),len(keywords)))
  File "/usr/lib/python2.7/dist-packages/scipy/sparse/lil.py", line 104, in __init__
    self.shape = (M,N)
  File "/usr/lib/python2.7/dist-packages/scipy/sparse/base.py", line 71, in set_shape
    raise ValueError('invalid shape')
ValueError: invalid shape
python --version
Python 2.7.4
benjaminaschultz commented 10 years ago

This behavior seems to indicate that the script couldn't locate an knowledge and then barfed in a way it shouldn't have. I will see if I can reproduce this behavior.

benjaminaschultz commented 10 years ago

I have made changes to the error handling that should prevent this path from executing is no naive bayes and/or keyword list objects are found.