Reputation: 250
Im trying to build a categorizer in version 1.8 of openNLP but with the code below I keep getting a NullPointerException
. What am I doing wrong?
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);
}
}
Upvotes: 1
Views: 261
Reputation: 339
You should have a look at following tutorial. They are useing OpenNLP
version 1.7.2. This may be a more recent example to work with.
Hope it helps.
Upvotes: 1