Beheben Sie die Koreferenz mit Stanford CoreNLP - Parser-Modell kann nicht geladen werden

Ich möchte einen sehr einfachen Job machen: Wenn ich eine Zeichenkette mit Pronomen habe, möchte ich sie auflösen.

Zum Beispiel möchte ich den Satz "Mary hat ein kleines Lamm. Sie ist süß." in "Mary hat ein kleines Lamm. Mary ist süß.".

Ich habe versucht, Stanford CoreNLP zu verwenden. Ich scheine jedoch nicht in der Lage zu sein, den Parser zum Starten zu bringen. Ich habe alle in meinem Projekt enthaltenen Gläser mit Eclipse importiert und der JVM (-Xmx3g) 3 GB zugewiesen.

Der Fehler ist sehr umständlich:

Ausnahme im Thread "main" java.lang.NoSuchMethodError: edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel (Ljava / lang / String; [Ljava / lang / String;) Ledu / stanford / nlp / parser / lexparser / LexicalizedParser;

Ich verstehe nicht, woher dieses L kommt, ich denke, es ist die Wurzel meines Problems ... Das ist ziemlich seltsam. Ich habe versucht, in die Quelldateien zu gelangen, aber es gibt dort keinen falschen Verweis.

Code:

import edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation;
import edu.stanford.nlp.dcoref.CorefCoreAnnotations.CorefChainAnnotation;
import edu.stanford.nlp.dcoref.CorefCoreAnnotations.CorefGraphAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.NamedEntityTagAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.PartOfSpeechAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.TextAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation;
import edu.stanford.nlp.trees.TreeCoreAnnotations.TreeAnnotation;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.dcoref.CorefChain;
import edu.stanford.nlp.pipeline.*;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.IntTuple;
import edu.stanford.nlp.util.Pair;
import edu.stanford.nlp.util.Timing;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import java.util.Properties;

public class Coref {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) throws IOException, ClassNotFoundException {
    // creates a StanfordCoreNLP object, with POS tagging, lemmatization, NER, parsing, and coreference resolution 
    Properties props = new Properties();
    props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);

    // read some text in the text variable
    String text = "Mary has a little lamb. She is very cute."; // Add your text here!

    // create an empty Annotation just with the given text
    Annotation document = new Annotation(text);

    // run all Annotators on this text
    pipeline.annotate(document);

    // these are all the sentences in this document
    // a CoreMap is essentially a Map that uses class objects as keys and has values with custom types
    List<CoreMap> sentences = document.get(SentencesAnnotation.class);

    for(CoreMap sentence: sentences) {
      // traversing the words in the current sentence
      // a CoreLabel is a CoreMap with additional token-specific methods
      for (CoreLabel token: sentence.get(TokensAnnotation.class)) {
        // this is the text of the token
        String word = token.get(TextAnnotation.class);
        // this is the POS tag of the token
        String pos = token.get(PartOfSpeechAnnotation.class);
        // this is the NER label of the token
        String ne = token.get(NamedEntityTagAnnotation.class);       
      }

      // this is the parse tree of the current sentence
      Tree tree = sentence.get(TreeAnnotation.class);
      System.out.println(tree);

      // this is the Stanford dependency graph of the current sentence
      SemanticGraph dependencies = sentence.get(CollapsedCCProcessedDependenciesAnnotation.class);
    }

    // This is the coreference link graph
    // Each chain stores a set of mentions that link to each other,
    // along with a method for getting the most representative mention
    // Both sentence and token offsets start at 1!
    Map<Integer, CorefChain> graph = 
      document.get(CorefChainAnnotation.class);
    System.out.println(graph);
  }
}

Vollständiger Stack-Trace:

Hinzufügen eines Annotator-Tokens Hinzufügen eines Annotators ssplit Hinzufügen eines Annotators pos Laden des POS-Modells [edu / stanford / nlp / models / pos-tagger / englisch-left3words / englisch-left3words-distsim.tagger] ... Laden der Standardeigenschaften vom trainierten Tagger edu / stanford / nlp / models / pos-tagger / english-left3words / english-left3words-distsim.tagger POS-Tagger-Modell aus edu / stanford / nlp / models / pos-tagger / english-left3words / english-left3words-distsim.tagger lesen ... erledigt [2,1 Sek.]. fertig [2,2 Sek.]. Hinzufügen eines Annotator-Lemmas Hinzufügen eines Annotators ner Laden des Klassifikators aus edu / stanford / nlp / models / ner / english.all.3class.distsim.crf.ser.gz ... done [4.0 sec]. Laden des Klassifikators aus edu / stanford / nlp / models / ner / english.muc.distsim.crf.ser.gz ... erledigt [3,0 Sek]. Laden des Klassifikators aus edu / stanford / nlp / models / ner / english.conll.distsim.crf.ser.gz ... erledigt [3,3 Sek]. Annotator-Analyse hinzufügen Ausnahme im Thread "main" java.lang.NoSuchMethodError: edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel (Ljava / lang / String; [Ljava / lang / String;) Ledu / stanford / nlp / parser / lexparser / LexicalizedParser; um edu.stanford.nlp.pipeline.ParserAnnotator.loadModel (ParserAnnotator.java:115) um edu.stanford.nlp.pipeline.ParserAnnotator. (ParserAnnotator.java:64) um edu.stanford.nlp.pipeline.st $ (StanfordCoreNLP.java:603) um edu.stanford.nlp.pipeline.StanfordCoreNLP $ 12.create (StanfordCoreNLP.java:585) um edu.stanford.nlp.pipeline.AnnotatorPool.get (AnnotatorPool.java:62) um edu .nlp.pipeline.StanfordCoreNLP.construct (StanfordCoreNLP.java:329) at edu.stanford.nlp.pipeline.StanfordCoreNLP. (StanfordCoreNLP.java:196) at edu.stanford.nlp.pipeline.Stanford ) bei edu.stanford.nlp.pipeline.StanfordCoreNLP. (StanfordCoreNLP.java:178) bei Coref.main (Coref.java:41)

Antworten auf die Frage(1)

Ihre Antwort auf die Frage