private OWLProperty getExistingProperty(String relationName) { for (String relationNamewithCase : generateCaseCombinationsSimple(relationName)) { for (String nameSpace : nameSpaces.values()) { IRI fetchIRI = IRI.create(nameSpace + relationNamewithCase); if (ontology.containsDataPropertyInSignature(fetchIRI)) { // consider properties as new if they are not present in the initial ontology if (initialProperties.contains(dataFactory.getOWLObjectProperty(fetchIRI))) { existingRelations.add(fetchIRI.toString() + "\n"); } countExistingRelations += 1; // for a current axiom, take into account current state of // the ontology return dataFactory.getOWLDataProperty(fetchIRI); } if (ontology.containsObjectPropertyInSignature(fetchIRI)) { // consider properties as new if they are not present in the initial ontology if (initialProperties.contains(dataFactory.getOWLObjectProperty(fetchIRI))) { existingRelations.add(fetchIRI.toString() + "\n"); } countExistingRelations += 1; return dataFactory.getOWLObjectProperty(fetchIRI); } } } return null; // return null if nothing matches. }
private Object[] addRelations(Set<String> relationNames) { // search for relations and add them if they don't exist List<String> newRelationsInAxiom = new ArrayList<String>(); List<String> existingRelationsInAxiom = new ArrayList<String>(); for (String relationName : relationNames) { String relationNameNoColon = relationName.replace(":", ""); // disallow MWE, but keep track of the original relation in entitiesToUri String relationNameNoMwe = relationNameNoColon.replace("_+_", "_"); OWLProperty property = getExistingProperty(relationNameNoMwe); if (property == null) { addNewObjectProperty(relationNameNoMwe); entitiesToUri.put(relationNameNoColon, "<http://airbus-group.installsys/component#" + relationNameNoMwe + ">"); log.log(Level.FINER, "add a new property to the ontology: <http://airbus-group.installsys/component#" + relationNameNoMwe + ">"); newRelationsInAxiom.add(relationNameNoMwe); } else { entitiesToUri.put(relationNameNoColon, property.toString()); existingRelationsInAxiom.add(relationNameNoMwe); } } return new Object[] {existingRelationsInAxiom, newRelationsInAxiom }; }
public SolrInputDocument collect(OWLObject obj, OWLGraphWrapper graph) { SolrInputDocument cls_doc = new SolrInputDocument(); // General for all ontology objects. cls_doc.addField("id", graph.getIdentifier(obj)); cls_doc.addField("label", graph.getLabel(obj)); cls_doc.addField("description", graph.getDef(obj)); if (obj instanceof OWLClass) collectClass(cls_doc, graph, (OWLClass)obj); else if (obj instanceof OWLIndividual) collectIndividual(cls_doc, (OWLIndividual)obj); else if (obj instanceof OWLProperty) collectProperty(cls_doc, (OWLProperty)obj); return cls_doc; }
private OWLProperty findRegisteredProperty(String uriencoded) { String uri = uriencoded; OWLProperty classOWL = null; ONodeID nodeid = null; try { nodeid = new ONodeIDImpl(uri, false); } catch (Exception e) { // find nodeid = new ONodeIDImpl(uri, false); } if (nodeid != null && this.annotationProperties.containsValue(nodeid)) { for (Entry<OWLDataProperty, Property> entry : dataProperties.entrySet()) { if (entry.getValue().equals(nodeid)) { classOWL = entry.getKey(); } } } return classOWL; }
@Override public void addToOntology() { OWLProperty property = featurePool.getExclusiveProperty(":noDomainAndRangeObjectProperty"); OWLAxiom axiom = factory.getOWLDeclarationAxiom(property); addAxiomToOntology(axiom); }
private void writeEdges(XMLStreamWriter writer, OWLObject c, List<OWLObject> allClasses, OWLGraphWrapper graph, List<GafDocument> gafs) throws XMLStreamException { String id = getId(graph.getIdentifier(c)); Set<OWLGraphEdge> edges = graph.getOutgoingEdges(c); for (OWLGraphEdge owlGraphEdge : edges) { OWLObject target = owlGraphEdge.getTarget(); if (!allClasses.contains(target)) continue; String tid = getId(graph.getIdentifier(target)); OWLQuantifiedProperty qp = owlGraphEdge.getSingleQuantifiedProperty(); OWLProperty p = qp.getProperty(); String pid; if (p == null) { pid = qp.getQuantifier().toString(); } else { pid = getId(graph.getIdentifier(p)); if (pid == null) { pid = "UNK"; } } String eid = id+" ("+pid+") "+tid; writer.writeStartElement("edge"); writer.writeAttribute("id", eid); writer.writeAttribute("label", eid); writer.writeAttribute("source", id); writer.writeAttribute("target", tid); writer.writeStartElement("att"); writer.writeAttribute("name","interaction"); writer.writeAttribute("value",pid); writer.writeEndElement(); // att writer.writeEndElement(); // edge } }
/** * * @param newIRI * @return ontology * @throws OWLOntologyCreationException */ public OWLOntology extractPropertyOntology(IRI newIRI) throws OWLOntologyCreationException { Set<OWLProperty> props = new HashSet<OWLProperty>(); for (OWLObjectProperty p : mainOntology.getObjectPropertiesInSignature(Imports.INCLUDED)) { LOG.info("mainOntology contains: "+p); props.add(p); } return extractPropertyOntology(newIRI, props); }
public Set<Object> getSubProperties(Object pr, int local, int asserted, int named) { Set<Object> sbpr = new HashSet<Object>(); for (Object p : getProperties()) { if (getSuperProperties((OWLProperty) p, local, asserted, named).contains(pr)) sbpr.add(p); } return sbpr; }
public Set<Object> getRange(Object p, int asserted) { Set<Object> resultSet = new HashSet<Object>(); for (Object ent : ((OWLProperty) p).getRanges(getOntology())) { // Not correct // Could be something else than class if (ent instanceof OWLClass || ent instanceof OWLDatatype) { resultSet.add(ent); } } return resultSet; }
public Set<Object> getDomain(Object p, int asserted) { Set<Object> resultSet = new HashSet<Object>(); for (Object ent : ((OWLProperty) p).getDomains(getOntology())) { // Not correct // Could be something else than class if (ent instanceof OWLClass) { resultSet.add(ent); } } return resultSet; }
@Override public void addToOntology() { OWLProperty property = factory.getOWLDataProperty(":noDomainAndRangeDataProperty", pm); addAxiomToOntology(factory.getOWLDeclarationAxiom(property)); }
private void collectProperty(SolrInputDocument d, OWLProperty obj) { }
public boolean isProperty(Object o) { return o instanceof OWLProperty; }