@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 endToEndTest() throws Exception {

        Tika tika = getTika("tika-config-sentiment-opennlp.xml");
        if (tika == null) {
            return;
        }

        String text = "What a wonderful thought it is that" +
                " some of the best days of our lives haven't happened yet.";
        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("positive", sentiment);

    }