Tôi đang cố gắng sử dụng Stanford CoreNLP. Tôi đã sử dụng một số mã từ web để hiểu những gì đang xảy ra với công cụ lõi. Tôi đã thử chạy dự án trong Eclipse nhưng tiếp tục gặp phải một ngoại lệ bộ nhớ. Tôi đã thử tăng kích thước heap nhưng không có bất kỳ sự khác biệt. Bất kỳ ý tưởng về lý do tại sao điều này tiếp tục xảy ra? Đây có phải là vấn đề về mã cụ thể không? Mọi hướng dẫn sử dụng CoreNLP sẽ thật tuyệt vời.Sử dụng Stanford CoreNLP
EDIT - Mã Added
import edu.stanford.nlp.dcoref.CorefChain;
import edu.stanford.nlp.dcoref.CorefCoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
public class testmain {
public static void main(String[] args) {
String text = "Viki is a smart boy. He knows a lot of things.";
Annotation document = new Annotation(text);
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
pipeline.annotate(document);
Map<Integer, CorefChain> graph = document.get(CorefCoreAnnotations.CorefChainAnnotation.class);
Iterator<Integer> itr = graph.keySet().iterator();
while (itr.hasNext()) {
String key = itr.next().toString();
String value = graph.get(key).toString();
System.out.println(key + " " + value);
}
}
}
đăng mã tại đây –
@Pangea Đã thêm mã. –
Tôi sử dụng corenlp trong nhật thực với-Xms4g và nó hoạt động tốt. – alienCoder