本文整理汇总了Java中org.apache.jena.rdf.model.ModelFactory.createOntologyModel方法的典型用法代码示例。如果您正苦于以下问题:Java ModelFactory.createOntologyModel方法的具体用法?Java ModelFactory.createOntologyModel怎么用?Java ModelFactory.createOntologyModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.rdf.model.ModelFactory
的用法示例。
在下文中一共展示了ModelFactory.createOntologyModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
model = ModelFactory.createOntologyModel();
InputStream in = null;
try {
in = new FileInputStream(outputFileName);
model.read(in, "http://github.com/quadrama/metadata/ontology.owl");
in.close();
} catch (IOException e) {
Ontology o = model.createOntology("http://github.com/quadrama/metadata/ontology.owl");
o.setRDFType(OWL2.Ontology);
model.setNsPrefix("gndo", "http://d-nb.info/standards/elementset/gnd#");
model.setNsPrefix("gnd", "http://d-nb.info/gnd/");
model.setNsPrefix("dc", "http://purl.org/dc/elements/1.1/");
model.setNsPrefix("oa", "http://www.w3.org/ns/oa#");
model.setNsPrefix("dbo", "http://dbpedia.org/ontology/");
model.setNsPrefix("qd", QD.NS);
} finally {
IOUtils.closeQuietly(in);
}
}
示例2: map
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
@Override
public void map(List<DIF> pojoList, Properties props) {
// create the base model
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
ontModel.setNsPrefix("dif_v9.8.2", MUDROD_GCMD_DIF_9_8_2);
ontModel.setNsPrefix("geo", "http://www.opengis.net/ont/geosparql#");
ontModel.read(SWEET_REPR_DATA_PRODUCT, null, "TURTLE");
// get the https://sweetontology.net/reprDataProduct/Dataset class reference
Resource dataset = ontModel.getResource(SWEET_REPR_DATA_PRODUCT_NS + "Dataset");
// create the https://sweetontology.net/reprDataProduct/PODAACDataset class
// reference
OntClass podaacDataset = ontModel.createClass(PODAAC_DATASET + "PODAACDataset");
// make PODAACDataset a subclass of Dataset
podaacDataset.addSuperClass(dataset);
// create an individual for each DIF POJO
for (DIF dif : pojoList) {
Individual gcmdDif = podaacDataset.createIndividual(PODAAC_DATASET + dif.getEntryID());
buildIndividual(ontModel, dif, gcmdDif);
}
writeOntologyModel(ontModel, props);
}
示例3: loadOntologyFromClasspath
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
protected OntModel loadOntologyFromClasspath(String classPathUri, String uri) {
OntModel ontModel = ModelFactory.createOntologyModel();
// Load from classpath
InputStream inStream = getClass().getResourceAsStream(classPathUri);
if (inStream == null) {
throw new IllegalArgumentException("Can't load " + classPathUri);
}
// Ontology ontology = ontModel.createOntology(uri);
if (classPathUri.endsWith(".ttl")) {
ontModel.read(inStream, uri, "TURTLE");
} else {
ontModel.read(inStream, uri);
}
return ontModel;
}
示例4: fixOntModel
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
public OntModel fixOntModel(OntModel ontModel)
{
if (ontModel == null) throw new IllegalArgumentException("Model cannot be null");
OntModel fixedModel = ModelFactory.createOntologyModel(ontModel.getSpecification());
Query fix = QueryFactory.create("CONSTRUCT\n" +
"{\n" +
" ?s ?p ?o\n" +
"}\n" +
"WHERE\n" +
"{\n" +
" ?s ?p ?o\n" +
" FILTER (!(?p = <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?o = <https://www.w3.org/ns/ldt#Constraint>))\n" +
"}");
try (QueryExecution qex = QueryExecutionFactory.create(fix, ontModel))
{
fixedModel.add(qex.execConstruct());
}
return fixedModel;
}
示例5: workflowHistory
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
public void workflowHistory(Workflow mainWorkflow, OutputStream output) throws WriterException {
OntModel model = ModelFactory.createOntologyModel();
Revision revision = mainWorkflow.getCurrentRevision();
Revision previous = revision.getPreviousRevision();
addRevision(model, revision);
while (previous != null) {
addRevision(model, previous);
addPrevious(model, revision, previous);
revision = previous;
previous = revision.getPreviousRevision();
}
java.net.URI baseURI = Workflow.WORKFLOW_ROOT;
model.setNsPrefix("roevo", "http://purl.org/wf4ever/roevo#");
model.setNsPrefix("prov", "http://www.w3.org/ns/prov#");
model.setNsPrefix("rdfs",
"http://www.w3.org/2000/01/rdf-schema#");
model.write(output, "Turtle", baseURI.toASCIIString());
// throw new WriterException("Can't write to output", e);
}
示例6: workflowUUIDs
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
@Test
public void workflowUUIDs() throws Exception {
ByteArrayOutputStream os = new ByteArrayOutputStream();
roEvo.workflowHistory(helloWorld.getMainWorkflow(), os);
System.out.write(os.toByteArray());
assertTrue(500 < os.size());
String ttl = os.toString("UTF-8");
assertTrue(ttl.contains("01348671-5aaa-4cc2-84cc-477329b70b0d"));
assertTrue(ttl.contains("VersionableResource"));
assertTrue(ttl.contains("Entity"));
OntModel m = ModelFactory.createOntologyModel();
m.read(new ByteArrayInputStream(os.toByteArray()), "http://example.com/", "Turtle");
Resource mainWf = m.getResource(helloWorld.getMainWorkflow().getIdentifier().toASCIIString());
Resource older = mainWf.getProperty(Prov_o.wasRevisionOf).getResource();
Resource oldest = older.getProperty(Prov_o.wasRevisionOf).getResource();
assertNull(oldest.getProperty(Prov_o.wasRevisionOf));
}
示例7: LocalOntology
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
public LocalOntology() {
//only initialize all the static variables
//if first time called to this ontology constructor
if (ontology == null) {
if (LOG.isInfoEnabled()) {
LOG.info("Creating new ontology");
}
parser = new OwlParser();
ontology = this;
}
if (ontologyModel == null)
ontologyModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
load();
}
示例8: setFormat
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
/**
* Set the format for an input or output, handling ontologies
* @param inputOutput The input or output CWL Element
* @param format The format URI
*/
private void setFormat(CWLElement inputOutput, String format) {
inputOutput.setFormat(format);
try {
if (!rdfService.ontPropertyExists(format)) {
Model ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
ontModel.read(format, null, "RDF/XML");
rdfService.addToOntologies(ontModel);
}
String formatLabel = rdfService.getOntLabel(format);
inputOutput.setType(inputOutput.getType() + " [" + formatLabel + "]");
} catch (RiotException ex) {
inputOutput.setType(inputOutput.getType() + " [format]");
}
}
示例9: resolveImports
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
/** Resolve the closure of all owl:imports statements into a union model */
private OntModel resolveImports(final OntModel model) {
// if no imports, nothing to resolve
if (model.listObjectsOfProperty(model.getProperty(OWL_IMPORTS)).toSet().isEmpty()) {
return model;
}
final OntModel out = ModelFactory.createOntologyModel(defaultSpec, model.getBaseModel());
final Set<String> resolvedImports = new HashSet<>();
Set<String> unresolvedImports = imports(model, resolvedImports);
while (!unresolvedImports.isEmpty()) {
for (final String unresolved : unresolvedImports) {
model.add(load(unresolved));
resolvedImports.add(unresolved);
}
unresolvedImports = imports(model, resolvedImports);
}
// Since we manually resolved all imports, remove all owl:imports statements
out.removeAll(null, model.getProperty(OWL_IMPORTS), null);
return out;
}
示例10: merge
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
@Override
public Ont merge(final Ontology ontology1, final Ontology ontology2) {
final OntModel model = ModelFactory.createOntologyModel(defaultSpec);
model.add(ont(ontology1).getBaseModel());
model.add(ont(ontology2).getBaseModel());
return new Ont(model);
}
示例11: resourceChangedMoveBaseFileWithBase
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
@Test
public void resourceChangedMoveBaseFileWithBase() {
final TestBaseRegistryListener registeryListener = new TestBaseRegistryListener();
try {
SemanticUtils.getSemanticBaseRegistry().addListener(registeryListener);
final Model model = ModelFactory.createOntologyModel();
final JenaBase base = new JenaBase(model, "test");
final IProject project = createProject();
final IFile file = createBaseFile(project, base);
assertTrue(file != null);
assertEquals(1, registeryListener.getBases().size());
assertEquals("/test/test.ttl", registeryListener.getBases().get(0).getName());
file.move(new Path("/test/file.ttl"), true, new NullProgressMonitor());
assertEquals(1, registeryListener.getBases().size());
assertEquals("/test/test.ttl", registeryListener.getBases().get(0).getName());
project.delete(true, new NullProgressMonitor());
} catch (CoreException e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
SemanticUtils.getSemanticBaseRegistry().removeListener(registeryListener);
}
}
示例12: getDataModel
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
protected Model getDataModel(String[] args) throws IOException {
for(int i = 0; i < args.length - 1; i++) {
if(DATA_FILE.equals(args[i])) {
String dataFileName = args[i + 1];
OntModel dataModel = ModelFactory.createOntologyModel(spec);
File dataFile = new File(dataFileName);
dataModel.read(new FileInputStream(dataFile), "urn:x-base", FileUtils.langTurtle);
return dataModel;
}
}
System.err.println("Missing -datafile, e.g.: -datafile myfile.ttl");
System.exit(0);
return null;
}
示例13: getShapesModel
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
protected Model getShapesModel(String[] args) throws IOException {
for(int i = 0; i < args.length - 1; i++) {
if(SHAPES_FILE.equals(args[i])) {
String fileName = args[i + 1];
OntModel model = ModelFactory.createOntologyModel(spec);
File dataFile = new File(fileName);
model.read(new FileInputStream(dataFile), "urn:x-base", FileUtils.langTurtle);
return model;
}
}
return null;
}
示例14: loadDcTerms
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
protected synchronized void loadDcTerms() {
if (dcterms != null) {
return;
}
// As http://purl.org/dc/terms/ pulls in various rubbish we cheat
OntModel ontModel = ModelFactory.createOntologyModel();
hasPart = ontModel.createObjectProperty(DCTERMS + "hasPart");
checkNotNull(ontModel, hasPart);
dcterms = ontModel;
}
示例15: validate
import org.apache.jena.rdf.model.ModelFactory; //导入方法依赖的package包/类
public List<ConstraintViolation> validate(Model model)
{
if (model == null) throw new IllegalArgumentException("Model cannot be null");
OntModelSpec ontModelSpec = OntModelSpec.OWL_MEM;
OntModel tempModel = ModelFactory.createOntologyModel(ontModelSpec);
tempModel.add(fixOntModel(getOntModel())).add(model);
return SPINConstraints.check(tempModel, null);
}