@Override
    public List<RecognisedObject> recognise(InputStream stream, ContentHandler handler,
                                            Metadata metadata, ParseContext context)
            throws IOException, SAXException, TikaException {
        Metadata md = new Metadata();
        parse(stream, handler, md, context);
        List<RecognisedObject> objects = new ArrayList<>();
        for (String key : md.names()) {
            double confidence = Double.parseDouble(md.get(key));
            objects.add(new RecognisedObject(key, "eng", key, confidence));
        }
        return objects;
    }
@Test
    public void recognise() throws Exception {
        TensorflowImageRecParser recogniser = new TensorflowImageRecParser();
        recogniser.initialize(new HashMap<>());
        try (InputStream stream = getClass().getClassLoader()
                .getResourceAsStream("test-documents/testJPEG.jpg")) {
            List<RecognisedObject> objects = recogniser
                    .recognise(stream, new DefaultHandler(), new Metadata(), new ParseContext());
            assertTrue(5 == objects.size());
            Set<String> objectLabels = new HashSet<>();
            for (RecognisedObject object : objects) {
                objectLabels.add(object.getLabel());
            }
            System.out.println(objectLabels);
            String[] expected = {"Egyptian cat", "tabby, tabby cat"};
            for (String label : expected) {
                assertTrue(objectLabels.contains(label), label + " is expected");
            }
        }
    }