https://stanfordnlp.github.io/CoreNLP/api.html
내 프로그램스탠포드 CoreNLP - 스레드의 예외 "주요"java.lang.OutOfMemoryError와 : Java 힙 공간
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Properties;
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.ling.CoreLabel;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.util.CoreMap;
public class StanfordClass {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
String text = "What is the Weather in Mumbai right now?";
Annotation document = new Annotation(text);
pipeline.annotate(document);
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);
System.out.println(String.format("Print: word: [%s] pos: [%s] ne: [%s]",word, pos, ne));
}
}
}
}
그러나에 예외를 받고 스레드 "주요"java.lang.OutOfMemoryError와 : Java 힙 공간
내가 NER (개체 명 인식기)를 제거하면 내가
1. 시도 무엇 적절한 ty from code 즉 props.setProperty ("annotators", "tokenize, ssplit, pos, lemma, parse");
그러면 코드가 제대로 실행됩니다.
2. 그러나 ner (엔티티 인식기)가 필요합니다. 따라서 eclipse.ini 파일에서 힙 크기를 1g까지 늘리십시오.이 정도의 크기가이 프로그램에 충분하고 힙 크기가이 문제에서 문제가 아닌지 확인하십시오. 케이스. 나는 뭔가 빠져 있지만 그것을 얻지 못한다고 생각한다.
메모리를 더 많이 차지하는 방법을 확인 했습니까? – meditat
어떻게 확인해야합니까? –
이것은 자바 5까지 적용 가능하지만 자바 8과 힙 크기를 1GB까지 사용하는 것은이 간단한 프로그램에 너무 많은 것입니다 –