IndexError:使用多语言时列出超出范围的索引

问题描述

我在使用多语言时遇到问题...这是多语言中的错误吗??下面提供的是代码

import polyglot

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

问题仍然存在于以下代码

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

输出一个错误: IndexError:列表索引超出范围 以下是我收到的第一个代码块的回溯。即使是第二个我收到第二个代码块..任何帮助表示赞赏 谢谢:)

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,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: 列表索引超出范围

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...