dkpro / dkpro-keyphrases

DKPro Keyphrases Extraction API
Other
10 stars 3 forks source link

Error: TreeTaggerPosLemmaTT4J class not found #40

Open LauraS2 opened 8 years ago

LauraS2 commented 8 years ago

Hi,

I am currently trying to use the CooccurrenceGraphExtractor. To set up my system, I have installed the TreeTagger. Furthermore, I have build the dkpro core treetagger-asl project using the build.xml.

For my test project I have added the jars for english - created during the treetagger build - as libraries in eclipse.

My Maven POM looks like this (Sry, it is not supported as attachment by GitHub):

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Test</groupId>
  <artifactId>Test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
  </build>

    <repositories>
        <repository>
            <id>ukp-oss</id>
            <url>https://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-ukp-releases-local/</url>
        </repository>
        <repository>
            <id>ukp-oss-releases</id>
            <url>http://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-releases</url>
        </repository>
        <repository>
            <id>ukp-oss-model-releases</id>
            <url>http://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-model-releases-local</url>
        </repository>
        <repository>
            <id>ukp-oss-snapshots-local</id>
            <url>http://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-ukp-snapshots-local</url>
        </repository>

    </repositories>

    <dependencies>
        <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.core</groupId>
            <artifactId>
                de.tudarmstadt.ukp.dkpro.core.treetagger-asl
            </artifactId>
            <version>1.9.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.keyphrases</groupId>
            <artifactId>
                de.tudarmstadt.ukp.dkpro.keyphrases.wrappers-gpl
            </artifactId>
            <version>1.6.0-SNAPSHOT</version>
        </dependency>
                <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.core</groupId>
            <artifactId>
                de.tudarmstadt.ukp.dkpro.core.io.text-asl
            </artifactId>
            <version>1.9.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.core</groupId>
            <artifactId>de.tudarmstadt.ukp.dkpro.core-asl</artifactId>
            <version>1.9.0-SNAPSHOT</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.core</groupId>
            <artifactId>
                de.tudarmstadt.ukp.dkpro.core.opennlp-asl
            </artifactId>
            <version>1.9.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>de.tudarmstadt.ukp.dkpro.keyphrases</groupId>
            <artifactId>de.tudarmstadt.ukp.dkpro.keyphrases.core-asl</artifactId>
            <version>1.6.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

My Java program looks like this:

import static de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.KeyphraseExtractorUtils.getTopRankedUniqueKeyphrases;

import java.io.IOException;
import java.util.List;

import de.tudarmstadt.ukp.dkpro.keyphrases.core.type.Keyphrase;
import de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.Candidate;
import de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.Candidate.CandidateType;
import de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.Candidate.PosType;
import de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.CooccurrenceGraphExtractor;

public class Test {

    public static void main(String[] args) throws IOException {

        String text = "This is a sample text and I dont know what else to write in here.";

        CooccurrenceGraphExtractor extractor = new CooccurrenceGraphExtractor();
        extractor.setMinKeyphraseLength(2);
        extractor.setCandidate(new Candidate(CandidateType.Token, PosType.N));

        List<Keyphrase> keyphrases = extractor.extract(text);

        keyphrases = getTopRankedUniqueKeyphrases(keyphrases, keyphrases.size());
        text = "";
        for (Keyphrase keyphrase : keyphrases) {
            text += keyphrase.getKeyphrase() + " ";
        }

        System.out.println(text);
    }

}

When I try to run it I get the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: de/tudarmstadt/ukp/dkpro/core/treetagger/TreeTaggerPosLemmaTT4J
    at de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.KeyphraseExtractor_ImplBase.createTagger(KeyphraseExtractor_ImplBase.java:195)
    at de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.KeyphraseExtractor_ImplBase.createPreprocessingComponents(KeyphraseExtractor_ImplBase.java:114)
    at de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.CooccurrenceGraphExtractor.createKeyphraseExtractorAggregate(CooccurrenceGraphExtractor.java:48)
    at de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.KeyphraseExtractor_ImplBase.getKeyphraseEngine(KeyphraseExtractor_ImplBase.java:232)
    at de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.KeyphraseExtractor_ImplBase.extract(KeyphraseExtractor_ImplBase.java:83)
    at Test.main(Test.java:25)
Caused by: java.lang.ClassNotFoundException: de.tudarmstadt.ukp.dkpro.core.treetagger.TreeTaggerPosLemmaTT4J
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more

Does anyone know how I can fix this? I am using Java 1.8 and my OS is Windows 10, 64-bit.

Yours, Laura

reckart commented 8 years ago

Looks like DKPro Keyphrases is incompatible with DKPro Core 1.9.0-SNAPSHOT. I think the last version where the TreeTagger component was still called TreeTaggerPosTaggerTT4J was 1.6.1 (or even before that). DKPro Keyphrases should be upgraded to a more recent DKPro Core release.

LauraS2 commented 8 years ago

Thank you for your reply. I will use an older version then.

Yours, Laura