Je veux obtenir l'analyseur de dépendance de Stanford collapsed. Alors, voici mon code:Stanford Collapsed Dépendance erreur de l'analyseur: loadmodel
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.Sentence;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
import edu.stanford.nlp.trees.*;
import java.util.List;
class Parser{
public static void main(String[] args) {
LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
lp.setOptionFlags(new String[] { "-maxLength", "80","-retainTmpSubcategories" });
String[] sent = { "This", "is", "an", "easy", "sentence", "." };
List<CoreLabel> rawWords = Sentence.toCoreLabelList(sent);
Tree parse = lp.apply(rawWords);
parse.pennPrint();
System.out.println();
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
List<TypedDependency> tdl = gs.typedDependenciesCCprocessed();
System.out.println(tdl);
TreePrint tp = new TreePrint("penn,typedDependenciesCollapsed");
tp.printTree(parse);
}
}
Je reçois les erreurs suivantes pour les 2 codes suivants lorsqu'il est exécuté dans Netbeans.
Pour,
LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
le message d'erreur que je reçois est:
cannot find symbol, symbol: method loadModel(java.lang.String), location: class.LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"); "
Et pour
lp.setOptionFlags(new String[] { "-maxLength", "80","-retainTmpSubcategories" });
le message d'erreur suivant apparaît.
setOptionFlags(java.lang.String..)is not public in edu.stanford.nlp.parser.lexparser.LexicalizedParser; cannot be accessed from outside package.
J'ai importé "stanford-corenlp-1.3.0.jar". Comment puis-je résoudre ce problème s'il vous plaît?