Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven dependency:get does not download Stanford NLP model files

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.

like image 855
W.P. McNeill Avatar asked Jan 10 '13 03:01

W.P. McNeill


1 Answers

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.

like image 125
Jonathan Hendler Avatar answered Oct 21 '22 12:10

Jonathan Hendler