I am trying to run the Wanish library in python and getting the following instead of the result expected.
>>> from wanish import Wanish
>>> wanish = Wanish()
>>> wanish.perform_url("http://www.bbc.com/news/uk-england-london-40269625")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36\lib\site-packages\wanish-0.6.3-py3.6.egg\wanish\__init__.py", line 167, in perform_url
File "C:\Python36\lib\site-packages\wanish-0.6.3-py3.6.egg\wanish\summarizer.py", line 55, in get_plain_text
File "C:\Python36\lib\site-packages\wanish-0.6.3-py3.6.egg\wanish\summarizer.py", line 91, in create_referat
File "C:\Python36\lib\site-packages\wanish-0.6.3-py3.6.egg\wanish\summarizer.py", line 68, in textrank
File "C:\Python36\lib\site-packages\wanish-0.6.3-py3.6.egg\wanish\langid.py", line 175, in classify
File "C:\Python36\lib\site-packages\wanish-0.6.3-py3.6.egg\wanish\langid.py", line 148, in instance2fv
TypeError: 'float' object cannot be interpreted as an integer
I have tried this using Python 3.6 and even with python 2.7
I came across the same issues.
Actually if you visit pypi wanish page you will see that it located only in Python 3.x categories:
Programming Language :: Python
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
It won't work in Python 2 because in code there is from urllib.parse import urlparse, urljoin
line. But from docs:
The
urlparse
module is renamed tourllib.parse
in Python 3
The offending line is this one* in LanguageIdentifier.instance2fv()
:
arr = np.zeros((self.nb_numfeats,), dtype='uint32')
In LanguageIdentifier.from_modelstring()
, the factory method used to instantiate this class, you can find this:
nb_numfeats = len(nb_ptc) / len(nb_pc)
In python3, division using the /
operator always returns a float, where in python2 it returns an int if both operants are ints. So this is a bug.
The langid.py
file seems to actually come from a different project, where this error was fixed a while ago .
*I would normally link to the code directly, but someone decided to drop a ~2.4MB blob of base64 in the source file, so github doesn't allow linking.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.