Java Code Examples for org.openrdf.rio.RDFFormat#TURTLE
The following examples show how to use
org.openrdf.rio.RDFFormat#TURTLE .
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: IntegrationTestSupertypeLayer.java From cumulusrdf with Apache License 2.0 | 6 votes |
/** * Loads all triples found in the datafile associated with the given name. * * @param datafileName the name of the datafile. * @param graphs an optional set of target graph URIs. * @throws Exception hopefully never, otherwise the test fails. */ protected void load(final MisteryGuest data) throws Exception { if (data.datasets == null || data.datasets.length == 0) { return; } for (final String datafileName : data.datasets) { final RDFFormat format = datafileName.endsWith(".ttl") ? RDFFormat.TURTLE : RDFFormat.RDFXML; if (data.graphURI != null) { localConnection.add(source(datafileName), DUMMY_BASE_URI, format, localConnection.getValueFactory().createURI(data.graphURI)); cumulusConnection.add(source(datafileName), DUMMY_BASE_URI, format, cumulusConnection.getValueFactory().createURI(data.graphURI)); } else { localConnection.add(source(datafileName), DUMMY_BASE_URI, format); cumulusConnection.add(source(datafileName), DUMMY_BASE_URI, format); } } }
Example 2
Source File: TripleStoreBlazegraph.java From powsybl-core with Mozilla Public License 2.0 | 5 votes |
private static RDFFormat guessFormatFromName(String name) { if (name.endsWith(".ttl")) { return RDFFormat.TURTLE; } else if (name.endsWith(".xml")) { return RDFFormat.RDFXML; } return RDFFormat.RDFXML; }
Example 3
Source File: AbstractSailResource.java From neo4j-sparql-extension with GNU General Public License v3.0 | 5 votes |
/** * Returns an instance of {@link org.openrdf.rio.RDFFormat} for a * given MIME-Type string. * * @param mimetype the MIME-Type as string * @return the corresponding RDF-Format */ protected RDFFormat getRDFFormat(String mimetype) { switch (mimetype) { default: case RDFMediaType.RDF_TURTLE: return RDFFormat.TURTLE; case RDFMediaType.RDF_XML: return RDFFormat.RDFXML; case RDFMediaType.RDF_NTRIPLES: return RDFFormat.NTRIPLES; case RDFMediaType.RDF_JSON: return RDFFormat.RDFJSON; } }
Example 4
Source File: SubsetDataSet.java From mustard with MIT License | 5 votes |
public SubsetDataSet(String dir) { tripleStore = new RDFFileDataSet(dir + "/subset.ttl", RDFFormat.TURTLE); instances = new ArrayList<Resource>(); target = new ArrayList<Double>(); try { BufferedReader instReader = new BufferedReader(new FileReader(dir + "/instances.txt")); String line = instReader.readLine(); while (line != null) { instances.add(tripleStore.createURI(line)); line = instReader.readLine(); } instReader.close(); BufferedReader targetReader = new BufferedReader(new FileReader(dir + "/target.txt")); line = targetReader.readLine(); while (line != null) { target.add(Double.parseDouble(line)); line = targetReader.readLine(); } targetReader.close(); } catch (Exception e) { throw new RuntimeException(e); } }
Example 5
Source File: TurtlePrettyPrinter.java From ldp4j with Apache License 2.0 | 4 votes |
@Override public RDFFormat getRDFFormat() { return RDFFormat.TURTLE; }
Example 6
Source File: FeatureCountAMExperiment.java From mustard with MIT License | 2 votes |
/** * @param args */ public static void main(String[] args) { dataset = new RDFFileDataSet(AM_FOLDER, RDFFormat.TURTLE); long[] seedsDataset = {11,21,31,41,51}; //,61,71,81,91,101}; int[] subsetSize = {100, 200, 400, 800}; for (int ss : subsetSize) { double avgInstances = 0; double avgNumFeatures = 0; double avgNonZeroFeatures = 0; for (long sDS : seedsDataset) { createAMDataSet(dataset, sDS, ss, 10); RDFData data = new RDFData(dataset, instances, blackList); RDFWLSubTreeKernel kernel = new RDFWLSubTreeKernel(4, 2, false, true, false, true); SparseVector[] fv = kernel.computeFeatureVectors(data); avgInstances += fv.length; avgNumFeatures += fv[0].getLastIndex()+1; double avg = 0; for (SparseVector v : fv) { avg += v.size(); } avgNonZeroFeatures += (avg / (fv.length)); } avgInstances /= (seedsDataset.length); avgNumFeatures /= (seedsDataset.length); avgNonZeroFeatures /= (seedsDataset.length); System.out.println("# instances: " + avgInstances + ", # features: " + avgNumFeatures + ", # non-zero features: " + avgNonZeroFeatures); } }