저는 C #을 사용하고 있으며 이것은 Stanford Corenlp 문서를 기반으로 결과를 얻으려고 시도한 코드 스 니펫입니다.
나는 이것을 위해 어떤 주석을 사용할지 모른다.
Annotation document = new Annotation(input);
pipeline.annotate(document);
var sentences = document.get(new CoreAnnotations.SentencesAnnotation().getClass()) as ArrayList;
foreach (CoreMap sentence in sentences)
{
var tokens = sentence.get(new CoreAnnotations.TokensAnnotation().getClass()) as ArrayList;
TokenSequencePattern pattern = TokenSequencePattern.compile("([ner: PERSON]+) /was|is/ /an?/ []{0,3} /painter|artist/");
TokenSequenceMatcher matcher = pattern.getMatcher(tokens);
while (matcher.find())
{
String matchedString = matcher.group();
var matchedTokens = matcher.groupNodes() as ArrayList;
foreach (CoreLabel matchedToken in matchedTokens)
{
//matchedToken.get(new CoreAnnotations.TokensAnnotation().getClass()));
//Which Annotation class to use in order to get result data from matched token?
}
}
}
당신이 무엇을 얻고 싶은지 잘 모르겠습니다. 의 각 토큰 matchedTokens
에는 문장의 다른 토큰과 동일한 주석이 있습니다.
첫 번째 캡처 그룹 ( ([ner: PERSON]+)
부분) 을 얻으려면 matcher.group(1)
또는 을 사용해야합니다 matcher.groupNodes(1)
. 일치 된 결과에 대한 다른 기능 은 http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/ling/tokensregex/BasicSequenceMatchResult.html 을 참조하십시오 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다