本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntologyManager.applyChanges方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntologyManager.applyChanges方法的具體用法?Java OWLOntologyManager.applyChanges怎麽用?Java OWLOntologyManager.applyChanges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLOntologyManager
的用法示例。
在下文中一共展示了OWLOntologyManager.applyChanges方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveModel
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的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);
}
}
}
}
}
示例2: addAutoGeneratedClassNames
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private void addAutoGeneratedClassNames(OWLOntologyManager manager,
OWLOntology ontology,
Map<String, OWLClassExpression> nameMap) {
OWLDataFactory factory = manager.getOWLDataFactory();
List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
for (Map.Entry<String, OWLClassExpression> entry : nameMap.entrySet()) {
OWLClass subClass = factory.getOWLClass( IRI.create(entry.getKey()) );
OWLAxiom declAxiom = factory.getOWLEquivalentClassesAxiom( subClass, entry.getValue() );
changes.addAll( manager.addAxiom( ontology, declAxiom ) );
}
manager.applyChanges( changes );
}
示例3: getModuleFromAxioms
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的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;
}
示例4: proofCompletenessTest
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public static <I extends Inference<?>> void proofCompletenessTest(
final OWLProver prover, final OWLAxiom entailment,
final Object conclusion, final Proof<? extends I> proof,
final InferenceJustifier<? super I, ? extends Set<? extends OWLAxiom>> justifier,
final boolean mustNotBeATautology) {
final OWLOntology ontology = prover.getRootOntology();
final OWLOntologyManager manager = ontology.getOWLOntologyManager();
// compute repairs
final Set<Set<? extends OWLAxiom>> repairs = new HashSet<Set<? extends OWLAxiom>>();
MinimalSubsetEnumerators.enumerateRepairs(conclusion, proof, justifier,
InterruptMonitor.DUMMY,
new MinimalSubsetCollector<OWLAxiom>(repairs));
if (mustNotBeATautology) {
assertFalse("Entailment is a tautology; there are no repairs!",
repairs.isEmpty());
}
for (final Set<? extends OWLAxiom> repair : repairs) {
final List<OWLOntologyChange> deletions = new ArrayList<OWLOntologyChange>();
final List<OWLOntologyChange> additions = new ArrayList<OWLOntologyChange>();
for (final OWLAxiom axiom : repair) {
deletions.add(new RemoveAxiom(ontology, axiom));
additions.add(new AddAxiom(ontology, axiom));
}
manager.applyChanges(deletions);
final boolean conclusionDerived = prover.isEntailed(entailment);
manager.applyChanges(additions);
assertFalse("Not all proofs were found!\n" + "Conclusion: "
+ conclusion + "\n" + "Repair: " + repair,
conclusionDerived);
}
}
示例5: proofsUnderOntologyUpdate
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void proofsUnderOntologyUpdate() throws Exception {
// loading and classifying via the OWL API
OWLOntology ontology = loadOntology(
ProofTest.class.getClassLoader().getResourceAsStream(
"ontologies/PropertyCompositionsWithHierarchy.owl"));
final OWLProver prover = OWLAPITestUtils.createProver(ontology);
prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);
OWLClass sub = factory.getOWLClass(IRI.create("http://example.org/A"));
OWLClass sup = factory.getOWLClass(IRI.create("http://example.org/G"));
// printInferences(reasoner, sub, sup);
// OWLExpression root =
// reasoner.getDerivedExpression(factory.getOWLSubClassOfAxiom(sub,
// sup));
// System.err.println(OWLProofUtils.printProofTree(root));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(sub, sup));
// now convert C <= R3 some D to C < S3 some D
OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
OWLClass d = factory.getOWLClass(IRI.create("http://example.org/D"));
OWLObjectProperty r3 = factory
.getOWLObjectProperty(IRI.create("http://example.org/R3"));
OWLObjectProperty s3 = factory
.getOWLObjectProperty(IRI.create("http://example.org/S3"));
OWLAxiom oldAx = factory.getOWLSubClassOfAxiom(c,
factory.getOWLObjectSomeValuesFrom(r3, d));
OWLAxiom newAx = factory.getOWLSubClassOfAxiom(c,
factory.getOWLObjectSomeValuesFrom(s3, d));
OWLOntologyManager manager = ontology.getOWLOntologyManager();
manager.applyChanges(Arrays.asList(new RemoveAxiom(ontology, oldAx),
new AddAxiom(ontology, newAx)));
prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);
// printInferences(reasoner, sub, sup);
// root =
// reasoner.getDerivedExpression(factory.getOWLSubClassOfAxiom(sub,
// sup));
// System.err.println(OWLProofUtils.printProofTree(root));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(sub, sup));
}
示例6: createSubSet
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public void createSubSet(OWLGraphWrapper targetGraph,
Set<OWLClass> subset, Set<OWLOntology> toMerge, boolean isExcludeClosure,
boolean isRemoveDangling) throws OWLOntologyCreationException {
OWLOntology targetOntology = targetGraph.getSourceOntology();
// import axioms set
Set<OWLAxiom> importAxioms = new HashSet<OWLAxiom>();
for (OWLOntology mergeOntology : toMerge) {
for (OWLClass cls : subset) {
importAxioms.addAll(mergeOntology.getAxioms(cls, Imports.EXCLUDED));
}
}
// remove merge imports
OWLOntologyManager targetManager = targetOntology.getOWLOntologyManager();
List<OWLOntologyChange> removeImports = new ArrayList<OWLOntologyChange>();
for(OWLOntology m : toMerge) {
removeImports.add(new RemoveImport(targetOntology, new OWLImportsDeclarationImpl(m.getOntologyID().getOntologyIRI().get())));
}
targetManager.applyChanges(removeImports);
// add axiom set to target ontology.
targetManager.addAxioms(targetOntology, importAxioms);
LOG.info("Start Mooncat for subset.");
Mooncat mooncat = new Mooncat(targetGraph);
for (OWLOntology ont : toMerge) {
mooncat.addReferencedOntology(ont);
}
if (!isExcludeClosure) {
// create Closure
Set<OWLAxiom> axioms = mooncat.getClosureAxiomsOfExternalReferencedEntities();
mooncat.addSubAnnotationProperties(axioms);
// add missing axioms
targetManager.addAxioms(targetOntology, axioms);
LOG.info("Added "+axioms.size()+" axioms to the query ontology");
}
if (isRemoveDangling) {
mooncat.removeDanglingAxioms();
}
return;
}
示例7: cleanupSupportOntologies
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private static void cleanupSupportOntologies(OWLGraphWrapper graph, List<OWLOntologyChange> remove)
{
OWLOntology ontology = graph.getSourceOntology();
OWLOntologyManager manager = ontology.getOWLOntologyManager();
manager.applyChanges(remove);
}