Maven dependency:get does not download Stanford NLP model files

会有一股神秘感。 提交于 2019-11-29 17:15:12

问题


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>

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

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

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.


回答1:


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>

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>

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



来源:https://stackoverflow.com/questions/14250476/maven-dependencyget-does-not-download-stanford-nlp-model-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!