本文整理匯總了Java中org.semanticweb.owlapi.apibinding.OWLManager類的典型用法代碼示例。如果您正苦於以下問題:Java OWLManager類的具體用法?Java OWLManager怎麽用?Java OWLManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OWLManager類屬於org.semanticweb.owlapi.apibinding包,在下文中一共展示了OWLManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: export
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
@UITopiaVariant(
author = "onprom team",
affiliation = "Free University of Bozen-Bolzano",
email = "[email protected]",
website = "http://onprom.inf.unibz.it"
)
@PluginVariant(requiredParameterLabels = {0, 1})
public void export(PluginContext context, OWLOntology ontology, File file) {
try {
//default format is RDF/XML format for the ontology
RDFDocumentFormat format = new RDFXMLDocumentFormat();
//save the given ontology using the format to the file
OWLManager.createOWLOntologyManager().saveOntology(ontology, format, new FileOutputStream(file));
context.log("Exported ontology to the file: " + file.getName());
} catch (Exception e) {
context.log("Couldn't export ontology to the file: " + file.getName() + " ->" + e.getMessage());
}
}
示例2: importFromStream
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
@UITopiaVariant(
author = "onprom team",
affiliation = "Free University of Bozen-Bolzano",
email = "[email protected]",
website = "http://onprom.inf.unibz.it"
)
@Override
protected OWLOntology importFromStream(final PluginContext context, final InputStream input, final String filename,
final long fileSizeInBytes) {
try {
context.getFutureResult(0).setLabel("OWL ontology imported from " + filename);
return OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(input);
} catch (final Throwable e) {
context.log("Couldn't import ontology:" + e.getMessage(), Logger.MessageLevel.ERROR);
}
return null;
}
示例3: fromOntology
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
/**
* Returns a list of rules extracted from the given OWL-2 ontology document.
*
* @param src an ontology document
* @return a list of rules
*/
public static List<Rule> fromOntology(OWLOntologyDocumentSource src) {
try {
// use OWL-API to get a OWLOntology document from source
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
manager.loadOntologyFromOntologyDocument(src);
Set<OWLOntology> ontologies = manager.getOntologies();
if (ontologies.isEmpty()) {
return Collections.EMPTY_LIST;
} else {
// use first ontology from given source
return fromOntology(ontologies.iterator().next());
}
} catch (OWLOntologyCreationException ex) {
throw new IllegalArgumentException(
"Loading ontology stream failed", ex);
}
}
示例4: createSmokeFilter
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
private static OWLEquivalentClassesAxiom createSmokeFilter() {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
OWLClass owlFilter = factory.getOWLClass(ONT_IRI + "SmokeFilter");
//hasContext some (observedProperty some Somke)
OWLObjectProperty hasContextProp = factory.getOWLObjectProperty(ONT_SSNIOT_IRI + "hasContext");
OWLObjectProperty observedProperty = factory.getOWLObjectProperty(ONT_SSN_IRI + "observedProperty");
OWLClass propCls = factory.getOWLClass(ONT_IRI + "Smoke");
return factory.getOWLEquivalentClassesAxiom(
owlFilter,
factory.getOWLObjectSomeValuesFrom(
hasContextProp,
factory.getOWLObjectSomeValuesFrom(observedProperty, propCls)
)
);
}
示例5: createTempFilter
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
private static OWLEquivalentClassesAxiom createTempFilter() {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
OWLClass owlFilter = factory.getOWLClass(ONT_SSNIOT_IRI + "TemperatureFilter");
OWLObjectProperty hasContextProp = factory.getOWLObjectProperty(ONT_SSNIOT_IRI + "hasContext");
OWLObjectProperty observedProperty = factory.getOWLObjectProperty(ONT_SSN_IRI + "observedProperty");
OWLClass propCls = factory.getOWLClass(ONT_SSNIOT_IRI + "Temperature");
return factory.getOWLEquivalentClassesAxiom(
owlFilter,
factory.getOWLObjectSomeValuesFrom(
hasContextProp,
factory.getOWLObjectSomeValuesFrom(observedProperty, propCls)
)
);
}
示例6: createSmokeFilter
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
private static OWLEquivalentClassesAxiom createSmokeFilter() {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
OWLClass owlFilter = factory.getOWLClass(ONT_SSNIOT_IRI + "SmokeFilter");
OWLObjectProperty hasContextProp = factory.getOWLObjectProperty(ONT_SSNIOT_IRI + "hasContext");
OWLObjectProperty observedProperty = factory.getOWLObjectProperty(ONT_SSN_IRI + "observedProperty");
OWLClass propCls = factory.getOWLClass(ONT_SSNIOT_IRI + "Smoke");
return factory.getOWLEquivalentClassesAxiom(
owlFilter,
factory.getOWLObjectSomeValuesFrom(
hasContextProp,
factory.getOWLObjectSomeValuesFrom(observedProperty, propCls)
)
);
}
示例7: getOntologyFromName
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
/**
* Open the OWL ontology (from the ontology resources of CartAGen) whose name
* is passed as parameter.
* @param name
* @return
* @throws OWLOntologyCreationException
*/
public static OWLOntology getOntologyFromName(String name)
throws OWLOntologyCreationException {
// create the URI from the name and the CartAGen ontologies folder path
String uri = FOLDER_PATH + "/" + name + ".owl";
InputStream stream = OwlUtil.class.getResourceAsStream(uri);
File file = new File(stream.toString());
String path = file.getAbsolutePath().substring(0,
file.getAbsolutePath().lastIndexOf('\\'));
path = path.replaceAll(new String("\\\\"), new String("//"));
path = path + "//src/main//resources//ontologies//" + name + ".owl";
// create the ontology from the URI using an OWLOntologyManager
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
IRI physicalURI = IRI.create(new File(path));
OWLOntology ontology = manager
.loadOntologyFromOntologyDocument(physicalURI);
return ontology;
}
示例8: getOntology
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
/**
* @param filename
* @return
*/
private static OWLOntology getOntology(String filename) {
File file = new File(filename);
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology o;
try {
o = m.loadOntologyFromOntologyDocument(IRI.create(file.toURI()));
} catch (OWLOntologyCreationException e) {
fail("Cannot load ontology.");
return null;
}
assertNotNull(o);
return o;
}
示例9: oneTimeSetUp
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
@BeforeClass
public static void oneTimeSetUp()
{
try {
// Create our ontology manager in the usual way.
manager = OWLManager.createOWLOntologyManager();
OWLOntology ont = manager.loadOntologyFromOntologyDocument(IRI.create("http://www.w3.org/TR/owl-guide/wine.rdf"));
// We need to create an instance of Reasoner.
StructuralReasonerFactory factory = new StructuralReasonerFactory();
reasoner = factory.createReasoner(ont);
reasoner.precomputeInferences();
}
catch(UnsupportedOperationException exception) {
System.out.println("Unsupported reasoner operation.");
}
catch(OWLOntologyCreationException e) {
System.out.println("Could not load the wine ontology: " + e.getMessage());
}
}
示例10: testDataPropertyMetadata
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
@Test
public void testDataPropertyMetadata() throws Exception {
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
{
// create a test ontology with one data property
OWLDataFactory f = m.getOWLDataFactory();
IRI propIRI = IRI.generateDocumentIRI();
OWLDataProperty prop = f.getOWLDataProperty(propIRI);
m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));
}
OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
MolecularModelManager<?> mmm = createM3(graph);
Pair<List<JsonRelationInfo>,List<JsonRelationInfo>> pair = MolecularModelJsonRenderer.renderProperties(mmm, null, curieHandler);
List<JsonRelationInfo> dataProperties = pair.getRight();
assertEquals(1, dataProperties.size());
}
示例11: main
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
public static void main(String[] args) throws OWLOntologyCreationException {
//register my built-in implementation
BuiltInRegistry.instance.registerBuiltIn("urn:makub:builtIn#IRIparts", new CustomSWRLBuiltin(new IRIparts()));
//initialize ontology and reasoner
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(IRI.create(DOC_URL));
OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance();
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, new SimpleConfiguration());
OWLDataFactory factory = manager.getOWLDataFactory();
PrefixDocumentFormat pm = manager.getOntologyFormat(ontology).asPrefixOWLOntologyFormat();
//print the SWRL rule
listSWRLRules(ontology);
//use the rule with the built-in to infer property values
OWLNamedIndividual martin = factory.getOWLNamedIndividual(":Martin", pm);
listAllDataPropertyValues(martin, ontology, reasoner);
}
示例12: getExplicitDLDisjointnessAxioms
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
/**
* A ^ B -> bottom
* @param reasoner
* @param ontology
* @param cls
* @author Shuo Zhang
* @return
*/
public static OWLClassNodeSet getExplicitDLDisjointnessAxioms(OWLReasoner reasoner, OWLOntology ontology, OWLClass cls){
OWLClassNodeSet nodeSet = new OWLClassNodeSet();
OWLClassExpression subExp;
Set<OWLClassExpression> set;
for (OWLSubClassOfAxiom sax : ontology.getSubClassAxiomsForSuperClass(OWLManager.getOWLDataFactory().getOWLNothing())) {
subExp = sax.getSubClass();
if (subExp instanceof OWLObjectIntersectionOf) {
set = subExp.asConjunctSet();
if (set.contains(cls) && set.size() == 2) {
for (OWLClassExpression op : set) {
if (!op.equals(cls) && !op.isAnonymous()) {
nodeSet.addNode(reasoner.getEquivalentClasses(op));
break;
}
}
}
}
}
return nodeSet;
}
示例13: ModuleExtractor
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
/**
* Default values for considerAnnotations=false, useIndexes=true, considerImportsClosure=true.
* @param ontology Ontology to be modularized
* @param dualConcepts Type of interpretation for concepts outside the signature
* @param dualRoles Type of interpretation for properties outside the signature
*/
public ModuleExtractor(OWLOntology ontology, boolean dualConcepts, boolean dualRoles){
ontologyManager = OWLManager.createOWLOntologyManager();
//entity2Axioms = new MultiValueMap<OWLEntity, OWLAxiom>();
ontologyAxioms=new HashSet<OWLAxiom>();
moduleAxioms = new HashSet<OWLAxiom>();
dataFactory = ontologyManager.getOWLDataFactory();
collectedEntities=new HashSet<OWLEntity>();
axiomSignatureCollector = new OWLEntityCollector(collectedEntities);
//From axioms we do not want to collect data types
axiomSignatureCollector.setCollectDatatypes(false);
//Load Ontology/ies
indexOntology(ontology);
//System.out.println("Ontology Axioms: " + ontologyAxioms.size());
//Set localityChecker
setLocalityChecker(dualConcepts, dualRoles, false, true);
}
示例14: getModuleFromAxioms
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
/**
* Necessary toi construct a module for an arbitriary set of axioms
* @param moduleAxioms
* @param moduleUri
* @return
*/
public OWLOntology getModuleFromAxioms(Set<OWLAxiom> moduleAxioms, IRI moduleIri) {
OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
OWLOntology module=null;
try {
module = ontologyManager.createOntology(moduleIri);
List<OWLOntologyChange> ontoChanges = new ArrayList<OWLOntologyChange>();
for(OWLAxiom axiom : moduleAxioms) {
ontoChanges.add(new AddAxiom(module, axiom));
}
ontologyManager.applyChanges(ontoChanges);
}
catch(Exception e) {
System.out.println("Error creating module ontology from extende set of axioms.");
}
//System.out.println("Time create OWLOntology for module (s): " + (double)((double)fin-(double)init)/1000.0);
return module;
}
示例15: checkEntailment
import org.semanticweb.owlapi.apibinding.OWLManager; //導入依賴的package包/類
/**
* Classifies a given ontology and checks whether another ontology is
* entailed by the former.
*
* @param premiseFile
* ontology file to be classified and used as premise
* @param conclusionFile
* file with the conclusion
* @throws FileNotFoundException
* if the file was not found
* @throws OWLOntologyCreationException
* if the ontology could not be created
* @throws OWLRendererException
* if a renderer error occurs
* @return <code>true</code> if and only if the premise ontology entails the
* conclusion ontology
*/
public boolean checkEntailment(File premiseFile, File conclusionFile)
throws OWLOntologyCreationException, OWLRendererException, FileNotFoundException {
Objects.requireNonNull(premiseFile);
Objects.requireNonNull(conclusionFile);
logger.fine("starting jcel console ...");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
logger.fine("loading premise ontology using the OWL API ...");
OWLOntology premiseOntology = manager.loadOntologyFromOntologyDocument(premiseFile);
logger.fine("loading conclusion ontology using the OWL API ...");
OWLOntology conclusionOntology = manager.loadOntologyFromOntologyDocument(conclusionFile);
logger.fine("starting reasoner ...");
JcelReasoner reasoner = new JcelReasoner(premiseOntology, false);
logger.fine("precomputing inferences ...");
reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
boolean ret = conclusionOntology.getAxioms().stream().allMatch(axiom -> reasoner.isEntailed(axiom));
logger.fine("jcel console finished.");
return ret;
}