use of org.apache.clerezza.rdf.jena.parser.JenaParserProvider in project stanbol by apache.
the class ClerezzaBackendTest method readTestData.
@BeforeClass
public static void readTestData() throws IOException {
ParsingProvider parser = new JenaParserProvider();
//NOTE(rw): the new third parameter is the base URI used to resolve relative paths
graph = new IndexedGraph();
InputStream in = ClerezzaBackendTest.class.getClassLoader().getResourceAsStream("testdata.rdf.zip");
assertNotNull(in);
ZipInputStream zipIn = new ZipInputStream(new BufferedInputStream(in));
InputStream uncloseable = new UncloseableStream(zipIn);
ZipEntry entry;
while ((entry = zipIn.getNextEntry()) != null) {
if (entry.getName().endsWith(".rdf")) {
parser.parse(graph, uncloseable, SupportedFormat.RDF_XML, null);
}
}
assertTrue(graph.size() > 0);
zipIn.close();
}
use of org.apache.clerezza.rdf.jena.parser.JenaParserProvider in project stanbol by apache.
the class ZemantaAPIWrapper method parseResponse.
private ImmutableGraph parseResponse(InputStream is) {
JenaParserProvider jenaParserProvider = new JenaParserProvider();
//NOTE(rw): the new third parameter is the base URI used to resolve relative paths
Graph g = new SimpleGraph();
jenaParserProvider.parse(g, is, SupportedFormat.RDF_XML, null);
log.debug("graph: " + g.toString());
return g.getImmutableGraph();
}
use of org.apache.clerezza.rdf.jena.parser.JenaParserProvider in project stanbol by apache.
the class TopicEngineTest method testImportModelFromSKOS.
@Test
public void testImportModelFromSKOS() throws Exception {
log.info(" --- testImportModelFromSKOS --- ");
Parser parser = Parser.getInstance();
parser.bindParsingProvider(new JenaParserProvider());
ImmutableGraph graph = parser.parse(getClass().getResourceAsStream("/sample-scheme.skos.rdf.xml"), SupportedFormat.RDF_XML);
int imported = classifier.importConceptsFromGraph(graph, OntologicalClasses.SKOS_CONCEPT, Properties.SKOS_BROADER);
assertEquals(imported, 4);
assertEquals(0, classifier.getBroaderConcepts("http://example.com/ns#someconceptscheme/100").size());
assertEquals(0, classifier.getBroaderConcepts("http://example.com/ns#someconceptscheme/200").size());
assertEquals(1, classifier.getBroaderConcepts("http://example.com/ns#someconceptscheme/010").size());
assertEquals(1, classifier.getBroaderConcepts("http://example.com/ns#someconceptscheme/020").size());
assertEquals(2, classifier.getRootConcepts().size());
}
use of org.apache.clerezza.rdf.jena.parser.JenaParserProvider in project stanbol by apache.
the class OWLAPIToClerezzaConverter method owlOntologyToClerezzaGraph.
/**
*
* Converts a OWL API {@link OWLOntology} to Clerezza {@link Graph}.
*
* @param ontology
* {@link OWLOntology}
* @return the equivalent Clerezza {@link Graph}.
*/
public static org.apache.clerezza.commons.rdf.Graph owlOntologyToClerezzaGraph(OWLOntology ontology) {
org.apache.clerezza.commons.rdf.Graph mGraph = null;
ByteArrayOutputStream out = new ByteArrayOutputStream();
OWLOntologyManager manager = ontology.getOWLOntologyManager();
try {
manager.saveOntology(ontology, new RDFXMLOntologyFormat(), out);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
ParsingProvider parser = new JenaParserProvider();
mGraph = new SimpleGraph();
parser.parse(mGraph, in, SupportedFormat.RDF_XML, null);
} catch (OWLOntologyStorageException e) {
log.error("Failed to serialize OWL Ontology " + ontology + "for conversion", e);
}
return mGraph;
}
use of org.apache.clerezza.rdf.jena.parser.JenaParserProvider in project stanbol by apache.
the class JenaToClerezzaConverter method jenaModelToClerezzaGraph.
/**
*
* Converts a Jena {@link Model} to Clerezza {@link Graph}.
*
* @param model {@link Model}
* @return the equivalent Clerezza {@link Graph}.
*/
public static org.apache.clerezza.commons.rdf.Graph jenaModelToClerezzaGraph(Model model) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
model.write(out);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
ParsingProvider parser = new JenaParserProvider();
org.apache.clerezza.commons.rdf.Graph mGraph = new SimpleGraph();
parser.parse(mGraph, in, SupportedFormat.RDF_XML, null);
return mGraph;
}
Aggregations