Gavy
Gavy

Reputation: 143

StanfordNLP OpenIE 4 error

I've been encountering this error:

I ran the OpenIE 4.1 binary but got the following error:

Exception in thread "main" java.lang.NullPointerException at 
com.googlecode.clearnlp.tokenization.EnglishTokenizer.protec‌​tEmoticons
(EnglishTokenizer.java:335) at 
com.googlecode.clearnlp.tokenization.EnglishTokenizer.getTok‌​enList(En 
glishTokenizer.java:109) at 
com.googlecode.clearnlp.tokenization.AbstractTokenizer.getTo‌​kens(AbstractTokenizer.java:58) at 
edu.knowitall.tool.tokenize.ClearTokenizer.tokenize(ClearTok‌​enizer.sc ala:22) 

I've looked up a few sources and found a comment by Yangrui who also had this problem in the past. But there are no solutions. I've checked my openie.4.1.jar file and the com.googlecode.clearnlp.tokenization.EnglishTokenizer.protectEmoticon exists.

Hope someone can help shed some light on this. Thank you in advance.

Upvotes: 1

Views: 109

Answers (1)

Gavy
Gavy

Reputation: 143

I've managed to solve this error. The issue lies with the compilation of the OpenIE 4.0 JAR and OpenIE 4.1 JAR files I downloaded from the official website. (http://knowitall.github.io/openie/).

How to solve? Compile the classes yourself.

  1. Go to https://github.com/knowitall/openie/releases
  2. Choose a release. (I chose 4.1.3)
  3. Download the zip file and unzip the file.
  4. Use terminal and redirect to the folder directory.
  5. Run 'sbt package' and it will start compiling.
  6. Your final JAR file will be found in the target folder/scala-2.10/{openie-assembly-VERSION.jar}

Note: There could be some changes you need to make to your code if you are running OpenIE as a dependency. The code for test is as follows:

    OpenIE openIE = new OpenIE(new ClearParser(new ClearPostagger(new ClearTokenizer())), new ClearSrl(), false, false);

    Seq<Instance> extractions = openIE.extract("Obama is the president of the United States");
    Iterator<Instance> iterator = extractions.iterator();
    while (iterator.hasNext()) {
        Instance inst = iterator.next();
        StringBuilder sb = new StringBuilder();
         sb.append(inst.confidence()).append("\t\t")
         .append(inst.extr().arg1().text()).append("\t\t")
         .append(inst.extr().rel().text()).append("\t\t");

        Iterator<Argument> argIter = inst.extr().arg2s().iterator();
        while (argIter.hasNext()) {
            Part arg = argIter.next();
            sb.append(arg.text()).append("; ");
        }
         System.out.println(sb.toString());
    }

I hope this will help someone in the future.

Upvotes: 1

Related Questions