本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntology.getOWLOntologyManager方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntology.getOWLOntologyManager方法的具體用法?Java OWLOntology.getOWLOntologyManager怎麽用?Java OWLOntology.getOWLOntologyManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLOntology
的用法示例。
在下文中一共展示了OWLOntology.getOWLOntologyManager方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addBioEntity
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
private void addBioEntity(OWLClass pr, OWLOntology lego, Bioentity bioentity) {
Set<OWLDeclarationAxiom> declarationAxioms = lego.getDeclarationAxioms(pr);
if (declarationAxioms == null || declarationAxioms.isEmpty()) {
// add class declaration and add label
OWLOntologyManager m = lego.getOWLOntologyManager();
OWLDataFactory f = m.getOWLDataFactory();
Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
axioms.add(f.getOWLDeclarationAxiom(pr));
String label = bioentity.getSymbol()+" - "+bioentity.getFullName();
axioms.add(f.getOWLAnnotationAssertionAxiom(f.getRDFSLabel(), pr.getIRI(), f.getOWLLiteral(label)));
m.addAxioms(lego, axioms);
}
}
示例2: minimizedTranslate
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
* Additionally minimize the lego model and imports into one ontology module.
*
* @param gaf
* @return minimized lego ontology
*/
public OWLOntology minimizedTranslate(GafDocument gaf) {
OWLOntology all = translate(gaf);
final OWLOntologyManager m = all.getOWLOntologyManager();
SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, all, ModuleType.BOT);
Set<OWLEntity> sig = new HashSet<OWLEntity>(all.getIndividualsInSignature());
Set<OWLAxiom> moduleAxioms = sme.extract(sig);
try {
OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
m.addAxioms(module, moduleAxioms);
return module;
} catch (OWLException e) {
throw new RuntimeException("Could not create minimized lego model.", e);
}
}
示例3: saveModel
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Save a model to the database.
*
* @param m
* @param annotations
* @param metadata
*
* @throws OWLOntologyStorageException
* @throws OWLOntologyCreationException
* @throws IOException
* @throws RepositoryException
* @throws UnknownIdentifierException
*/
public void saveModel(ModelContainer m,
Set<OWLAnnotation> annotations, METADATA metadata)
throws OWLOntologyStorageException, OWLOntologyCreationException,
IOException, RepositoryException, UnknownIdentifierException {
IRI modelId = m.getModelId();
final OWLOntology ont = m.getAboxOntology();
final OWLOntologyManager manager = ont.getOWLOntologyManager();
List<OWLOntologyChange> changes = preSaveFileHandler(ont);
synchronized(ont) {
try {
this.writeModelToDatabase(ont, modelId);
// reset modified flag for abox after successful save
m.setAboxModified(false);
} finally {
if (changes != null) {
List<OWLOntologyChange> invertedChanges = ReverseChangeGenerator
.invertChanges(changes);
if (invertedChanges != null && !invertedChanges.isEmpty()) {
manager.applyChanges(invertedChanges);
}
}
}
}
}
示例4: removeRedundantSubClassAxioms
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Remove the redundant and marked as inferred super class assertions for
* each class in the ontology signature. Uses the reasoner to infer the
* direct super classes.
*
* @param ontology
* @param reasoner
* @return map of class to set of redundant axioms
*/
public static Map<OWLClass, Set<RedundantAxiom>> removeRedundantSubClassAxioms(OWLOntology ontology, OWLReasoner reasoner) {
Iterable<OWLClass> classes = ontology.getClassesInSignature();
Map<OWLClass, Set<RedundantAxiom>> axioms = findRedundantSubClassAxioms(classes, ontology, reasoner);
if (!axioms.isEmpty()) {
Set<OWLSubClassOfAxiom> allAxioms = new THashSet<OWLSubClassOfAxiom>();
for(OWLClass cls : axioms.keySet()) {
for(RedundantAxiom redundantAxiom : axioms.get(cls)) {
allAxioms.add(redundantAxiom.getAxiom());
}
}
OWLOntologyManager manager = ontology.getOWLOntologyManager();
manager.removeAxioms(ontology, allAxioms);
LOG.info("Removed "+axioms.size()+" redundant axioms.");
}
return axioms;
}
示例5: synonym
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Add an synonym annotation, plus an annotation on that annotation
* that specified the type of synonym. The second annotation has the
* property oio:hasSynonymType.
*
* @param ontology the current ontology
* @param subject the subject of the annotation
* @param type the IRI of the type of synonym
* @param property the IRI of the annotation property.
* @param value the literal value of the synonym
* @return the synonym annotation axiom
*/
protected static OWLAnnotationAssertionAxiom synonym(
OWLOntology ontology, OWLEntity subject,
OWLAnnotationValue type,
OWLAnnotationProperty property,
OWLAnnotationValue value) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLAnnotationProperty hasSynonymType =
dataFactory.getOWLAnnotationProperty(
format.getIRI("oio:hasSynonymType"));
OWLAnnotation annotation =
dataFactory.getOWLAnnotation(hasSynonymType, type);
Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>();
annotations.add(annotation);
OWLAnnotationAssertionAxiom axiom =
dataFactory.getOWLAnnotationAssertionAxiom(
property, subject.getIRI(), value,
annotations);
manager.addAxiom(ontology, axiom);
return axiom;
}
示例6: setOntology
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
@Override
public void setOntology(OWLOntology o) {
this.ontology = o;
this.manager = o.getOWLOntologyManager();
Configuration conf = new Configuration();
this.reasoner = new Reasoner(conf, ontology);
}
示例7: AlternativeUelStarter
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
public AlternativeUelStarter(OWLOntology ontology) {
if (ontology == null) {
throw new IllegalArgumentException("Null argument.");
}
this.ontologyManager = ontology.getOWLOntologyManager();
this.ontologies = new HashSet<>();
this.ontologies.add(ontology);
}
示例8: getDcSourceProperty
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
private OWLAnnotationProperty getDcSourceProperty(OWLOntology lego, OWLDataFactory f) {
OWLAnnotationProperty p = f.getOWLAnnotationProperty(DC_SOURCE);
Set<OWLDeclarationAxiom> declarationAxioms = lego.getDeclarationAxioms(p);
if (declarationAxioms == null || declarationAxioms.isEmpty()) {
OWLOntologyManager m = lego.getOWLOntologyManager();
m.addAxiom(lego, f.getOWLDeclarationAxiom(p));
}
return p;
}
示例9: appendXrefAnnotations
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Append xref annotations onto an existing axiom
*
* @param axiom
* @param xrefs
* @param ontology
* @return
*/
public static OWLAxiom appendXrefAnnotations(OWLAxiom axiom, Set<String> xrefs, OWLOntology ontology) {
// filter existing
Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations());
final OWLOntologyManager manager = ontology.getOWLOntologyManager();
final OWLDataFactory factory = manager.getOWLDataFactory();
for (String x : xrefs) {
OWLAnnotationProperty p = factory.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#hasDbXref"));
OWLLiteral v = factory.getOWLLiteral(x);
newAnnotations.add(factory.getOWLAnnotation(p, v));
}
final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology);
return newAxiom;
}
示例10: exportModel
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Export the ABox, will try to set the ontologyID to the given modelId (to
* ensure import assumptions are met)
*
* @param model
* @param ontologyFormat
* @return modelContent
* @throws OWLOntologyStorageException
*/
public String exportModel(ModelContainer model, OWLDocumentFormat ontologyFormat) throws OWLOntologyStorageException {
final OWLOntology aBox = model.getAboxOntology();
final OWLOntologyManager manager = aBox.getOWLOntologyManager();
// make sure the exported ontology has an ontologyId and that it maps to the modelId
final IRI expectedABoxIRI = model.getModelId();
Optional<IRI> currentABoxIRI = aBox.getOntologyID().getOntologyIRI();
if (currentABoxIRI.isPresent() == false) {
manager.applyChange(new SetOntologyID(aBox, expectedABoxIRI));
}
else {
if (expectedABoxIRI.equals(currentABoxIRI) == false) {
OWLOntologyID ontologyID = new OWLOntologyID(Optional.of(expectedABoxIRI), Optional.of(expectedABoxIRI));
manager.applyChange(new SetOntologyID(aBox, ontologyID));
}
}
// write the model into a buffer
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
if (ontologyFormat != null) {
manager.saveOntology(aBox, ontologyFormat, outputStream);
}
else {
manager.saveOntology(aBox, outputStream);
}
// extract the string from the buffer
String modelString = outputStream.toString();
return modelString;
}
示例11: ElkReasoner
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
ElkReasoner(OWLOntology ontology, boolean isBufferingMode,
ElkReasonerConfiguration elkConfig,
final Reasoner internalReasoner) {
this.owlOntology_ = ontology;
this.owlOntologymanager_ = ontology.getOWLOntologyManager();
this.mainProgressMonitor_ = elkConfig.getProgressMonitor() == null
? new DummyProgressMonitor()
: new ElkReasonerProgressMonitor(
elkConfig.getProgressMonitor());
this.secondaryProgressMonitor_ = new DummyProgressMonitor();
this.isBufferingMode_ = isBufferingMode;
this.ontologyChangeListener_ = new OntologyChangeListener();
this.owlOntologymanager_
.addOntologyChangeListener(ontologyChangeListener_);
this.ontologyChangeProgressListener_ = new OntologyChangeProgressListener();
this.owlOntologymanager_.addOntologyChangeProgessListener(
ontologyChangeProgressListener_);
this.objectFactory_ = internalReasoner.getElkFactory();
this.owlConverter_ = OwlConverter.getInstance();
this.elkConverter_ = ElkConverter.getInstance();
this.config_ = elkConfig.getElkConfiguration();
this.isAllowFreshEntities = elkConfig
.getFreshEntityPolicy() == FreshEntityPolicy.ALLOW;
initReasoner(internalReasoner);
this.bufferedChangesLoader_ = new OwlChangesLoaderFactory(
this.mainProgressMonitor_);
if (!isBufferingMode_) {
// register the change loader only in non-buffering mode;
// in buffering mode the loader is registered only when
// changes are flushed
reasoner_.registerAxiomLoader(bufferedChangesLoader_);
}
this.ontologyReloadRequired_ = false;
}
示例12: assertSubClass
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Convenience method for asserting a subClass relation between
* a parent and child class in an ontology.
*
* @param ontology the current ontology
* @param child the child class
* @param parent the parent class
* @return the axiom
*/
protected static OWLSubClassOfAxiom assertSubClass(
OWLOntology ontology, OWLClass child, OWLClass parent) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLSubClassOfAxiom axiom =
dataFactory.getOWLSubClassOfAxiom(child, parent);
ontology.getOWLOntologyManager().addAxiom(ontology, axiom);
return axiom;
}
示例13: OldSimpleOwlSim
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
public OldSimpleOwlSim(OWLOntology sourceOntology) {
super();
this.sourceOntology = sourceOntology;
this.owlOntologyManager = sourceOntology.getOWLOntologyManager();
this.owlDataFactory = owlOntologyManager.getOWLDataFactory();
this.sourceOntology = sourceOntology;
init();
}
示例14: annotate
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Convenience method for adding an annotation assertion to the
* ontology itself, taking a CURIE for the property and an Boolean literal.
*
* @param ontology the current ontology
* @param propertyCURIE will be expanded to the full annotation
* property IRI
* @param value the literal value of the annotation
* @return the annotation axiom
*/
protected static OWLAnnotation annotate(OWLOntology ontology,
String propertyCURIE, IRI value) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
IRI iri = format.getIRI(propertyCURIE);
OWLAnnotationProperty property =
dataFactory.getOWLAnnotationProperty(iri);
OWLAnnotation annotation = dataFactory.getOWLAnnotation(
property, value);
manager.applyChange(
new AddOntologyAnnotation(ontology, annotation));
return annotation;
}
示例15: PropertyViewOntologyBuilder
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* @param sourceOntology
* @param elementsOntology
* @param viewProperty
*/
public PropertyViewOntologyBuilder(OWLOntology sourceOntology,
OWLOntology elementsOntology, OWLObjectProperty viewProperty) {
super();
this.owlOntologyManager = sourceOntology.getOWLOntologyManager();
this.owlDataFactory = owlOntologyManager.getOWLDataFactory();
this.sourceOntology = sourceOntology;
this.elementsOntology = elementsOntology;
this.viewProperty = viewProperty;
init();
}