我从下载页面下载了 stanfordCoreNLP 模块版本 stanford-corenlp-full-2018-02-27
并解压缩文件。在解压目录中创建了 example_file.txt 文件。我添加了文本 我的名字是 Sam。我想成为一名宇航员。我不久前吃过零食。
。我导航到它被提取到的文件夹,并尝试在命令行中运行为共同引用解析提供的示例代码
java -Xmx5g -cp stanford-corenlp-3.9.1.jar:stanford-corenlp-3.9.1-sources.jar:* edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse,mention,coref -coref.algorithm neural -file example_file.txt
我收到以下错误消息
Exception in thread "main" java.lang.IllegalArgumentException: File doesn't exist: example_file.txt
at edu.stanford.nlp.io.FileSequentialCollection$FileSequentialCollectionIterator.primeNextFile(FileSequentialCollection.java:364)
at edu.stanford.nlp.io.FileSequentialCollection$FileSequentialCollectionIterator.<init>(FileSequentialCollection.java:269)
at edu.stanford.nlp.io.FileSequentialCollection.iterator(FileSequentialCollection.java:238)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:1166)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:1010)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.run(StanfordCoreNLP.java:1365)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1427)
对此有什么帮助吗?
最佳答案
在使用 -cp
选项定义的类路径中查找资源。包含 example_file.txt
的目录可能应该包含在其中
-cp“.:stanford-corenlp-3.9.1.jar:stanford-corenlp-3.9.1-sources.jar:*”
添加到类路径中的点表示此目录
,它显然包含您的文件。另外,双引号可以防止 shell 在末尾扩展通配符,在我看来,除非它包含与应用程序相关的 jar,否则它不应该存在。最多可能是*.jar
。
关于java - stanford nlp 共指解析错误 : Exception in thread "main" java. lang.IllegalArgumentException : File doesn't exist: example_file. txt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50061815/