Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入wordnet和stopwords时出现chaquopy错误_Python_Android Studio_Nltk_Chaquopy - Fatal编程技术网

Python 导入wordnet和stopwords时出现chaquopy错误

Python 导入wordnet和stopwords时出现chaquopy错误,python,android-studio,nltk,chaquopy,Python,Android Studio,Nltk,Chaquopy,当应用程序崩溃时,会显示以下错误消息: 我假设崩溃发生在调用wn.synsets时?这是我看到的堆栈跟踪: if (! Python.isStarted()) { Python.start(new AndroidPlatform(this)); Python py = Python.getInstance(); final PyObject pyobj = py.getModule("sum");

当应用程序崩溃时,会显示以下错误消息:


我假设崩溃发生在调用
wn.synsets
时?这是我看到的堆栈跟踪:

 if (! Python.isStarted()) {
           Python.start(new AndroidPlatform(this));
           Python py = Python.getInstance();
           final PyObject pyobj = py.getModule("sum");


           b2.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View view) {
                   if (path==null) {
                       Toast.makeText(documentupload.this, " plz upload the doc", Toast.LENGTH_SHORT).show();
                       //upload.setText(path);


                       // Intent intent= new Intent(documentupload.this,result.class);
                       //startActivity(intent);
                   }
                   else {
                       PyObject obj = pyobj.callAttr("main", Words.toString());
                       upload.setText(obj.toString());
                       Toast.makeText(documentupload.this, "uploaded" + Words, Toast.LENGTH_LONG).show();
                      // Toast.makeText(documentupload.this, " plz upload the doc", Toast.LENGTH_LONG).show();
                   }
               }
           });
我不认为“wordnet”和“corpus”pip包与nltk有任何关系。相反,您应该使用
nltk.download
安装它们,正如错误消息所说


由于模拟器错误,您可能需要循环调用
nltk.download
,如中所述。

您的Python代码不包含名为
main
的函数,因此不清楚Java和Python代码之间的连接是什么。请编辑您的问题以澄清这一点,并包括来自的完整堆栈跟踪。实际上,取消这一点,我已经复制了该问题,几分钟后我将发布一个答案。我已经下载了nltk,但我无法导入nltk子库,如stopwords如何从nltk导入nltk。语料库导入stopwords打印(stopwords.words('english'))如何使这些东西工作还有其他问题我编辑了我的答案,注意到“语料库”pip包与nltk也没有任何关系,因此它不会为您提供stopwords功能。相反,使用
nltk安装它。如我所说,下载
。错误消息可能会告诉您要使用哪个包名。我使用过此方法,但当我们尝试从python脚本文件访问库时,会生成错误,无法访问。如果您仍然需要帮助,请创建一个新问题并提供完整错误,包括堆栈跟踪,以及代码的相关部分。
 if (! Python.isStarted()) {
           Python.start(new AndroidPlatform(this));
           Python py = Python.getInstance();
           final PyObject pyobj = py.getModule("sum");


           b2.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View view) {
                   if (path==null) {
                       Toast.makeText(documentupload.this, " plz upload the doc", Toast.LENGTH_SHORT).show();
                       //upload.setText(path);


                       // Intent intent= new Intent(documentupload.this,result.class);
                       //startActivity(intent);
                   }
                   else {
                       PyObject obj = pyobj.callAttr("main", Words.toString());
                       upload.setText(obj.toString());
                       Toast.makeText(documentupload.this, "uploaded" + Words, Toast.LENGTH_LONG).show();
                      // Toast.makeText(documentupload.this, " plz upload the doc", Toast.LENGTH_LONG).show();
                   }
               }
           });
  File "/data/user/0/com.chaquo.python.pkgtest3/files/chaquopy/AssetFinder/requirements/nltk/corpus/util.py", line 120, in __getattr__
  File "/data/user/0/com.chaquo.python.pkgtest3/files/chaquopy/AssetFinder/requirements/nltk/corpus/util.py", line 85, in __load
  File "/data/user/0/com.chaquo.python.pkgtest3/files/chaquopy/AssetFinder/requirements/nltk/corpus/util.py", line 80, in __load
  File "/data/user/0/com.chaquo.python.pkgtest3/files/chaquopy/AssetFinder/requirements/nltk/data.py", line 585, in find
LookupError: 
**********************************************************************
  Resource [93mwordnet[0m not found.