Examples of NTriplesWriter


Examples of org.apache.any23.writer.NTriplesWriter

        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.NTriplesWriter

        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.NTriplesWriter

        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

Examples of org.apache.any23.writer.NTriplesWriter

    private ExtractionReport detectAndExtract(String in) throws Exception {
        Any23 any23 = new Any23();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ReportingTripleHandler outputHandler = new ReportingTripleHandler(
                new IgnoreAccidentalRDFa(new IgnoreTitlesOfEmptyDocuments(
                        new NTriplesWriter(out))));
        return any23.extract(in, "http://host.com/path", outputHandler);
    }
View Full Code Here

Examples of org.apache.any23.writer.NTriplesWriter

        Any23 runner = new Any23(parsers.length == 0 ? null : parsers);
        if (parsers.length != 0) {
            runner.setMIMETypeDetector(null); // Use all the provided
                                              // extractors.
        }
        final NTriplesWriter tripleHandler = new NTriplesWriter(out);
        runner.extract(new StringDocumentSource(content, PAGE_URL),
                tripleHandler);
        tripleHandler.close();
        String result = out.toString("us-ascii");
        Assert.assertNotNull(result);
        Assert.assertTrue(result.length() > 10);
    }
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesWriter

            if(willFollowAnother)
                ps.print("\n");
                ps.print(RDF_XML_SEPARATOR);
                ps.print("\n");
        } else if(format == VocabularyFormat.NTriples) {
            rdfWriter = new NTriplesWriter(ps);
        } else if(format == VocabularyFormat.NQuads) {
            rdfWriter = new NQuadsWriter(ps);
        }
        else {
            throw new IllegalArgumentException("Unsupported format " + format);
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesWriter

   */
  public static String extractRDF(LocalRepository repository, RDFFormat format) {
    StringWriter stringWriter = new StringWriter();
    RdfDocumentWriter rdfDocumentWriter;
    if (format == RDFFormat.NTRIPLES) {
      rdfDocumentWriter = new NTriplesWriter(stringWriter);
    } else if (format == RDFFormat.RDFXML) {
      rdfDocumentWriter = new RdfXmlWriter(stringWriter);
    } else {
      rdfDocumentWriter = new TurtleWriter(stringWriter);
    }
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesWriter

      // test export and handlers
      File f = new File("results.n3.txt");
      try {
        ok = true;
        log("Writing the statements to file: (" + f.getAbsolutePath() + ")");
        RDFHandler ntw = new NTriplesWriter(new FileOutputStream(f));
        con.exportStatements(kingsleyidehen, name, null, false, ntw);
      }
      catch (Exception e) {
        log("Error[" + e + "]");
        e.printStackTrace();
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesWriter

      // test export and handlers
      File f = new File("results.n3.txt");
      try {
        ok = true;
        log("Writing the statements to file: (" + f.getAbsolutePath() + ")");
        RDFHandler ntw = new NTriplesWriter(new FileOutputStream(f));
        con.exportStatements(kingsleyidehen, name, null, false, ntw);
      }
      catch (Exception e) {
        log("Error[" + e + "]");
        e.printStackTrace();
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesWriter

      Iterator<Statement> iter = mdGraph.iterator();
      Integer _stmtcnt = 0;
      String mdFile = String.format("%s.md.nt", inFile);

      FileOutputStream outStream = new FileOutputStream(mdFile);
      NTriplesWriter ntw = new NTriplesWriter (outStream);

      ntw.handleNamespace ("dc", dcNS);

      try {
    ntw.startRDF();
    while (iter.hasNext()) {
        Statement _stmt = iter.next();
        ntw.handleStatement(_stmt);
        _stmtcnt++;
    }
    ntw.endRDF();
    outStream.close();
      }
      catch (Exception e) {
    e.printStackTrace();
    System.exit (-1);
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.