本文整理汇总了Java中org.semanticweb.owlapi.model.RemoveAxiom类的典型用法代码示例。如果您正苦于以下问题:Java RemoveAxiom类的具体用法?Java RemoveAxiom怎么用?Java RemoveAxiom使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RemoveAxiom类属于org.semanticweb.owlapi.model包,在下文中一共展示了RemoveAxiom类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeAnnotation
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
/** Removes the set annotations of the entity from the given ontology using the given manager.
* @param modelManager
* @param currentEntity
* @param ontology
* @param annotations
*/
public static void removeAnnotation(OWLModelManager modelManager,
OWLEntity currentEntity,
OWLOntology ontology,
Set<OWLAnnotation> annotations) {
OWLDataFactory factory = modelManager.getOWLDataFactory();
List<OWLOntologyChange> changes = new Vector<OWLOntologyChange>();
for(OWLAnnotation annot : annotations) {
OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom(
currentEntity.getIRI(),
annot);
changes.add(new RemoveAxiom(ontology, axiom));
}
modelManager.applyChanges(changes);
}
示例2: undo
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
public void undo() {
OWLClassAssertionAxiom axiom = null;
if (isTypePlus) {
axiom = theContext.getFactory().getOWLClassAssertionAxiom(changedType, candidate);
}
else {
axiom = theContext.getFactory().getOWLClassAssertionAxiom(
theContext.getFactory().getOWLObjectComplementOf(changedType), candidate);
}
RemoveAxiom removeAxiom = new RemoveAxiom(theContext.getOntology(),axiom);
try {
theContext.getManager().applyChange(removeAxiom);
}
catch (OWLOntologyChangeException e) {
e.printStackTrace();
System.exit(-1);
}
}
示例3: removeRedundantAxioms
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
void removeRedundantAxioms() {
final List<RemoveAxiom> changes = new ArrayList<RemoveAxiom>();
Set<OWLClass> allClasses = ont.getClassesInSignature(true);
logger.info("Check classes for redundant super class axioms, all OWL classes count: " + allClasses.size());
for (OWLClass cls: allClasses) {
final Set<OWLClass> directSuperClasses = reasoner.getSuperClasses(cls, true).getFlattened();
for (final OWLOntology importedOntology: ont.getImportsClosure()) {
Set<OWLSubClassOfAxiom> subClassAxioms = importedOntology.getSubClassAxiomsForSubClass(cls);
for (final OWLSubClassOfAxiom subClassAxiom : subClassAxioms) {
subClassAxiom.getSuperClass().accept(new OWLClassExpressionVisitorAdapter(){
@Override
public void visit(OWLClass desc) {
if (directSuperClasses.contains(desc) == false) {
changes.add(new RemoveAxiom(importedOntology, subClassAxiom));
}
}
});
}
}
}
logger.info("Found redundant axioms: " + changes.size());
List<OWLOntologyChange> result = manager.applyChanges(changes);
logger.info("Removed axioms: " + result.size());
}
示例4: undo
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
public void undo() {
RemoveAxiom removeAxiom = new RemoveAxiom(getContext().getOntology(),
getChange().getAxiom());
try {
getContext().getManager().applyChange(removeAxiom);
// context.reClassifyOntology();
}
catch (OWLOntologyChangeException e) {
e.printStackTrace();
System.exit(-1);
}
}
示例5: modifyAnnotations
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
private OWLObjectPropertyAssertionAxiom modifyAnnotations(OWLObjectPropertyAssertionAxiom axiom,
Set<OWLAnnotation> replacement,
ModelContainer model, METADATA metadata) {
OWLOntology ont = model.getAboxOntology();
OWLDataFactory f = model.getOWLDataFactory();
List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(2);
changes.add(new RemoveAxiom(ont, axiom));
OWLObjectPropertyAssertionAxiom newAxiom =
f.getOWLObjectPropertyAssertionAxiom(axiom.getProperty(), axiom.getSubject(), axiom.getObject(), replacement);
changes.add(new AddAxiom(ont, newAxiom));
applyChanges(model, changes, metadata);
return newAxiom;
}
示例6: removeAxiom
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
void removeAxiom(ModelContainer model, OWLAxiom axiom, METADATA metadata) {
OWLOntology ont = model.getAboxOntology();
List<OWLOntologyChange> changes = Collections.<OWLOntologyChange>singletonList(new RemoveAxiom(ont, axiom));
synchronized (ont) {
/*
* all changes to the ontology are synchronized via the ontology object
*/
applyChanges(model, ont.getOWLOntologyManager(), changes, metadata);
}
}
示例7: removeAxioms
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
void removeAxioms(ModelContainer model, Set<OWLAxiom> axioms, METADATA metadata) {
OWLOntology ont = model.getAboxOntology();
List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(axioms.size());
for(OWLAxiom axiom : axioms) {
changes.add(new RemoveAxiom(ont, axiom));
}
synchronized (ont) {
/*
* all changes to the ontology are synchronized via the ontology object
*/
applyChanges(model, ont.getOWLOntologyManager(), changes, metadata);
}
}
示例8: loadDefaultConstraintsFromOWL
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
/**
* Loads conditional constraints from an ontology with annotated axioms
*
* @param ontology
* @param signature
* @param declAxioms Used to return declaration axioms for auto-generated class names
* @param iriPrefix IRI prefix for auto-generated class names
* @param raxList
* @return
*/
public static Set<ConditionalConstraint> loadDefaultConstraintsFromOWL(
OWLOntology ontology,
Map<String, OWLClassExpression> nameMap,
Set<OWLEntity> signature,
List<RemoveAxiom> raxList, String iriPrefix,
OWLOntologyManager manager) {
Set<ConditionalConstraint> ccSet = new HashSet<ConditionalConstraint>();
//Begin with generic (default) subclass-of axioms
for( OWLAxiom axiom : ontology.getAxioms( AxiomType.SUBCLASS_OF ) ) {
for( OWLAnnotation annotation : axiom.getAnnotations() ) {
if( Constants.CERTAINTY_ANNOTATION_URI.equals(annotation.getProperty().getIRI().toURI() ) ) {
OWLSubClassOfAxiom sbAxiom = (OWLSubClassOfAxiom) axiom;
String subClassIRI = generateClassName(sbAxiom.getSubClass(), nameMap, iriPrefix);
String superClassIRI = generateClassName(sbAxiom.getSuperClass(), nameMap, iriPrefix);
ConditionalConstraint cc = newConstraint(subClassIRI, superClassIRI, annotation.getValue().toString());
signature.addAll( sbAxiom.getSubClass().getClassesInSignature() );
signature.addAll( sbAxiom.getSuperClass().getClassesInSignature() );
if( null != cc ) {
ccSet.add( cc );
if( null != raxList ) {
raxList.add( new RemoveAxiom( ontology, axiom ) );
}
}
}
}
}
return ccSet;
}
示例9: getPendingAxiomRemovals
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
public Set<OWLAxiom> getPendingAxiomRemovals() {
Set<OWLAxiom> removed = new HashSet<OWLAxiom>();
for (OWLOntologyChange change : m_pendingChanges)
if (change instanceof RemoveAxiom)
removed.add(change.getAxiom());
return removed;
}
示例10: getPendingAxiomRemovals
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
Set<OWLAxiom> getPendingAxiomRemovals() {
Set<OWLAxiom> removed = new HashSet<OWLAxiom>();
for (OWLOntologyChange change : pendingChanges_) {
if (change instanceof RemoveAxiom) {
removed.add(change.getAxiom());
}
}
return removed;
}
示例11: removeSubsetEntities
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
@CLIMethod("--remove-subset-entities")
public void removeSubsetEntities(Opts opts) throws Exception {
opts.info("[SUBSET]+","Removes all classes, individuals and object properties that are in the specific subset(s)");
List<String> subSets = opts.nextList();
if (subSets == null || subSets.isEmpty()) {
System.err.println("At least one subset is required for this function.");
exit(-1);
}
// create annotation values to match
Set<OWLAnnotationValue> values = new HashSet<OWLAnnotationValue>();
OWLDataFactory f = g.getDataFactory();
for(String subSet : subSets) {
// subset as plain string
values.add(f.getOWLLiteral(subSet));
// subset as IRI
values.add(IRI.create(Obo2OWLConstants.DEFAULT_IRI_PREFIX+"#"+subSet));
}
// get annotation property for subset
OWLAnnotationProperty p = g.getAnnotationProperty(OboFormatTag.TAG_SUBSET.getTag());
// collect all objects in the given subset
final Set<OWLObject> entities = Mooncat.findTaggedEntities(p, values, g);
LOG.info("Found "+entities.size()+" tagged objects.");
if (entities.isEmpty() == false) {
final List<RemoveAxiom> changes = Mooncat.findRelatedAxioms(entities, g);
if (changes.isEmpty() == false) {
LOG.info("applying changes to ontology, count: "+changes.size());
g.getManager().applyChanges(changes);
}
else {
LOG.info("No axioms found for removal.");
}
}
}
示例12: tr
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
public Set<OWLOntologyChange> tr(OWLAxiom inAxiom, Mapping m) {
Set<OWLOntologyChange> chgs = new HashSet<OWLOntologyChange>();
boolean isModified = false;
OWLAxiom newAxiom = null;
if (inAxiom instanceof OWLEquivalentClassesAxiom) {
OWLEquivalentClassesAxiom aa = (OWLEquivalentClassesAxiom)inAxiom;
Set<OWLClassExpression> xs = new HashSet<OWLClassExpression>();
for (OWLClassExpression x : aa.getClassExpressions()) {
OWLClassExpression x2 = replace(x, m);
if (x2 == null) {
xs.add(x);
}
else {
isModified = true;
xs.add(x2);
LOG.info(" TR : "+x+ " ---> "+x2);
}
}
if (isModified) {
newAxiom = getOWLDataFactory().getOWLEquivalentClassesAxiom(xs);
}
}
if (isModified) {
if (m.isReplace) {
chgs.add(new RemoveAxiom(ontology, inAxiom));
}
chgs.add(new AddAxiom(ontology, newAxiom));
}
return chgs;
}
示例13: removeInferredAxioms
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
/**
* Remove inferred axioms, which are marked by the appropriate axiom annotation.
*
* @param removedSubClassOfAxioms
* @param removedSubClassOfAxiomChanges
*
* @see AxiomAnnotationTools#isMarkedAsInferredAxiom(OWLAxiom)
*/
private void removeInferredAxioms(Set<OWLSubClassOfAxiom> removedSubClassOfAxioms, Set<RemoveAxiom> removedSubClassOfAxiomChanges)
{
final OWLOntology ont = mooncat.getGraph().getSourceOntology();
for (OWLSubClassOfAxiom a : ont.getAxioms(AxiomType.SUBCLASS_OF)) {
if (AxiomAnnotationTools.isMarkedAsInferredAxiom(a)) {
RemoveAxiom rmax = new RemoveAxiom(ont, a);
removedSubClassOfAxiomChanges.add(rmax);
removedSubClassOfAxioms.add(a);
}
}
}
示例14: removeUnaryDisjointnessAxioms
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
/**
* Remove unary disjointness axioms from the given ontology
* @param ont OWL ontology
*/
private void removeUnaryDisjointnessAxioms(OWLOntology ont) {
List<RemoveAxiom> toRemove = new ArrayList<RemoveAxiom>();
for(OWLAxiom ax : ont.getAxioms(AxiomType.DISJOINT_CLASSES)) {
OWLDisjointClassesAxiom dis = (OWLDisjointClassesAxiom)ax;
if(dis.getClassesInSignature().size() < 2)
toRemove.add(new RemoveAxiom(ont, ax));
}
ont.getOWLOntologyManager().applyChanges(toRemove);
}
示例15: removeAbox
import org.semanticweb.owlapi.model.RemoveAxiom; //导入依赖的package包/类
/**
* Remove Abox axioms from given ontology
* @param ont Ontology to remove Abox axioms from
*/
private void removeAbox(OWLOntology ont) {
Set<OWLAxiom> aboxAxs = ont.getABoxAxioms(true);
List<RemoveAxiom> toRemove = new ArrayList<RemoveAxiom>();
for(OWLAxiom ax : aboxAxs)
toRemove.add(new RemoveAxiom(ont, ax));
ont.getOWLOntologyManager().applyChanges(toRemove);
}