@Test public void testAgeRecogniser() throws Exception { try (InputStream is = getClass().getResourceAsStream(CONFIG_FILE); InputStream bis = new ByteArrayInputStream(TEST_TEXT.getBytes(Charset.defaultCharset())); ) { TikaConfig config = new TikaConfig(is); Tika tika = new Tika(config); Metadata md = new Metadata(); tika.parse(bis, md); Assert.assertArrayEquals("Age Parser not invoked.", new String[] {CompositeParser.class.getCanonicalName(), AgeRecogniser.class.getCanonicalName()}, md.getValues("X-Parsed-By")); Assert.assertArrayEquals("Wrong age predicted.", new String[] {Double.toString(TEST_AGE)}, md.getValues(AgeRecogniser.MD_KEY_ESTIMATED_AGE)); } }
public AgeRecogniser() { try { secondaryParser = new Tika(new TikaConfig()); available = true; } catch (Exception e) { available = false; LOG.error("Unable to initialize secondary parser", e); } }
AgeRecogniser extends AbstractParser implements Initializable { public AgeRecogniser() { try { secondaryParser = new Tika(new TikaConfig()); available = true; } catch (Exception e) { available = false; LOG.error("Unable to initialize secondary parser", e); } } }
AgeRecogniser extends AbstractParser implements Initializable { public AgeRecogniser() { try { secondaryParser = new Tika(new TikaConfig()); available = true; } catch (Exception e) { available = false; LOG.error("Unable to initialize secondary parser", e); } } AgeRecogniser(); }
AgeRecogniser extends AbstractParser implements Initializable { public AgeRecogniser() { try { secondaryParser = new Tika(new TikaConfig()); available = true; } catch (Exception e) { available = false; LOG.error("Unable to initialize secondary parser", e); } } AgeRecogniser(); @Override void checkInitialization(InitializableProblemHandler problemHandler); @Override Set<MediaType> getSupportedTypes(ParseContext parseContext); @Override void initialize(Map<String, Param> params); AgePredicterLocal getAgePredictorClient(); @Override void parse(InputStream inputStream, ContentHandler handler, Metadata metadata, ParseContext context); }
AgeRecogniser extends AbstractParser implements Initializable { public AgeRecogniser() { try { secondaryParser = new Tika(new TikaConfig()); available = true; } catch (Exception e) { available = false; LOG.error("Unable to initialize secondary parser", e); } } AgeRecogniser(); @Override void checkInitialization(InitializableProblemHandler problemHandler); @Override Set<MediaType> getSupportedTypes(ParseContext parseContext); @Override void initialize(Map<String, Param> params); AgePredicterLocal getAgePredictorClient(); @Override void parse(InputStream inputStream, ContentHandler handler, Metadata metadata, ParseContext context); static final String MD_KEY_ESTIMATED_AGE_RANGE; static final String MD_KEY_ESTIMATED_AGE; public Tika secondaryParser; }