【问题标题】:Maven dependency:get does not download Stanford NLP model filesMaven依赖:get不下载斯坦福NLP模型文件
【发布时间】:2013-01-10 03:41:36
【问题描述】:

Stanford Natural Language Processing Toolkit 的核心组件在 stanford-corenlp-1.3.4.jar 文件中包含 Java 代码,并且在单独的 stanford-corenlp-1.3.4-models.jar 文件中包含(非常大的)模型文件。 Maven 不会自动下载模型文件,但前提是您将 <classifier>models</classifier> 行添加到 .pom。这是一个获取代码和模型的 .pom sn-p。

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

我试图弄清楚如何从命令行执行相同的操作。似乎 Maven dependency:get 插件任务是执行此操作的方法。以下命令行似乎是正确的

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

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

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

【问题讨论】:

  • 嗨,Bill,我们不是 maven 专家,可能做错了什么,但是,我不知道是什么,其他人需要告诉我们什么。
  • 任何使用 Scala 和 SBT 的人都可以使用:val stanfordNlp = "edu.stanford.nlp" % "stanford-corenlp" % "1.3.4" artifacts (Artifact("stanford-corenlp", "models"), Artifact("stanford-corenlp"))

标签: maven models stanford-nlp


【解决方案1】:

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

<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 包含我使用的库:

  <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 目录。

【讨论】:

  • 有“源”包吗?我试过 sources,但没有运气。
猜你喜欢
  • 1970-01-01
  • 2017-06-06
  • 1970-01-01
  • 2014-04-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多