2016-09-04 3 views
0

텍스트가 이미 토큰 화되고, 문장 분할 및 POS 태그가 있습니다.CoreNLP : pos 태그 제공

내가 추가 주석 보조 정리 (lemma)에 CoreNLP를 사용하고 싶습니다라는 엔티티 (ner), contituency 및 종속 구문 분석 (parse), 및 coreferences (dcoref).

명령 줄 옵션과 명령 줄에서 가능하게하는 옵션 파일 사양이 조합되어 있습니까? 그래서 남아있는 모든이며, 이것은 잘 작동

tokenize.whitespace = true 
ssplit.eolonly = true 

:

this question에 따르면, 나는 토큰을 구분으로 공백을 볼 수 파서를 요청할 수 있습니다, 나의 특성이를 추가하여 문장을 구분 등의 줄 바꿈이 파일 CoreNLP에 POS 태그도 제공하고 싶다고 지정하십시오.

스탠포드 파서를 단독으로 사용하는 경우 기존 POS 태그를 사용하려면 seems to be possible이지만 CoreNLP 호출에 해당 구문을 복사하는 것은 효과가없는 것처럼 보입니다. 예를 들어,이 작동하지 않습니다 this question이 프로그램 호출을 포함

java -cp *:./* -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -props my-properties-file -outputFormat xml -outputDirectory my-output-dir -sentences newline -tokenized -tagSeparator/-tokenizerFactory edu.stanford.nlp.process.WhitespaceTokenizer -tokenizerMethod newCoreLabelTokenizerFactory -file my-annotated-text.txt 

동안, 나는 CoreNLP가 더 큰 시스템의 일부로서 명령 줄을 형성 호출, 그래서 난 정말이 이것을 달성 할 수 있는지 부탁 해요 명령 행 옵션.

답변

2

나는 이것이 명령 행 옵션으로는 가능하지 않다고 생각한다.

사용자 정의 주석자를 만들고이를 파이프 라인에 포함 시키려면 해당 경로를 사용할 수 있습니다. 당신은에 의해 "_"로 구분 POS 토큰과 토큰을 제공하는 경우

package edu.stanford.nlp.pipeline; 

import edu.stanford.nlp.util.logging.Redwood; 
import edu.stanford.nlp.ling.*; 
import edu.stanford.nlp.util.concurrent.MulticoreWrapper; 
import edu.stanford.nlp.util.concurrent.ThreadsafeProcessor; 

import java.util.*; 

public class ProvidedPOSTaggerAnnotator { 

    public String tagSeparator; 

    public ProvidedPOSTaggerAnnotator(String annotatorName, Properties props) { 
    tagSeparator = props.getProperty(annotatorName + ".tagSeparator", "_"); 
    } 

    public void annotate(Annotation annotation) { 

    for (CoreLabel token : annotation.get(CoreAnnotations.TokensAnnotation.class)) { 
     int tagSeparatorSplitLength = token.word().split(tagSeparator).length; 
     String posTag = token.word().split(tagSeparator)[tagSeparatorSplitLength-1]; 
     String[] wordParts = Arrays.copyOfRange(token.word().split(tagSeparator), 0, tagSeparatorSplitLength-1); 
     String tokenString = String.join(tagSeparator, wordParts); 
     // set the word with the POS tag removed 
     token.set(CoreAnnotations.TextAnnotation.class, tokenString); 
     // set the POS 
     token.set(CoreAnnotations.PartOfSpeechAnnotation.class, posTag); 
    } 
    } 
} 

이 작동합니다 : 여기

은 몇 가지 예제 코드입니다. forcedpos.tagSeparator 속성을 사용하여 변경할 수 있습니다.

당신은 customAnnotator.forcedpos = edu.stanford.nlp.pipeline.ProvidedPOSTaggerAnnotator 등록 정보 파일에

은 "후 주석 자의 목록에"forcedpos "를 포함 다음 CLASSPATH 위의 클래스를 포함하고 설정하는 경우 토큰 화 "하면 자신의 pos 태그를 전달할 수 있어야합니다.

필자는 이것을 좀 더 정리하고 실제로 향후 릴리스에 포함시킬 수 있습니다!

실제로이 코드를 테스트 할 시간이 없었습니다. 시도해보고 오류를 발견하면 알려 주시면 고칠 것입니다.

관련 문제