Package org.apache.any23.extractor

Examples of org.apache.any23.extractor.ExtractionResultImpl


    throws IOException, ExtractionException, TripleHandlerException {
        final URI uri = RDFUtils.uri("http://host.com/test-malformed-literal.turtle");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final TripleHandler th = new RDFXMLWriter(baos);
        final ExtractionContext extractionContext = new ExtractionContext("turtle-extractor", uri);
        final ExtractionResult result = new ExtractionResultImpl(extractionContext, extractor, th);
        extractor.setStopAtFirstError(false);
        try {
            extractor.run(
                    ExtractionParameters.newDefault(),
                    extractionContext,
                    this.getClass().getResourceAsStream("/org/apache/any23/extractor/rdf/testMalformedLiteral"),
                    result
            );
        } finally {
            logger.debug(baos.toString());
            th.close();
            result.close();
        }
    }
View Full Code Here


        final TripleHandler th = mock(TripleHandler.class);
        final ExtractionContext extractionContext = new ExtractionContext(
                extractor.getDescription().getExtractorName(),
                new URIImpl("http://fake.document.uri")
        );
        final ExtractionResult er = new ExtractionResultImpl(extractionContext, extractor, th);
        er.notifyIssue(IssueReport.IssueLevel.Fatal  , "Fake fatal error.", 1, 2);
        er.notifyIssue(IssueReport.IssueLevel.Error  , "Fake error."      , 3, 4);
        er.notifyIssue(IssueReport.IssueLevel.Warning, "Fake warning."    , 5, 6);

        ExtractionException ee = new ExtractionException("Fake message.", new RuntimeException("Fake cause"), er);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ee.printStackTrace(new PrintWriter(baos));
        final String bufferContent = baos.toString();
View Full Code Here

        compositeTripleHandler.addChild(verifierTripleHandler);
        final CountingTripleHandler countingTripleHandler = new CountingTripleHandler();
        compositeTripleHandler.addChild(countingTripleHandler);
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        compositeTripleHandler.addChild( new NTriplesWriter(out) );
        final ExtractionResult extractionResult = new ExtractionResultImpl(
                extractionContext, extractor, compositeTripleHandler
        );
        extractor.run(extractionParameters, extractionContext, is, extractionResult);
        compositeTripleHandler.close();
        logger.info(out.toString());
View Full Code Here

  public void extract(URI uri, String filePath)
    throws IOException, ExtractionException, TripleHandlerException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final TripleHandler tHandler = new RDFXMLWriter(baos);
    final ExtractionContext extractionContext = new ExtractionContext("rdf-jsonld", uri);
    final ExtractionResult result = new ExtractionResultImpl(extractionContext, extractor, tHandler);
    extractor.setStopAtFirstError(false);
    try {
      extractor.run(
              ExtractionParameters.newDefault(),
              extractionContext,
              this.getClass().getResourceAsStream(filePath),
              result
      );
    } finally {
      logger.debug(baos.toString());
      tHandler.close();
      result.close();
    }
  }
View Full Code Here

     * @throws InstantiationException
     * @throws IllegalAccessException
     */
    @Test
    public void testDetectExtractorPlugins() throws IOException, InstantiationException, IllegalAccessException {
        final ExtractorGroup extractorGroup = manager.getApplicableExtractors(
                new ExtractorRegistryImpl(),
                HTML_SCRAPER_TARGET_DIR,  // Required to satisfy class dependencies.
                HTML_SCRAPER_DEPENDENCY_DIR,
                OFFICE_SCRAPER_TARGET_DIR
, OFFICE_SCRAPER_DEPENDENCY_DIR // Required to satisfy class dependencies.
        );
        assertEquals("Did not find the number of expected extractors", NUM_OF_EXTRACTORS ,        // HTMLScraper Plugin, OfficeScraper Plugin.
                extractorGroup.getNumOfExtractors()
        );
    }
View Full Code Here

            //for (ExtractorFactory<?> extractorFactory : initialExtractorGroup) {
            //    newFactoryList.add(extractorFactory);
            //}

            return new ExtractorGroup(newFactoryList);
        } finally {
            logger.info(report.toString());
        }
    }
View Full Code Here

     * @throws IllegalAccessException
     */
    @Test
    public void testDetectExtractorPlugins() throws IOException, InstantiationException, IllegalAccessException {
        final ExtractorGroup extractorGroup = manager.getApplicableExtractors(
                new ExtractorRegistryImpl(),
                HTML_SCRAPER_TARGET_DIR,  // Required to satisfy class dependencies.
                HTML_SCRAPER_DEPENDENCY_DIR,
                OFFICE_SCRAPER_TARGET_DIR
, OFFICE_SCRAPER_DEPENDENCY_DIR // Required to satisfy class dependencies.
        );
View Full Code Here

     * @throws IOException
     */
    // TODO: MimeType detector to null forces the execution of all extractors, but extraction
    //       tests should be based on mimetype detection.
    protected void extract(String resource) throws ExtractionException, IOException {
        SingleDocumentExtraction ex = new SingleDocumentExtraction(
            new HTMLFixture(copyResourceToTempFile(resource)).getOpener(baseURI.toString()),
            getExtractorFactory(), new RepositoryWriter(conn)
        );
        ex.setMIMETypeDetector(null);
        report = ex.run();
    }
View Full Code Here

        final ModifiableConfiguration configuration = DefaultConfiguration.copy();
        configuration.setProperty("any23.extraction.metadata.domain.per.entity", "on");
        SingleDocumentExtraction instance =  new SingleDocumentExtraction(
                configuration,
                new HTMLFixture(copyResourceToTempFile(file)).getOpener("http://nested.test.com"),
                extractorGroup,
                cth
        );
        instance.setMIMETypeDetector( new TikaMIMETypeDetector(new WhiteSpacesPurifier()) );
        return instance;
View Full Code Here

    private Extractor extractor;
    private TripleHandler mockTripleHandler;

    @Before
    public void setUp() {
        extractor = new TitleExtractor();
        mockTripleHandler = Mockito.mock(TripleHandler.class);
        extractionResult  = new ExtractionResultImpl(
                new ExtractionContext("test-extractor-name", TEST_URI),
                extractor,
                mockTripleHandler
View Full Code Here

TOP

Related Classes of org.apache.any23.extractor.ExtractionResultImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.