polyglot
polyglot copied to clipboard
List index out of range
Windows 8.1 Python 3.5 Trying to run the NER example given in the documentation and it results in a list index out of range error.
Hi, @GJena , thanks for pointing it out. Can you provide more details, like the stacktrace when the error happens?
List index out of range occurs also to me:
Environment: (Win10, Anaconda, Conda, python 2.7, PyICU installed from github and PyCLD2 installed from whl)
Language Detection and Tokenization examples run correctly, but from there on examples fail.
Here is the code:
-- coding: utf-8 --
import polyglot from polyglot.text import Text, Word text = Text(u"O primeiro uso de desobediência civil em massa ocorreu em setembro de 1906.")
print("{:<16}{}".format("Word", "POS Tag")+"\n"+"-"*30) for word, tag in text.pos_tags: print(u"{:<16}{:>2}".format(word, tag))
and here is Traceback
Traceback (most recent call last):
File "C:/Users/Petteri/PycharmProjects/Polyglot/Testi.py", line 8, in
I get the same error. window 7, 64 bit, Python 3.5 anaconda, installed pyicu and pycld2 wheels from http://www.lfd.uci.edu/~gohlke/pythonlibs/
It seems to happen whenever the downloader gets involved or when I try to call the downloader directly:
print(downloader.models())
IndexError Traceback (most recent call last)
<ipython-input-16-5df9209721dc> in <module>()
----> 1 print(downloader.models())
C:\Program Files\Anaconda3\lib\site-packages\polyglot-16.7.4-py3.5.egg\polyglot\downloader.py in models(self)
491
492 def models(self):
--> 493 self._update_index()
494 return [pkg for (id,pkg) in self._packages.items()
495 if pkg.subdir != 'corpora']
C:\Program Files\Anaconda3\lib\site-packages\polyglot-16.7.4-py3.5.egg\polyglot\downloader.py in _update_index(self, url)
841 packages = []
842 for p in objs:
--> 843 P = Package.fromcsobj(p)
844 packages.append(P)
845 self._packages = dict((p.id, p) for p in packages)
C:\Program Files\Anaconda3\lib\site-packages\polyglot-16.7.4-py3.5.egg\polyglot\downloader.py in fromcsobj(csobj)
214 filename = attrs["name"]
215 task = subdir.split(path.sep)[0]
--> 216 language = subdir.split(path.sep)[1]
217 attrs = attrs
218 return Package(**locals())
IndexError: list index out of range
ok, the solution was hidden here https://github.com/aboSamoor/polyglot/issues/12
@petteri72 did it resolved?
Now it works :) To solve this issue: I replace path.sep with "/" (4 items in lines number: 208, 210, 215 and 216) at file "C:\Python36\Lib\site-packages\polyglot\downloader.py", ("fromcsobj" function in line 205)
@ehsanasgarian This method doesn't work...I replace 4 items in function "fromcsobj"
@ehsanasgarian @Seymour0724 This method doesn't work for me too. Do you have any update? thanks!
After restart "jupyter lab" in powershell, it works! So please don't forget restart jupyter in command. Thank you everybody.