2017-05-12 8 views
0

나는 Mannings 교수의 코드 샘플을 here에서 수정하여 파일, 토큰 화, 품사 - 태그를 읽고이를 lemmatize했습니다.스탠포드 CoreNLP 토크 나이저의 옵션 설정

이제 문자를 사용할 수없는 문자가 나왔습니다. "untokenizable"옵션을 사용하고 "noneKeep"으로 설정하려고합니다.

StackOverflow에 대한 다른 질문은 직접 토크 나이저를 인스턴스화해야한다고 설명합니다. 그러나 다음 작업 (POS 태깅 등)이 필요에 따라 계속 수행되도록하기 위해 그렇게하는 방법을 모르겠습니다. 누구든지 올바른 방향으로 나를 가리킬 수 있습니까?

// expects two command line parameters: one file to be read, one to write to 

import java.io.*; 
import java.util.*; 

import edu.stanford.nlp.io.*; 
import edu.stanford.nlp.ling.*; 
import edu.stanford.nlp.pipeline.*; 
import edu.stanford.nlp.trees.*; 
import edu.stanford.nlp.util.*; 

public class StanfordCoreNlpDemo { 

    public static void main(String[] args) throws IOException { 
    PrintWriter out; 
    out = new PrintWriter(args[1]); 

    Properties props = new Properties(); 
    props.setProperty("annotators", "tokenize, ssplit, pos, lemma"); 
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props); 
    Annotation annotation; 
    annotation = new Annotation(IOUtils.slurpFileNoExceptions(args[0])); 

    pipeline.annotate(annotation); 
    pipeline.prettyPrint(annotation, out); 
    } 
} 

답변

1

코드에 이것을 추가 untokenizable에 대한

props.setProperty("tokenize.options", "untokenizable=allKeep");

6 옵션은 다음과 같습니다 거의 실망 쉬웠다

noneDelete, firstDelete, allDelete, noneKeep, firstKeep, allKeep

+0

. 고마워요! – user1769925

관련 문제