How to do it...

The necessary steps include the following:

  1. Add the following imports to your project:
import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.InputStream;import java.nio.charset.StandardCharsets;import java.util.ArrayList;import opennlp.tools.doccat.DoccatModel;import opennlp.tools.doccat.DocumentCategorizerME;import opennlp.tools.doccat.DocumentSample;import opennlp.tools.doccat.DocumentSampleStream;import opennlp.tools.util.ObjectStream;import opennlp.tools.util.PlainTextByLineStream;
  1. In the main method, add the following declaration and ...

Get Natural Language Processing with Java Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.