, 나는에 대한 루프 (자바)에 주석 문서의 문장을 통과 :스탠포드 NLP를 사용하여 문장 (CoreMap)에서 토큰 (CoreLabel)을 바꾸는 방법은 무엇입니까? 평소처럼
for (CoreMap sentence : document.get(CoreAnnotations.SentencesAnnotation.class)) {
...
}
그런 다음, 그 안에, 내가 단어를 사용하여 문장 (예 : "선생님")에서 단어를 제거 인덱스, 나는 CoreLabel
방법 setWord()
을 사용하여 "존"으로 새로운 단어 텍스트를 설정하고 결국 나는 같은 인덱스의 문장 갱신 단어를 추가 :
sentence.get(CoreAnnotations.TokensAnnotations.class).remove(token.get(CoreAnnotations.IndexAnnotation.class));
token.setWord("John");
sentence.get(CoreAnnotations.TokensAnnotation.class).add(token.get(CoreAnnotations.IndexAnnotation.class),token);
문제는 문장으로 유지된다 입니다. 제거 직후에 문장 텍스트를 인쇄하더라도 변경되지 않습니다. 내가 뭔가 잘못하고 있는거야? 더 합리적인 방법이 있습니까?