本文整理汇总了Java中org.semanticweb.owlapi.model.RemoveImport类的典型用法代码示例。如果您正苦于以下问题:Java RemoveImport类的具体用法?Java RemoveImport怎么用?Java RemoveImport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoveImport类属于org.semanticweb.owlapi.model包,在下文中一共展示了RemoveImport类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeImportClosure
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
public void mergeImportClosure(boolean isRemovedImportsDeclarations) throws OWLOntologyCreationException {
OWLOntologyManager manager = getManager();
Set<OWLOntology> imports = sourceOntology.getImportsClosure();
for (OWLOntology o : imports) {
if (o.equals(sourceOntology))
continue;
String comment = "Includes "+summarizeOntology(o);
LOG.info(comment);
addCommentToOntology(sourceOntology, comment);
manager.addAxioms(sourceOntology, o.getAxioms());
}
Set<OWLImportsDeclaration> oids = sourceOntology.getImportsDeclarations();
for (OWLImportsDeclaration oid : oids) {
RemoveImport ri = new RemoveImport(sourceOntology, oid);
getManager().applyChange(ri);
}
}
示例2: mergeSpecificImport
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
/**
* Merge a specific ontology from the import closure into the main ontology.
* Removes the import statement.
*
* @param ontologyIRI id of the ontology to merge
* @throws OWLOntologyCreationException
*/
public void mergeSpecificImport(IRI ontologyIRI) throws OWLOntologyCreationException {
OWLOntologyManager manager = getManager();
Set<OWLOntology> imports = sourceOntology.getImportsClosure();
for (OWLOntology o : imports) {
if (o.equals(sourceOntology))
continue;
Optional<IRI> currentIRI = o.getOntologyID().getOntologyIRI();
if (currentIRI.isPresent() && currentIRI.get().equals(ontologyIRI)) {
String comment = "Includes "+summarizeOntology(o);
LOG.info(comment);
addCommentToOntology(sourceOntology, comment);
manager.addAxioms(sourceOntology, o.getAxioms());
}
}
Set<OWLImportsDeclaration> oids = sourceOntology.getImportsDeclarations();
for (OWLImportsDeclaration oid : oids) {
if (ontologyIRI.equals(oid.getIRI())) {
RemoveImport ri = new RemoveImport(sourceOntology, oid);
getManager().applyChange(ri);
}
}
}
示例3: handleSupportOntologies
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
private static List<OWLOntologyChange> handleSupportOntologies(OWLGraphWrapper graph)
{
OWLOntology ontology = graph.getSourceOntology();
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
List<OWLOntologyChange> removeImportChanges = new ArrayList<OWLOntologyChange>();
Set<OWLOntology> supportOntologySet = graph.getSupportOntologySet();
for (OWLOntology support : supportOntologySet) {
Optional<IRI> supportIRI = support.getOntologyID().getOntologyIRI();
if(supportIRI.isPresent()) {
IRI ontologyIRI = supportIRI.get();
OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(ontologyIRI);
ChangeApplied status = manager.applyChange(new AddImport(ontology, importDeclaration));
if (ChangeApplied.SUCCESSFULLY == status) {
// the change was successful, create remove import for later
removeImportChanges.add(new RemoveImport(ontology, importDeclaration));
}
}
}
return removeImportChanges;
}
示例4: updateOntology
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
@Override
public void updateOntology( OWLOntology generatedOntology,
IRI generatedOntologyIRI,
IRI previousOntologyIRI,
URI physicalURI) {
final OWLModelManager mm = getOWLModelManager();
IRI iri = generatedOntologyIRI;
OWLOntology generatedOntologyToDelete = null;
final List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
final Collection<OWLOntology> ontologies = mm.getOntologies();
for (OWLOntology oo : ontologies) {
if (iri.equals(oo.getOntologyID().getOntologyIRI())) {
log.info("Removing ontology " + iri);
generatedOntologyToDelete = oo;
}
changes.add(new RemoveImport(oo, getOWLOntologyManager().getOWLDataFactory()
.getOWLImportsDeclaration(iri)));
}
mm.applyChanges(changes);
changes.clear();
if (generatedOntologyToDelete != null) {
if ( !mm.removeOntology(generatedOntologyToDelete) ) {
log.info("Removing ontology " + generatedOntologyToDelete.getOntologyID() + " NOT succesful.");
}
}
changes.add(new SetOntologyID(generatedOntology, iri));
changes.add(new AddImport(generatedOntology, mm.getOWLDataFactory()
.getOWLImportsDeclaration(previousOntologyIRI)));
mm.applyChanges(changes);
mm.setPhysicalURI(generatedOntology, physicalURI);
}
示例5: updateOntology
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
@Override
public void updateOntology(
OWLOntology generatedOntology, IRI generatedOntologyIRI, IRI previousOntologyIRI,
URI physicalURI) {
IRI iri = generatedOntologyIRI;
OWLOntology generatedOntologyToDelete = null;
final List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
final Collection<OWLOntology> ontologies = m.getOntologies();
for (OWLOntology oo : ontologies) {
if (iri.equals(oo.getOntologyID().getOntologyIRI())) {
log.info("Removing ontology " + iri);
generatedOntologyToDelete = oo;
}
changes.add(new RemoveImport(oo, getOWLOntologyManager()
.getOWLDataFactory().getOWLImportsDeclaration(iri)));
}
m.applyChanges(changes);
changes.clear();
if (generatedOntologyToDelete != null) {
m.removeOntology(generatedOntologyToDelete);
}
changes.add(new SetOntologyID(generatedOntology, iri));
changes.add(new AddImport(generatedOntology, m.getOWLDataFactory()
.getOWLImportsDeclaration(previousOntologyIRI)));
m.applyChanges(changes);
m.setOntologyDocumentIRI(generatedOntology, IRI.create(physicalURI));
try {
m.saveOntology(generatedOntology);
} catch (OWLOntologyStorageException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: visit
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
public OWLOntologyChange visit(AddImport addImport) {
return new RemoveImport(addImport.getOntology(), addImport.getImportDeclaration());
}
示例7: visit
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
@Override
public void visit(RemoveImport change) {
defaultVisit(change);
}
示例8: testRemovingImpA
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
/**
* Testing correctness of the reasoner with respect to ontology changes
* <p>
* removing the import declaration for </impA>
*/
@Test
public void testRemovingImpA() throws Exception {
OWLOntologyManager man = TestOWLManager.createOWLOntologyManager();
OWLDataFactory dataFactory = man.getOWLDataFactory();
// set up resolution of prefixes
PrefixManager pm = new DefaultPrefixManager();
pm.setDefaultPrefix("http://www.example.com/main#");
pm.setPrefix("A:", "http://www.example.com/A#");
pm.setPrefix("B:", "http://www.example.com/B#");
// define query classes
OWLClass mainX = dataFactory.getOWLClass(":X", pm);
OWLClass mainY = dataFactory.getOWLClass(":Y", pm);
OWLClass extA = dataFactory.getOWLClass("A:A", pm);
OWLClass extB = dataFactory.getOWLClass("B:B", pm);
OWLClass extC = dataFactory.getOWLClass("B:C", pm);
// loading the root ontology
OWLOntology root = loadOntology(man, "root.owl");
// Create an ELK reasoner.
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(root);
try {
// ************************************
// ** removing the import declaration for </impA>
// ************************************
OWLImportsDeclaration importA = new OWLImportsDeclarationImpl(
IRI.create("http://www.example.com#impA"));
OWLOntologyChange change = new RemoveImport(root, importA);
man.applyChange(change);
reasoner.flush();
// Now the root ontology should not import anything
assertEquals(root.getAxiomCount(), 3);
assertEquals(root.getImportsClosure().size(), 1);
assertEquals(getAxioms(root).size(), 3);
// reasoner queries -- only subsumptions of the root ontology are
// there
assertTrue(reasoner.getSuperClasses(mainX, true).containsEntity(
mainY));
assertTrue(reasoner.getSuperClasses(mainX, true).containsEntity(
extA));
assertTrue(reasoner.getSuperClasses(mainY, true).containsEntity(
extB));
assertFalse(reasoner.getSuperClasses(extA, true).containsEntity(
extB));
assertFalse(reasoner.getSuperClasses(extB, true).containsEntity(
extC));
} finally {
reasoner.dispose();
}
}
示例9: createSubSet
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的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;
}
示例10: visit
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
@Override
public Boolean visit(RemoveImport change) {
Objects.requireNonNull(change);
return false;
}
示例11: removeImports
import org.semanticweb.owlapi.model.RemoveImport; //导入依赖的package包/类
/**
* Remove all imports from the given ontology
* @param ont OWL ontology
*/
private void removeImports(OWLOntology ont) {
for(OWLImportsDeclaration importDecl : ont.getImportsDeclarations())
ont.getOWLOntologyManager().applyChange(new RemoveImport(ont.getOWLOntologyManager().getImportedOntology(importDecl), importDecl));
}