java - Stanford CoreNLP sentiment -


i'm trying implement corenlp sentiment analyzer in eclipse. getting error:

unable resolve "edu/stanford/nlp/models/lexparser/englishpcfg.ser.gz" 

as either class path, filename or url. installed of nlp files using maven not sure why looking else. here code getting error on.

import java.util.properties;   import edu.stanford.nlp.ling.coreannotations; import edu.stanford.nlp.neural.rnn.rnncoreannotations; import edu.stanford.nlp.pipeline.annotation; import edu.stanford.nlp.pipeline.stanfordcorenlp; import edu.stanford.nlp.sentiment.sentimentcoreannotations; import edu.stanford.nlp.trees.tree; import edu.stanford.nlp.util.coremap;  public class stanfordsentiment {   stanfordcorenlp pipeline;     public stanfordsentiment(){     properties props = new properties();     props.setproperty("annotators", "tokenize, ssplit, parse, sentiment");      pipeline = new stanfordcorenlp(props);   }  public float calculatesentiment (string text) {           float mainsentiment = 0;          int longest = 0;         annotation annotation = pipeline.process(text);         (coremap sentence : annotation.get(coreannotations.sentencesannotation.class)) {             tree tree = sentence.get(sentimentcoreannotations.annotatedtree.class);             int sentiment = rnncoreannotations.getpredictedclass(tree) - 2;             string parttext = sentence.tostring();             if (parttext.length() > longest) {                 mainsentiment = sentiment;                 longest = parttext.length();             }          }         return mainsentiment;    } } 

public class sentimentanalysis {      public static void main(string[] args) throws ioexception {         string text = "i happy";         properties props = new properties();         props.setproperty("annotators",                 "tokenize, ssplit, pos, lemma, parse, sentiment");         stanfordcorenlp pipeline = new stanfordcorenlp(props);          annotation annotation = pipeline.process(text);         list<coremap> sentences = annotation                 .get(coreannotations.sentencesannotation.class);         (coremap sentence : sentences) {             string sentiment = sentence                     .get(sentimentcoreannotations.classname.class);             system.out.println(sentiment + "\t" + sentence);         }     } } 

hope help..:)


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -