java - stanford nlp 共指解析错误 : Exception in thread "main" java. lang.IllegalArgumentException : File doesn't exist: example_file. txt

标签 java ubuntu stanford-nlp

我从下载页面下载了 stanfordCoreNLP 模块版本 stanford-corenlp-full-2018-02-27 并解压缩文件。在解压目录中创建了 example_file.txt 文件。我添加了文本 我的名字是 Sam。我想成为一名宇航员。我不久前吃过零食。。我导航到它被提取到的文件夹,并尝试在命令行中运行为共同引用解析提供的示例代码

stanfordNLP page

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/

相关文章:

java - 如何使用 itextpdf 在 PDF 中放置电子邮件 anchor

java - 为什么我会收到此未处理的异常?

java - 为什么 SonarQube 无法分配请求的地址?

ubuntu -/usr/bin/ld : cannot find -lGL (Ubuntu 16. 04)

python - 如何使用 corenlp 用 python 提取句法特征?

java - org.eclipse.persistence.exceptions.ValidationException : Cannot add a query whose types conflict with an existing query

linux - shell 脚本中的 for x in {1..10} 仅运行一次

python - NLTK : combining stanford tagger and personal tagger

java - 在 Stanford CoreNLP 流水线中输入 Penn Treebank 组成树

JavaCC 正则表达式 [#xC0-#xD6]