2017-10-18 127 views
1

我试图在openNLP 1.8版中构建分类程序,但代码如下,我不断收到NullPointerException。我究竟做错了什么?OpenNLP分类程序版本1.8

public class test 
{ 

     public static void main(String[] args) throws IOException 
     { 
      InputStream is = new FileInputStream("D:/training.txt"); 
      DoccatModel m = new DoccatModel(is); 
      Tokenizer tokenizer = WhitespaceTokenizer.INSTANCE; 
      String tweet = "testing sentence"; 
      String[] tokens = tokenizer.tokenize(tweet); 
      DocumentCategorizerME myCategorizer = new DocumentCategorizerME(m); 
      double[] outcomes = myCategorizer.categorize(tokens); 
      String category = myCategorizer.getBestCategory(outcomes); 

     } 
} 

回答