0

Im having issues when using polyglot... is it a bug in polyglot?? Below provided is the codes

import polyglot

from polyglot.downloader import downloader
print(downloader.supported_languages_table("ner2", 3))

Issue persists for the following code also

import polyglot
from polyglot.text import Text, Word
blob = """The Israeli Prime Minister Benjamin Netanyahu has warned that Iran poses a "threat to the 
          entire world"."""
text = Text(blob)
text.entities

Output is an error: IndexError: list index out of range The below is the traceback i recieved for the first block of code. even for the second i received the second block of code.. any help is appreciated Thanks:)

IndexError                                Traceback (most recent call 
last)
<ipython-input-5-3795737b065a> in <module>
  1 from polyglot.downloader import downloader
----> 2 print(downloader.supported_languages_table("ner2", 3))

~\anaconda3\lib\site-packages\polyglot\downloader.py in 
supported_languages_table(self, task, cols)
    976 
    977   def supported_languages_table(self, task, cols=3):
--> 978     languages = self.supported_languages(task)
    979     return pretty_list(languages)
    980 

~\anaconda3\lib\site-packages\polyglot\downloader.py in 
supported_languages(self, task)
    968     """
    969     if task:
--> 970       collection = self.get_collection(task=task)
    971       return [isoLangs[x.id.split('.')[1]]["name"]
    972                                          for x in 
              collection.packages]

~\anaconda3\lib\site-packages\polyglot\downloader.py in 
 get_collection(self, lang, task)
    944     else: raise ValueError("You should pass either the task or the 
    lang")
    945     try:
--> 946       return self.info(id)
    947     except ValueError as e:
    948       if lang: raise LanguageNotSupported("Language {} is not 
              supported".format(id))

~\anaconda3\lib\site-packages\polyglot\downloader.py in info(self, id)
    927     if id in self._packages: return self._packages[id]           
    928     if id in self._collections: return self._collections[id]
--> 929     self._update_index() # If package is not found, most probably 
            we did not
    930                          # warm up the cache
    931     if id in self._packages: return self._packages[id]

~\anaconda3\lib\site-packages\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)

~\anaconda3\lib\site-packages\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

Antony Joy
  • 301
  • 3
  • 15

1 Answers1

0

I find a solution, it replaces 4 items 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).