TensorflowImageRecParser extends ExternalParser implements ObjectRecogniser { @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; }  Set<MediaType> getSupportedMimes(); @Override boolean isAvailable(); @Override void initialize(Map<String, Param> params); @Override void checkInitialization(InitializableProblemHandler handler); @Override List<RecognisedObject> recognise(InputStream stream, ContentHandler handler,
                                            Metadata metadata, ParseContext context);  }
@Test public void recognise() throws Exception { TensorflowImageRecParser recogniser = new TensorflowImageRecParser(); recogniser.initialize(new HashMap<String, Param>()); try (InputStream stream = getClass().getClassLoader().getResourceAsStream("test-documents/testJPEG.jpg")) { List<RecognisedObject> objects = recogniser.recognise(stream, new DefaultHandler(), new Metadata(), new ParseContext()); Assert.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) { Assert.assertTrue(label + " is expected", objectLabels.contains(label)); } } }