我試圖使用CoreNLP(Java)對大量產品評論進行情感分析。總的來說,我發現分析的準確性非常好。從我閱讀的內容來看,我使用的模型最初是使用電影評論(我認爲)創建的,因此它不是100%適合分析產品評論。我想知道最好的方法去「提高」我的分析的準確性。「增強」CoreNLP情感分析結果
我在想的主要是除了產品評論的文字之外,我還有用戶提供的星級評分。值範圍從1-5,其中1星是最低的。我希望有一種方法可以在生成情感分數時考慮星級評分,因爲它更準確地反映了用戶對特定產品的感受。 CoreNLP中的情緒分析評分有沒有一種方法可以最好地具有星級評分因子?我的分析代碼看起來是這樣的:
List<ProductReview> reviews = this.reviewRepository.findAll();
for (ProductReview review : reviews) {
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref, sentiment");
props.put("ner.model", "edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
int starRating = review.getStarRating();
String reviewText = review.getTitle() + " : " + review.getReviewText();
if (!StringUtils.isEmpty(reviewText)) {
int longest = 0;
int mainSentiment = 0;
Annotation annotation = pipeline.process(reviewText);
String sentimentStr = null;
List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
Tree sentimentTree = sentence.get(SentimentCoreAnnotations.SentimentAnnotatedTree.class);
int sentiment = RNNCoreAnnotations.getPredictedClass(sentimentTree) - 2;
String partText = sentence.toString();
if (partText.length() > longest) {
mainSentiment = sentiment;
sentimentStr = sentence.get(SentimentCoreAnnotations.SentimentClass.class);
longest = partText.length();
}
}
}
}
我怎麼能最好納入星級評定(或其他信息,如票上最有用的商品評論等)成CoreNLP正在執行的分析?這是我必須分開做的事嗎?或者有沒有辦法將其他數據直接納入情緒分析引擎?