당신은 당신이 모든 것을 가지고 있는지 확인하기 위해 주요 배포판을 사용하고 스페인 모델
(여기에 해당 : http://stanfordnlp.github.io/CoreNLP/download.html)
다운로드해야
package edu.stanford.nlp.examples;
import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.pipeline.*;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.trees.tregex.*;
import edu.stanford.nlp.util.*;
import java.util.*;
public class TregexExample {
public static void main(String[] args) {
// set up pipeline
Properties props = StringUtils.argsToProperties("-props", "StanfordCoreNLP-spanish.properties");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// Spanish example
Annotation spanishDoc = new Annotation("...insert Spanish text...");
pipeline.annotate(spanishDoc);
// get first sentence
CoreMap firstSentence = spanishDoc.get(CoreAnnotations.SentencesAnnotation.class).get(0);
Tree firstSentenceTree = firstSentence.get(TreeCoreAnnotations.TreeAnnotation.class);
// use Tregex to match
String nounPhrasePattern = "/grup\\.nom/";
TregexPattern nounPhraseTregexPattern = TregexPattern.compile(nounPhrasePattern);
TregexMatcher nounPhraseTregexMatcher = nounPhraseTregexPattern.matcher(firstSentenceTree);
while (nounPhraseTregexMatcher.find()) {
nounPhraseTregexMatcher.getMatch().pennPrint();
}
}
}
감사합니다. nounPhrasePattern을 변경하는 동사 그룹과 동일한 작업을 수행해야합니까? –
예 "/grup\\.verb/"로 변경하십시오. – StanfordNLPHelp
완벽. 고마워. –