@Override
    public void parse(InputStream stream, ContentHandler handler, Metadata metadata,
                      ParseContext context) throws IOException, SAXException, TikaException {
        if (classifier == null) {
            LOG.warn(getClass().getSimpleName() + " is not configured properly.");
            return;
        }
        String inputString = IOUtils.toString(stream, "UTF-8");
        String sentiment = classifier.predict(inputString);
        metadata.add("Sentiment", sentiment);
    }
@Test
    public void testCategorical() throws Exception {
        Tika tika = getTika("tika-config-sentiment-opennlp-cat.xml");
        if (tika == null) {
            return;
        }
        String text = "Whatever, I need some cooling off time!";
        ByteArrayInputStream stream =
                new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8));
        Metadata md = new Metadata();
        tika.parse(stream, md);
        String sentiment = md.get("Sentiment");
        assertNotNull(sentiment);
        assertEquals("angry", sentiment);
    }