Maven 依赖:get 不下载斯坦福 NLP 模型文件 [英] Maven dependency:get does not download Stanford NLP model files

查看:16
本文介绍了Maven 依赖:get 不下载斯坦福 NLP 模型文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Stanford Natural Language Processing Toolkit 的核心组件在 stanford-corenlp 中有 Java 代码-1.3.4.jar 文件,并且在单独的 stanford-corenlp-1.3.4-models.jar 文件中有(非常大的)模型文件.Maven 不会自动下载模型文件,但前提是您将 models 行添加到 .pom.这是一个 .pom 片段,它同时获取代码和模型.

The core component of the Stanford Natural Language Processing Toolkit has Java code in a stanford-corenlp-1.3.4.jar file, and has (very large) model files in a separate stanford-corenlp-1.3.4-models.jar file. Maven does not download the model files automatically, but only if you add <classifier>models</classifier> line to the .pom. Here is a .pom snippet that fetches both the code and the models.

    <dependency>
        <groupId>edu.stanford.nlp</groupId>
        <artifactId>stanford-corenlp</artifactId>
        <version>1.3.4</version>
        <classifier>models</classifier>
    </dependency>

我想弄清楚如何从命令行做同样的事情.看起来像 Maven dependency:get 插件任务是做到这一点的方法.以下命令行似乎是正确的

I'm trying to figure out how to do the same thing from the command line. It seems like the Maven dependency:get plugin task is the way to do this. The following command line seems like it would be correct

mvn dependency:get 
    -DgroupId=edu.stanford.nlp 
    -DartifactId=stanford-corenlp 
    -Dversion=LATEST 
    -Dclassifier=models 
    -DrepoUrl=repo1.maven.org

但是,它只下载代码 Jar 文件,而不下载模型 Jar 文件.

However, it only downloads the code Jar file but not the models Jar file.

知道为什么会这样吗?我不确定这是否只是斯坦福 NLP 包的问题,​​还是 dependency:getclassifier 选项的更普遍问题.

Any idea why this is the case? I'm not sure if this is just an issue with the Stanford NLP package or a more general issue with the classifier option of dependency:get.

推荐答案

首先感谢您的提问.它回答了我关于如何同时包含数据和库的问题.我将与 Maven 分享我正在做的事情,但我不确定这是否满足您的问题:

First thanks for your question. It answered my question about how to include both the data and the lib. I'll share what I'm doing with Maven, but I'm not sure this satisfies your question:

<dependency>
  <groupId>edu.stanford.nlp</groupId>
  <artifactId>stanford-corenlp</artifactId>
  <version>1.3.4</version>
  <classifier>models</classifier>
</dependency>
<dependency>
      <groupId>edu.stanford.nlp</groupId>
      <artifactId>stanford-corenlp</artifactId>
      <version>1.3.4</version>
    </dependency>
    <dependency>
      <groupId>edu.stanford.nlp</groupId>
      <artifactId>stanford-parser</artifactId>
      <version>2.0.4</version>
    </dependency>

另外,请确保我的 jar 包含我使用的库:

Also, make sure my jar includes the libs I use:

  <build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>org.example.nlpservice.NLP</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
      <executions>
        <execution>
          <id>make-assembly</id> <!-- this is used for inheritance merges -->
          <phase>package</phase> <!-- bind to the packaging phase -->
          <goals>
            <goal>single</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
   </build>

最后,你试过 mvn deploymvn install 了吗?您可以从本地 mvn cache/repo 复制到/lib 目录.

Finally, have you tried mvn deploy or mvn install yet? You could copy from your local mvn cache/repo into a /lib directory.

这篇关于Maven 依赖:get 不下载斯坦福 NLP 模型文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆