Examples of TripleHandler


Examples of org.apache.any23.writer.TripleHandler

    @Test
    public void testTypedLiteralIncompatibleValueSupport()
    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

Examples of org.apache.any23.writer.TripleHandler

        final Extractor extractor = mock(Extractor.class);
        final ExtractorDescription ed = mock(ExtractorDescription.class);
        when(ed.getExtractorName()).thenReturn(FAKE_EXTRACTOR_NAME);
        when(extractor.getDescription()).thenReturn(ed);

        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);
View Full Code Here

Examples of org.apache.any23.writer.TripleHandler

    }

    private void checkTriple(String predicate, VerificationMode verificationMode)
    throws TripleHandlerException {
        final String DOCUMENT_URI = "http://an.html.page";
        final TripleHandler mockTripleHandler = mock(TripleHandler.class);
        final ValueFactory valueFactory = new ValueFactoryImpl();
        ExtractionContext extractionContext = new ExtractionContext(
                "test-extractor",
                valueFactory.createURI(DOCUMENT_URI)
        );
View Full Code Here

Examples of org.apache.any23.writer.TripleHandler

                                     "foo:bar foo: : .                          " +
                                     ":bar : foo:bar .                           ";
        //    The second argument of StringDocumentSource() must be a valid URI.
        /*3*/ DocumentSource source = new StringDocumentSource(content, "http://host.com/service");
        /*4*/ ByteArrayOutputStream out = new ByteArrayOutputStream();
        /*5*/ TripleHandler handler = new NTriplesWriter(out);
              try {
        /*6*/     runner.extract(source, handler);
              } finally {
        /*7*/     handler.close();
              }
        /*8*/ String nt = out.toString("UTF-8");

        /*
            <http://example.org/ns#bar> <http://example.org/ns#> <http://other.example.org/ns#> .
View Full Code Here

Examples of org.apache.any23.writer.TripleHandler

        /*4*/ DocumentSource source = new HTTPDocumentSource(
                 httpClient,
                 "http://dbpedia.org/resource/Trento"
              );
        /*5*/ ByteArrayOutputStream out = new ByteArrayOutputStream();
        /*6*/ TripleHandler handler = new NTriplesWriter(out);
              try {
        /*7*/     runner.extract(source, handler);
              } finally {
        /*8*/     handler.close();
              }
        /*9*/ String n3 = out.toString("UTF-8");

        /*
            <http://dbpedia.org/resource/Trent> <http://dbpedia.org/ontology/wikiPageDisambiguates> <http://dbpedia.org/resource/Trento> .
View Full Code Here

Examples of org.apache.any23.writer.TripleHandler

            protected int getSoTimeout() {
                return 2000;
            }
        });
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        TripleHandler handler = new RDFXMLWriter(byteArrayOutputStream);
        TripleHandler rdfWriter = new IgnoreAccidentalRDFa(handler);
        ReportingTripleHandler reporting = new ReportingTripleHandler(rdfWriter);

        DocumentSource source = new FileDocumentSource(
                new File("src/test/resources/html/rdfa/ansa_2010-02-26_12645863.html"),
                    "http://host.com/service");
View Full Code Here

Examples of org.apache.any23.writer.TripleHandler

        DocumentSource source = new HTTPDocumentSource(
                httpClient,
                "http://products.semweb.bestbuy.com/y/products/7590289/"
        );
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TripleHandler handler = new NTriplesWriter(out);
        runner.extract(source, handler);
        String n3 = out.toString("UTF-8");

        logger.debug("N3 " + n3);
        Assert.assertTrue(n3.length() > 0);
View Full Code Here

Examples of org.apache.any23.writer.TripleHandler

    public void testAbstractMethodErrorIssue186_1() throws IOException, ExtractionException{
        final Any23 runner = new Any23();
        final String content = FileUtils.readResourceContent("/html/rdfa/rdfa-issue186-1.xhtml");
        final DocumentSource source = new StringDocumentSource(content, "http://base.com");
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final TripleHandler handler = new NTriplesWriter(out);
        runner.extract(source, handler);
        String n3 = out.toString("UTF-8");
        logger.debug(n3);
    }
View Full Code Here

Examples of org.apache.any23.writer.TripleHandler

    public void testAbstractMethodErrorIssue186_2() throws IOException, ExtractionException{
        final Any23 runner = new Any23();
        final String content = FileUtils.readResourceContent("/html/rdfa/rdfa-issue186-2.xhtml");
        final DocumentSource source = new StringDocumentSource(content, "http://richard.cyganiak.de/");
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final TripleHandler handler = new NTriplesWriter(out);
        runner.extract(source, handler);
        final String n3 = out.toString("UTF-8");
        logger.debug(n3);
    }
View Full Code Here

Examples of org.apache.any23.writer.TripleHandler

        final Any23 any23 = new Any23(modifiableConf);

        final String content = FileUtils.readResourceContent("/rdf/rdf-issue183.ttl");
        final DocumentSource source = new StringDocumentSource(content, "http://base.com");
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final TripleHandler handler = new NTriplesWriter(out);
        any23.extract(source, handler);
        handler.close();
        final String n3 = out.toString("UTF-8");

        logger.debug(n3);
        Assert.assertFalse(
                "Should not contain triple with http://vocab.sindice.net/date",
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.