本文整理汇总了Java中org.semanticweb.owlapi.model.OWLObjectUnionOf类的典型用法代码示例。如果您正苦于以下问题:Java OWLObjectUnionOf类的具体用法?Java OWLObjectUnionOf怎么用?Java OWLObjectUnionOf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OWLObjectUnionOf类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLObjectUnionOf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUnionExpression
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
public OWLObject createUnionExpression(OWLObject a, OWLObject b, OWLObject c) {
Set<OWLGraphEdge> edgesA = graph.getEdgesBetween(a, c);
Set<OWLGraphEdge> edgesB = graph.getEdgesBetween(b, c);
if (edgesA.equals(edgesB)) {
return edgeSetToExpression(edgesA);
}
else {
OWLClassExpression xa = edgeSetToExpression(edgesA);
OWLClassExpression xb = edgeSetToExpression(edgesA);
HashSet<OWLClassExpression> xl = new HashSet<OWLClassExpression>();
xl.add(xa);
xl.add(xb);
if (xl.size() == 1)
return xl.iterator().next();
OWLObjectUnionOf xu = graph.getDataFactory().getOWLObjectUnionOf(xl);
return xu;
}
}
示例2: reverseOWLObjectUnionOfs
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
/**
* Reverse all {@code OWLObjectUnionOf}s, that are operands in
* an {@code OWLEquivalentClassesAxiom}, into individual {@code OWLSubClassOfAxiom}s, where
* the classes part of the {@code OWLObjectUnionOf} become subclasses, and
* the original first operand of the {@code OWLEquivalentClassesAxiom} superclass.
* <p>
* Note that such {@code OWLEquivalentClassesAxiom}s are not removed from the ontology,
* only {@code OWLSubClassOfAxiom}s are added. The axioms containing
* {@code OWLObjectUnionOf}s will be removed by calling {@link #removeOWLObjectUnionOfs()},
* in order to give a chance to {@link #convertEquivalentClassesToSuperClasses()}
* to do its job before.
*
* @see #performDefaultModifications()
* @see #removeOWLObjectUnionOfs()
* @see #convertEquivalentClassesToSuperClasses()
*/
private void reverseOWLObjectUnionOfs() {
log.info("Reversing OWLObjectUnionOfs into OWLSubClassOfAxioms");
for (OWLOntology ont : this.getOwlGraphWrapper().getAllOntologies()) {
for (OWLClass cls : ont.getClassesInSignature()) {
for (OWLEquivalentClassesAxiom eca : ont.getEquivalentClassesAxioms(cls)) {
for (OWLClassExpression ce : eca.getClassExpressions()) {
if (ce instanceof OWLObjectUnionOf) {
for (OWLObject child : ((OWLObjectUnionOf)ce).getOperands()) {
//we reverse only named classes
if (child instanceof OWLClass) {
this.getOwlGraphWrapper().getManager().addAxiom(ont,
ont.getOWLOntologyManager().getOWLDataFactory().
getOWLSubClassOfAxiom((OWLClass) child, cls));
}
}
}
}
}
}
}
this.triggerWrapperUpdate();
log.info("OWLObjectUnionOf reversion done.");
}
示例3: visit
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
@Override
public HandlerResult visit(OWLObjectUnionOf unionOf) {
Set<OWLClassExpression> newOperands = new HashSet<OWLClassExpression>();
boolean changed = false;
for (OWLClassExpression ce : unionOf.getOperands()) {
HandlerResult handlerResult = ce.accept(this);
if (handlerResult != null) {
if (handlerResult.remove) {
return HandlerResult.remove();
}
changed = true;
newOperands.add(handlerResult.modified);
}
else {
newOperands.add(ce);
}
}
if (changed) {
if (newOperands.size() == 1) {
return HandlerResult.modified(newOperands.iterator().next());
}
return HandlerResult.modified(factory.getOWLObjectUnionOf(newOperands));
}
return null;
}
示例4: cacheReverseUnionMap
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
private void cacheReverseUnionMap() {
synchronized (edgeCacheMutex) {
extraSubClassOfEdges = new HashMap<OWLObject, Set<OWLGraphEdge>>();
if (!config.isGraphReasonedAndRelaxed) {
for (OWLOntology o : getAllOntologies()) {
for (OWLClass cls : o.getClassesInSignature()) {
for (OWLEquivalentClassesAxiom eca : o.getEquivalentClassesAxioms(cls)) {
for (OWLClassExpression ce : eca.getClassExpressions()) {
if (ce instanceof OWLObjectUnionOf) {
for (OWLObject child : ((OWLObjectUnionOf)ce).getOperands()) {
if (!extraSubClassOfEdges.containsKey(child)) {
extraSubClassOfEdges.put(child, new OWLGraphEdgeSet());
}
extraSubClassOfEdges.get(child).add(
createSubClassOfEdge(child,cls,o,eca));
}
}
}
}
}
}
}
}
}
示例5: handleUnionOf
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
private void handleUnionOf(List<CheckWarning> warnings, Set<OWLOntology> allOntologies,
OWLEquivalentClassesAxiom axiom, OWLObjectUnionOf union, OWLPrettyPrinter pp)
{
List<OWLClassExpression> operands = union.getOperandsAsList();
for(OWLClassExpression operand : operands) {
if (!operand.isAnonymous()) {
OWLClass operandCls = operand.asOWLClass();
if (isDangling(operandCls, allOntologies)) {
final IRI iri = operandCls.getIRI();
String message = "Dangling reference "+iri+" in UNION_OF axiom: "+pp.render(axiom);
warnings.add(new CheckWarning(getID(), message , isFatal(), iri, OboFormatTag.TAG_UNION_OF.getTag()));
}
}
else {
// not translatable to OBO
handleGeneric(warnings, allOntologies, axiom, operand, pp);
}
}
}
示例6: getNextPossibleSymptom
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
public String getNextPossibleSymptom() {
OWLClass disease = model.getClass("Disease");
OWLObjectUnionOf allDiseases = model.getDataFactory().getOWLObjectUnionOf(model.getSubOfExpression(disease));
OWLObjectIntersectionOf intersectionOfSelected = getIntersectionOfSelected();
OWLObjectUnionOf unionOfSubSelected = model.getDataFactory().getOWLObjectUnionOf(model.getSubOfExpression(intersectionOfSelected));
OWLObjectIntersectionOf possibleDiseasesIntersection = model.getDataFactory().getOWLObjectIntersectionOf(allDiseases, unionOfSubSelected);
Set<OWLClass> possibleDiseases = model.getSubOfExpression(possibleDiseasesIntersection);
possibleDiseases.addAll(model.getEquivalentOfExpression(possibleDiseasesIntersection));
possibleDiseases.remove(model.getDataFactory().getOWLNothing());
Set<OWLClass> possibleSymptoms = new TreeSet<OWLClass>();
Iterator<OWLClass> possibleDiseasesIterator = possibleDiseases.iterator();
while (possibleDiseasesIterator.hasNext()) {
OWLClass next = possibleDiseasesIterator.next();
possibleSymptoms.addAll(model.getSuperOfExpression(next));
}
possibleSymptoms.remove(model.getDataFactory().getOWLThing());
possibleSymptoms.remove(model.getClass("Disease"));
possibleSymptoms.removeAll(selectedSymptoms);
possibleSymptoms.removeAll(notSelectedSymptoms);
System.out.println(possibleDiseases);
if(possibleSymptoms.size()!=0 && possibleDiseases.size()>1)
return (new SimpleShortFormProvider().getShortForm((OWLClass)possibleSymptoms.toArray()[0])).substring(7);
else
return null;
}
示例7: getPossibleDisease
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
public String getPossibleDisease(){
OWLClass disease = model.getClass("Disease");
OWLObjectUnionOf allDiseases = model.getDataFactory().getOWLObjectUnionOf(model.getSubOfExpression(disease));
OWLObjectIntersectionOf intersectionOfSelected = getIntersectionOfSelected();
OWLObjectUnionOf unionOfSubSelected = model.getDataFactory().getOWLObjectUnionOf(model.getSubOfExpression(intersectionOfSelected));
OWLObjectIntersectionOf possibleDiseasesIntersection = model.getDataFactory().getOWLObjectIntersectionOf(allDiseases, unionOfSubSelected);
Set<OWLClass> possibleDiseases = model.getSubOfExpression(possibleDiseasesIntersection);
possibleDiseases.addAll(model.getEquivalentOfExpression(possibleDiseasesIntersection));
possibleDiseases.remove(model.getDataFactory().getOWLNothing());
String value="";
if(possibleDiseases.size()!=0) {
Iterator<OWLClass> it = possibleDiseases.iterator();
while (it.hasNext()) {
value+="\n"+new SimpleShortFormProvider().getShortForm(it.next());
}
}else
value+="\nCould not found";
return value;
}
示例8: visit
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
public void visit(OWLObjectUnionOf union) {
Set<OWLClassExpression> ops = union.getOperands();
for (OWLClassExpression op : ops) {
/*
* ArrayList<OWLClassExpression> l = new
* ArrayList<OWLClassExpression>(); new
* NormalizatorClassExpressionVisitor(op, l); list.addAll(l);
*/
try {
list.addAll(getListOfConjunctions(op));
} catch (UnusedClassExpressionException e) {
errorCnt++;
}
}
}
示例9: addToOntology
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
@Override
public void addToOntology() {
OWLClass c1 = featurePool.getExclusiveClass(":ObjectUnionOf_RL_Class1");
OWLClass c2 = featurePool.getExclusiveClass(":ObjectUnionOf_RL_Class2");
OWLClass c3 = featurePool.getExclusiveClass(":ObjectUnionOf_RL_Class3");
OWLObjectUnionOf unionOf = factory.getOWLObjectUnionOf(c1, c2, c3);
OWLClass unionClass = featurePool.getExclusiveClass(":ObjectUnionOf_RL");
addAxiomToOntology(factory.getOWLSubClassOfAxiom(unionOf, unionClass));
}
示例10: addToOntology
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
@Override
public void addToOntology() {
OWLClass c1 = featurePool.getExclusiveClass(":ObjectUnionOf_Class1");
OWLClass c2 = featurePool.getExclusiveClass(":ObjectUnionOf_Class2");
OWLClass c3 = featurePool.getExclusiveClass(":ObjectUnionOf_Class3");
OWLObjectUnionOf unionOf = factory.getOWLObjectUnionOf(c1, c2, c3);
OWLClass unionClass = featurePool.getExclusiveClass(":ObjectUnionOf");
addAxiomToOntology(factory.getOWLSubClassOfAxiom(unionClass, unionOf));
}
示例11: getConceptForOwlClassExpression
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
/**
* Load owl class.
*
* @param expr the owl class
* @param ontology the ontology
* @param level the level
* @return the concept
* @throws Exception the exception
*/
private Concept getConceptForOwlClassExpression(OWLClassExpression expr,
OWLOntology ontology, int level) throws Exception {
// Log it
if (expr instanceof OWLClass) {
OwlUtility.logOwlClass((OWLClass) expr, ontology, level);
} else {
OwlUtility.logOwlClassExpression(expr, ontology, level);
}
// Handle direct OWLClass
if (expr instanceof OWLClass) {
return getConceptForOwlClass((OWLClass) expr, ontology, level);
}
// Handle ObjectIntersectionOf
else if (expr instanceof OWLObjectIntersectionOf) {
return getConceptForIntersectionOf((OWLObjectIntersectionOf) expr,
ontology, level);
}
// Handle ObjectUnionOf
else if (expr instanceof OWLObjectUnionOf) {
return getConceptForUnionOf((OWLObjectUnionOf) expr, ontology, level);
}
// Handle ObjectSomeValuesFrom
else if (expr instanceof OWLObjectSomeValuesFrom) {
return getConceptForSomeValuesFrom((OWLObjectSomeValuesFrom) expr,
ontology, level);
}
else {
throw new Exception("Unexpected class expression type - "
+ expr.getClassExpressionType());
}
}
示例12: visit
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
public OWLClassExpression visit(OWLObjectUnionOf d) {
Set<OWLClassExpression> newDisjuncts=new HashSet<OWLClassExpression>();
for (OWLClassExpression description : d.getOperands()) {
OWLClassExpression descriptionNNF=getNNF(description);
newDisjuncts.add(descriptionNNF);
}
return m_factory.getOWLObjectUnionOf(newDisjuncts);
}
示例13: visit
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
@Override
public OWLObjectUnionOf visit(OWLObjectUnionOf ce) {
if (LOG.isDebugEnabled()) {
LOG.debug("Unfolding union_of: "+ce);
}
Set<OWLClassExpression> operands = ce.getOperands();
if (operands != null && !operands.isEmpty()) {
Set<OWLClassExpression> unfolded = unfoldExpressions(operands);
if (unfolded != null) {
return factory.getOWLObjectUnionOf(unfolded);
}
}
return null;
}
示例14: removeOWLObjectUnionOfs
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
/**
* Remove any {@code OWLEquivalentClassesAxiom} containing an {@code OWLObjectUnionOf}
* as class expression, and any {@code OWLSubClassOfAxiom} whose superclass is an
* {@code OWLObjectUnionOf}.
*
* @see #performDefaultModifications()
* @see #reverseOWLObjectUnionOfs()
*/
private void removeOWLObjectUnionOfs() {
log.info("Removing OWLEquivalentClassesAxiom or OWLSubClassOfAxiom containig OWLObjectUnionOf...");
for (OWLOntology ont : this.getOwlGraphWrapper().getAllOntologies()) {
for (OWLAxiom ax: ont.getAxioms()) {
boolean toRemove = false;
if (ax instanceof OWLSubClassOfAxiom) {
if (((OWLSubClassOfAxiom) ax).getSuperClass() instanceof OWLObjectUnionOf) {
toRemove = true;
}
} else if (ax instanceof OWLEquivalentClassesAxiom) {
for (OWLClassExpression ce :
((OWLEquivalentClassesAxiom) ax).getClassExpressions()) {
if (ce instanceof OWLObjectUnionOf) {
toRemove = true;
break;
}
}
}
if (toRemove) {
ont.getOWLOntologyManager().removeAxiom(ont, ax);
}
}
}
this.triggerWrapperUpdate();
log.info("Done removing OWLObjectUnionOfs");
}
示例15: visit
import org.semanticweb.owlapi.model.OWLObjectUnionOf; //导入依赖的package包/类
public void visit(OWLObjectUnionOf arg0) {
boolean isFirst=true;
for (OWLClassExpression operand : arg0.getOperands()) {
if (!isFirst)
writer.write(" or ");
operand.accept(this);
isFirst=false;
}
}