2017-10-18 132 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); 

     } 
} 

回答