Java Code Examples for org.semanticweb.owlapi.model.OWLObjectPropertyExpression#isAnonymous()
The following examples show how to use
org.semanticweb.owlapi.model.OWLObjectPropertyExpression#isAnonymous() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphOwlVisitor.java From SciGraph with Apache License 2.0 | 6 votes |
@Override public Void visit(OWLEquivalentObjectPropertiesAxiom axiom) { Set<OWLObjectPropertyExpression> properties = axiom.getProperties(); boolean anonymousPropertyExists = false; for (OWLObjectPropertyExpression property : properties) { anonymousPropertyExists = anonymousPropertyExists || property.isAnonymous(); } // #217 - in case of EquivalentObjectProperties(:p ObjectInverseOf(:q)) if (!anonymousPropertyExists) { Collection<Long> nodes = Collections2.transform(axiom.getObjectPropertiesInSignature(), new Function<OWLObjectProperty, Long>() { @Override public Long apply(OWLObjectProperty objectProperty) { return getOrCreateNode(getIri(objectProperty)); } }); getOrCreateRelationshipPairwise(nodes, OwlRelationships.OWL_EQUIVALENT_OBJECT_PROPERTY); } return null; }
Example 2
Source File: EliminateEJVar.java From quetzal with Eclipse Public License 2.0 | 6 votes |
/** * return named properties p such that c \subseteq \some inv(p) T * @param c * @return */ protected Set<URI> getNamedInverseSuperPropertiesOrSelf(OWLClassExpression c) { Set<OWLClassExpression> subs = taxo.getAllSubsumers(c); Set<URI> ret = new HashSet<URI>(); for (OWLClassExpression ex: subs) { if (ex.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM)) { OWLObjectSomeValuesFrom rest = (OWLObjectSomeValuesFrom) ex; OWLObjectPropertyExpression prop = rest.getProperty().getSimplified(); if (prop.isAnonymous()) { OWLObjectProperty namedProp = prop.getNamedProperty(); ret.add(namedProp.getIRI().toURI()); } } } return ret; }
Example 3
Source File: OwlApiUtils.java From SciGraph with Apache License 2.0 | 5 votes |
public static String getIri(OWLObjectPropertyExpression property) { if (property.isAnonymous()) { return "_:" + hash(property.toString()); } else { return property.asOWLObjectProperty().getIRI().toString(); } }
Example 4
Source File: BioChebiGenerator.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Create the GCIs for BioChEBI. Add the axioms into the given ontology. * * @param ontology * @param ignoredClasses */ public void expand(OWLOntology ontology, Set<OWLClass> ignoredClasses) { final OWLOntologyManager manager = ontology.getOWLOntologyManager(); final OWLDataFactory factory = manager.getOWLDataFactory(); // scan axioms Set<OWLSubClassOfAxiom> axioms = ontology.getAxioms(AxiomType.SUBCLASS_OF, Imports.INCLUDED); for (OWLSubClassOfAxiom axiom : axioms) { OWLClassExpression superCE = axiom.getSuperClass(); OWLClassExpression subCE = axiom.getSubClass(); if (subCE.isAnonymous()) { // sub class needs to be an named OWLClass continue; } if (superCE instanceof OWLObjectSomeValuesFrom == false) { continue; } OWLObjectSomeValuesFrom some = (OWLObjectSomeValuesFrom) superCE; OWLObjectPropertyExpression expression = some.getProperty(); if (expression.isAnonymous()) { // object property expression needs to be a named OWLObjectProperty continue; } OWLObjectProperty p = (OWLObjectProperty) expression; Set<OWLObjectProperty> expansions = expansionMap.get(p); if (expansions == null) { continue; } // get content for GCI OWLClassExpression y = some.getFiller(); OWLClass x = subCE.asOWLClass(); if (ignoredClasses.contains(x)) { continue; } for (OWLObjectProperty createProperty : expansions) { OWLClassExpression ce1 = factory.getOWLObjectSomeValuesFrom(createProperty, x); OWLClassExpression ce2 = factory.getOWLObjectSomeValuesFrom(createProperty, y); OWLEquivalentClassesAxiom eq = factory.getOWLEquivalentClassesAxiom(ce1, ce2); manager.addAxiom(ontology, eq); } } Set<OWLOntology> imports = ontology.getImports(); StringBuilder sb = new StringBuilder(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); sb.append("Generated on ").append(dateFormat.format(new Date())).append(" using the following import chain:"); for (OWLOntology owlOntology : imports) { OWLOntologyID ontologyID = owlOntology.getOntologyID(); sb.append(" "); appendOntologyId(ontologyID, sb); } addComment(sb.toString(), ontology); }
Example 5
Source File: LegoShuntGraphTool.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
private String getLabel(OWLClassExpression expression, OWLPrettyPrinter owlpp, OWLGraphWrapper graph) { if (expression instanceof OWLClass) { return graph.getLabelOrDisplayId(expression); } else if (expression instanceof OWLObjectIntersectionOf) { StringBuilder sb = new StringBuilder(); OWLObjectIntersectionOf intersectionOf = (OWLObjectIntersectionOf) expression; sb.append("<TABLE>"); for (OWLClassExpression ce : intersectionOf.getOperands()) { sb.append("<TR><TD>"); if (ce instanceof OWLClass) { sb.append(graph.getLabelOrDisplayId((OWLClass)ce)); } else if (ce instanceof OWLObjectSomeValuesFrom){ OWLObjectSomeValuesFrom some = (OWLObjectSomeValuesFrom) ce; OWLObjectPropertyExpression property = some.getProperty(); if (property.isAnonymous()) { sb.append(owlpp.render(property)); } else { sb.append(graph.getLabelOrDisplayId(property.asOWLObjectProperty())); } sb.append(" <B>some</B> "); OWLClassExpression filler = some.getFiller(); if (filler instanceof OWLClass) { sb.append(graph.getLabelOrDisplayId((OWLClass)filler)); } else { sb.append(owlpp.render(filler)); } } else { sb.append(ce.toString()); } sb.append("</TD></TR>"); } sb.append("</TABLE>"); return sb.toString(); } return owlpp.render(expression); }
Example 6
Source File: LegoShuntGraphTool.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
private CharSequence getLabel(OWLObjectPropertyExpression expression, OWLPrettyPrinter owlpp, OWLGraphWrapper graph) { if (expression.isAnonymous()) { return owlpp.render(expression); } return graph.getLabelOrDisplayId(expression); }
Example 7
Source File: LegoDotWriter.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
private CharSequence getLabel(OWLClassExpression expression, OWLPrettyPrinter owlpp) { if (expression instanceof OWLClass) { return insertLineBrakes(graph.getLabelOrDisplayId(expression)); } else if (expression instanceof OWLObjectIntersectionOf) { StringBuilder sb = new StringBuilder(); OWLObjectIntersectionOf intersectionOf = (OWLObjectIntersectionOf) expression; sb.append("<TABLE>"); for (OWLClassExpression ce : intersectionOf.getOperands()) { sb.append("<TR><TD>"); if (ce instanceof OWLClass) { sb.append(insertLineBrakes(graph.getLabelOrDisplayId((OWLClass)ce))); } else if (ce instanceof OWLObjectSomeValuesFrom){ OWLObjectSomeValuesFrom some = (OWLObjectSomeValuesFrom) ce; OWLObjectPropertyExpression property = some.getProperty(); if (property.isAnonymous()) { sb.append(owlpp.render(property)); } else { sb.append(insertLineBrakes(graph.getLabelOrDisplayId(property.asOWLObjectProperty()))); } sb.append(" <B>some</B> "); OWLClassExpression filler = some.getFiller(); if (filler instanceof OWLClass) { sb.append(insertLineBrakes(graph.getLabelOrDisplayId((OWLClass)filler))); } else { sb.append(insertLineBrakes(escape(owlpp.render(filler)))); } } else { sb.append(insertLineBrakes(escape(ce.toString()))); } sb.append("</TD></TR>"); } sb.append("</TABLE>"); return sb.toString(); } return insertLineBrakes(escape(owlpp.render(expression))); }
Example 8
Source File: LegoDotWriter.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
private CharSequence getLabel(OWLObjectPropertyExpression expression, OWLPrettyPrinter owlpp) { if (expression.isAnonymous()) { return insertLineBrakes(escape(owlpp.render(expression))); } return insertLineBrakes(graph.getLabelOrDisplayId(expression)); }