Java Code Examples for org.eclipse.rdf4j.rio.RDFFormat#NTRIPLES
The following examples show how to use
org.eclipse.rdf4j.rio.RDFFormat#NTRIPLES .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RdfSerializationExample.java From Wikidata-Toolkit-Examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws IOException { // Define where log messages go ExampleHelpers.configureLogging(); // Print information about this program printDocumentation(); // Initialize sites; only needed to link to Wikipedia pages in RDF DumpProcessingController dumpProcessingController = new DumpProcessingController( "wikidatawiki"); dumpProcessingController.setOfflineMode(ExampleHelpers.OFFLINE_MODE); Sites sites = dumpProcessingController.getSitesInformation(); // Prepare a compressed output stream to write the data to // (admittedly, this is slightly over-optimized for an example) OutputStream bufferedFileOutputStream = new BufferedOutputStream( ExampleHelpers .openExampleFileOuputStream("wikidata-simple-statements.nt.gz"), 1024 * 1024 * 5); GzipParameters gzipParameters = new GzipParameters(); gzipParameters.setCompressionLevel(7); OutputStream compressorOutputStream = new GzipCompressorOutputStream( bufferedFileOutputStream, gzipParameters); OutputStream exportOutputStream = asynchronousOutputStream(compressorOutputStream); // Create a serializer processor RdfSerializer serializer = new RdfSerializer(RDFFormat.NTRIPLES, exportOutputStream, sites, PropertyRegister.getWikidataPropertyRegister()); // Serialize simple statements (and nothing else) for all items serializer.setTasks(RdfSerializer.TASK_ITEMS | RdfSerializer.TASK_SIMPLE_STATEMENTS); // Run serialization serializer.open(); ExampleHelpers.processEntitiesFromWikidataDump(serializer); serializer.close(); }
Example 2
Source File: NTriplesParserFactory.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Returns {@link RDFFormat#NTRIPLES}. */ @Override public RDFFormat getRDFFormat() { return RDFFormat.NTRIPLES; }
Example 3
Source File: NTriplesWriterFactory.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Returns {@link RDFFormat#NTRIPLES}. */ @Override public RDFFormat getRDFFormat() { return RDFFormat.NTRIPLES; }
Example 4
Source File: NTriplesWriter.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public RDFFormat getRDFFormat() { return RDFFormat.NTRIPLES; }
Example 5
Source File: NTriplesParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public RDFFormat getRDFFormat() { return RDFFormat.NTRIPLES; }
Example 6
Source File: RdfSerializationExample.java From Wikidata-Toolkit with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws IOException { // Define where log messages go ExampleHelpers.configureLogging(); // Print information about this program printDocumentation(); // Initialize sites; only needed to link to Wikipedia pages in RDF DumpProcessingController dumpProcessingController = new DumpProcessingController( "wikidatawiki"); dumpProcessingController.setOfflineMode(ExampleHelpers.OFFLINE_MODE); Sites sites = dumpProcessingController.getSitesInformation(); // Prepare a compressed output stream to write the data to // (admittedly, this is slightly over-optimized for an example) try(OutputStream bufferedFileOutputStream = new BufferedOutputStream( ExampleHelpers.openExampleFileOuputStream("wikidata-simple-statements.nt.gz"), 1024 * 1024 * 5 )) { GzipParameters gzipParameters = new GzipParameters(); gzipParameters.setCompressionLevel(7); OutputStream compressorOutputStream = new GzipCompressorOutputStream( bufferedFileOutputStream, gzipParameters); OutputStream exportOutputStream = asynchronousOutputStream(compressorOutputStream); // Create a serializer processor RdfSerializer serializer = new RdfSerializer(RDFFormat.NTRIPLES, exportOutputStream, sites, PropertyRegister.getWikidataPropertyRegister()); // Serialize simple statements (and nothing else) for all items serializer.setTasks(RdfSerializer.TASK_ITEMS | RdfSerializer.TASK_SIMPLE_STATEMENTS); // Run serialization serializer.open(); ExampleHelpers.processEntitiesFromWikidataDump(serializer); serializer.close(); } }