2016-11-15 1 views

답변

1

지금까지 해보신 것은 무엇입니까? 링크 된 예제를 자세히 보지 않았지만,이 예제를 수정하여 원하는 위치로 이동할 수 있다고 확신합니다. 어떤 경우 , 그것은 매우 어려운 일이 아니다 : http://opennlp.sourceforge.net/models-1.5/

을 그리고 나는 SimpleTokenizer이되지 않는 것을 말해야한다 :

InputStream modelIn = null; 
POSModel POSModel = null; 
try{ 
    File f = new File("<location to your tagger model here>"); 
    modelIn = new FileInputStream(f); 
    POSModel = new POSModel(modelIn); 
    POSTaggerME tagger = new POSTaggerME(POSModel); 
    SimpleTokenizer tokenizer= new SimpleTokenizer(); 
    String tokens[] = tokenizer.tokenize("This is a sample sentence."); 
    String[] tagged = tagger.tag(tokens); 
    for (int i = 0; i < tagged.length; i++){ 
     if (tagged[i].equalsIgnoreCase("nn")){ 
      System.out.println(tokens[i]); 
     } 
    } 

} 
catch(IOException e){ 
    throw new BadRequestException(e.getMessage()); 
} 

는 여기에서 술래 모델을 다운로드 할 수 있습니다. 좀 더 정교한 것으로 보길 원할 수도 있지만, 제 경험상 OpenNLP의 더 멋진 것들은 훨씬 더 느립니다 (그리고 토큰 화를 위해서 일반적으로 받아 들일 수 없을 정도로 느립니다).

관련 문제