org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom Java Examples
The following examples show how to use
org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom.
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: OWLInAboxTranslator.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @param i - source * @param supc - target expression (e.g. R some B) * @return OWLObjectPropertyAssertionAxiom or null */ private OWLObjectPropertyAssertionAxiom trEdge(OWLIndividual i, OWLClassExpression supc) { if (supc instanceof OWLObjectSomeValuesFrom) { OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)supc; OWLObjectPropertyExpression p = trTypeLevel(svf.getProperty()); OWLIndividual j; if (svf.getFiller().isAnonymous()) { j = anonClassToIndividual(svf.getFiller()); add(trEdge(j, svf.getFiller())); } else { j = classToIndividual((OWLClass)svf.getFiller()); } OWLObjectPropertyAssertionAxiom e = getOWLDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j); return e; } return null; }
Example #2
Source File: OWLHandler.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Deprecated public void deleteFactCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException { if (isHelp()) { info("generates ClassAssertion"); return; } OWLOntology ont = resolveOntology(Param.ontology); OWLIndividual i = resolveIndividual(Param.individualId); OWLIndividual j = resolveIndividual(Param.fillerId); OWLObjectProperty p = resolveObjectProperty(Param.propertyId); for (OWLObjectPropertyAssertionAxiom ax : ont.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)) { if (ax.getSubject().equals(i)) { if (p == null || ax.getProperty().equals(p)) { if (j == null || ax.getObject().equals(j)) { removeAxiom(ont, graph.getDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j)); } } } } String jsonStr = ""; response.getWriter().write(jsonStr); }
Example #3
Source File: ModelAnnotationSolrDocumentLoader.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> findProcesses(OWLNamedIndividual mf) { Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> result = new HashMap<OWLClass, Pair<OWLNamedIndividual,Set<OWLAnnotation>>>(); Set<OWLObjectPropertyAssertionAxiom> axioms = model.getObjectPropertyAssertionAxioms(mf); for (OWLObjectPropertyAssertionAxiom axiom : axioms) { if (partOf.equals(axiom.getProperty()) && mf.equals(axiom.getSubject())) { // relevant axiom OWLIndividual bpCandidate = axiom.getObject(); if (bpCandidate.isNamed()) { final OWLNamedIndividual named = bpCandidate.asOWLNamedIndividual(); Set<OWLClass> bpTypes = getTypes(named); for (OWLClass bpType : bpTypes) { if (bpSet.contains(bpType) == false) { continue; } result.put(bpType, Pair.of(named, getAnnotations(axiom, named))); } } } } return result; }
Example #4
Source File: ModelAnnotationSolrDocumentLoader.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> findLocations(OWLNamedIndividual mf) { Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> result = new HashMap<OWLClass, Pair<OWLNamedIndividual,Set<OWLAnnotation>>>(); Set<OWLObjectPropertyAssertionAxiom> axioms = model.getObjectPropertyAssertionAxioms(mf); for (OWLObjectPropertyAssertionAxiom axiom : axioms) { if (occursIn.equals(axiom.getProperty()) && mf.equals(axiom.getSubject())) { // relevant axiom OWLIndividual locationCandidate = axiom.getObject(); if (locationCandidate.isNamed()) { OWLNamedIndividual named = locationCandidate.asOWLNamedIndividual(); Set<OWLClass> locationTypes = getTypes(named); for (OWLClass locationType : locationTypes) { result.put(locationType, Pair.of(named, getAnnotations(axiom, named))); } } } } return result; }
Example #5
Source File: AbstractElkObjectConverter.java From elk-reasoner with Apache License 2.0 | 5 votes |
@Override public OWLObjectPropertyAssertionAxiom visit( ElkObjectPropertyAssertionAxiom axiom) { return owlFactory_.getOWLObjectPropertyAssertionAxiom( convert(axiom.getProperty()), convert(axiom.getSubject()), convert(axiom.getObject())); }
Example #6
Source File: LegoUnitTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Set<OWLObjectPropertyAssertionAxiom> getPropertyAxioms(OWLNamedIndividual individual) { Set<OWLObjectPropertyAssertionAxiom> propertyAxioms = new HashSet<OWLObjectPropertyAssertionAxiom>(); for(OWLOntology o : graph.getAllOntologies()) { propertyAxioms.addAll(o.getObjectPropertyAssertionAxioms(individual)); } return propertyAxioms; }
Example #7
Source File: LegoTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Set<OWLObjectPropertyAssertionAxiom> getAllPropertyAssertionAxioms(Set<OWLOntology> ontologies) { Set<OWLObjectPropertyAssertionAxiom> axioms = new HashSet<OWLObjectPropertyAssertionAxiom>(); for(OWLOntology o : ontologies) { axioms.addAll(o.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)); } return axioms; }
Example #8
Source File: LegoTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Set<OWLObjectPropertyAssertionAxiom> getPropertyAxioms(OWLNamedIndividual individual, Set<OWLOntology> ontologies) { Set<OWLObjectPropertyAssertionAxiom> propertyAxioms = new HashSet<OWLObjectPropertyAssertionAxiom>(); for(OWLOntology o : ontologies) { propertyAxioms.addAll(o.getObjectPropertyAssertionAxioms(individual)); } return propertyAxioms; }
Example #9
Source File: LegoTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public List<LegoNode> createLegoNodes(Collection<OWLNamedIndividual> individuals) throws UnExpectedStructureException { List<LegoNode> nodes = new ArrayList<LegoNode>(individuals.size()); Set<OWLOntology> ontologies = new HashSet<OWLOntology>(graph.getAllOntologies()); for (OWLNamedIndividual individual : individuals) { Set<OWLClassAssertionAxiom> axioms = getClassAxioms(individual, ontologies); final LegoNode node = createNode(individual, axioms, ontologies); if (node != null) { // links List<LegoLink> links = new ArrayList<LegoLink>(); Set<OWLObjectPropertyAssertionAxiom> propertyAxioms = getPropertyAxioms(individual, ontologies); for (OWLObjectPropertyAssertionAxiom propertyAxiom : propertyAxioms) { OWLIndividual object = propertyAxiom.getObject(); if (object instanceof OWLNamedIndividual == false) { throw new UnExpectedStructureException("Expected a named individual for a link: "+propertyAxiom); } OWLNamedIndividual namedTarget = (OWLNamedIndividual) object; OWLObjectPropertyExpression property = propertyAxiom.getProperty(); LegoLink link = new LegoLink(individual, namedTarget, property); LegoMetadata.extractMetadata(link, propertyAxiom); links.add(link); } if (!links.isEmpty()) { node.setLinks(links); } nodes.add(node); } } return nodes; }
Example #10
Source File: OwlHelper.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Map<OWLObjectPropertyExpression, Set<OWLIndividual>> getObjectPropertyValues(OWLIndividual i, OWLOntology ont) { Set<OWLObjectPropertyAssertionAxiom> axioms = ont.getObjectPropertyAssertionAxioms(i); Map<OWLObjectPropertyExpression, Set<OWLIndividual>> result = new HashMap<>(); for(OWLObjectPropertyAssertionAxiom ax : axioms) { Set<OWLIndividual> inds = result.get(ax.getProperty()); if (inds == null) { inds = new HashSet<>(); result.put(ax.getProperty(), inds); } inds.add(ax.getObject()); } return result; }
Example #11
Source File: AbstractOwlAxiomConverterVisitor.java From elk-reasoner with Apache License 2.0 | 5 votes |
@Override public T visit(OWLObjectPropertyAssertionAxiom axiom) { throw new IllegalArgumentException( OWLObjectPropertyAssertionAxiom.class.getSimpleName() + " cannot be converted to " + getTargetClass().getSimpleName()); }
Example #12
Source File: FailingOwlAxiomVisitor.java From elk-reasoner with Apache License 2.0 | 4 votes |
@Override public void visit(OWLObjectPropertyAssertionAxiom axiom) { defaultVisit(axiom); }
Example #13
Source File: OwlIndividualAxiomConverterVisitor.java From elk-reasoner with Apache License 2.0 | 4 votes |
@Override public ElkAssertionAxiom visit(OWLObjectPropertyAssertionAxiom axiom) { return CONVERTER.convert(axiom); }
Example #14
Source File: AxiomAnnotationTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public OWLAxiom visit(OWLObjectPropertyAssertionAxiom axiom) { return factory.getOWLObjectPropertyAssertionAxiom(axiom.getProperty(), axiom.getSubject(), axiom.getObject(), annotations); }
Example #15
Source File: CardinalityContraintsTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void visit(OWLObjectPropertyAssertionAxiom axiom) { }
Example #16
Source File: OwlAxiomConverterVisitor.java From elk-reasoner with Apache License 2.0 | 4 votes |
@Override public ElkAxiom visit(OWLObjectPropertyAssertionAxiom axiom) { return CONVERTER.convert(axiom); }
Example #17
Source File: OwlConverter.java From elk-reasoner with Apache License 2.0 | 4 votes |
@SuppressWarnings("static-method") public ElkObjectPropertyAssertionAxiom convert( OWLObjectPropertyAssertionAxiom owlObjectPropertyAssertionAxiom) { return new ElkObjectPropertyAssertionAxiomWrap<OWLObjectPropertyAssertionAxiom>( owlObjectPropertyAssertionAxiom); }
Example #18
Source File: SimpleOntology.java From mobi with GNU Affero General Public License v3.0 | 4 votes |
@Override public Hierarchy getConceptRelationships(ValueFactory vf, ModelFactory mf) { long start = getStartTime(); try { Hierarchy hierarchy = new Hierarchy(vf, mf); OWLClass conceptClass = owlManager.getOWLDataFactory() .getOWLClass(org.semanticweb.owlapi.model.IRI.create(CONCEPT)); owlReasoner.instances(conceptClass) .filter(this::isDeclaredIndividual) .forEach(concept -> { IRI conceptIRI = SimpleOntologyValues.mobiIRI(concept.getIRI()); hierarchy.addIRI(conceptIRI); Set<IRI> superConcepts = new HashSet<>(); Set<IRI> subConcepts = new HashSet<>(); owlOntology.axioms(concept, Imports.INCLUDED) .filter(axiom -> axiom.getAxiomType() == AxiomType.OBJECT_PROPERTY_ASSERTION) .map(axiom -> (OWLObjectPropertyAssertionAxiom) axiom) .forEach(axiom -> { String property = axiom.getProperty().getNamedProperty().toStringID(); if (property.equals(SKOS.NARROWER.stringValue()) || property.equals(SKOS.NARROWER_TRANSITIVE.stringValue()) || property.equals(SKOS.NARROW_MATCH.stringValue())) { IRI subConceptIRI = SimpleOntologyValues.mobiIRI( org.semanticweb.owlapi.model.IRI.create(axiom.getObject() .toStringID())); if (!subConceptIRI.equals(conceptIRI) && isDeclaredIndividual(axiom.getObject())) { subConcepts.add(subConceptIRI); } } else if (property.equals(SKOS.BROADER.stringValue()) || property.equals(SKOS.BROADER_TRANSITIVE.stringValue()) || property.equals(SKOS.BROAD_MATCH.stringValue())) { IRI superConceptIRI = SimpleOntologyValues.mobiIRI( org.semanticweb.owlapi.model.IRI.create(axiom.getObject() .toStringID())); if (!superConceptIRI.equals(conceptIRI) && isDeclaredIndividual(axiom.getObject())) { superConcepts.add(superConceptIRI); } } }); superConcepts.forEach(iri -> hierarchy.addParentChild(iri, conceptIRI)); subConcepts.forEach(iri -> hierarchy.addParentChild(conceptIRI, iri)); }); return hierarchy; } finally { logTrace("getConceptRelationships()", start); } }
Example #19
Source File: GraphOwlVisitor.java From SciGraph with Apache License 2.0 | 4 votes |
@Override public Void visit(OWLObjectPropertyAssertionAxiom axiom) { getObjectPropertyRelationship(axiom); return null; }
Example #20
Source File: OWLView.java From relex with Apache License 2.0 | 4 votes |
public Boolean BinaryRelationCB(String relName, FeatureNode srcNode, FeatureNode tgtNode) { String srcName = srcNode.get("name").getValue(); FeatureNode tgt = tgtNode.get("name"); if (tgt == null) { System.out.println("Error: No target! rel=" + relName + " and src=" + srcName); return false; } String tgtName = tgt.getValue(); if (id_map != null) { srcName = id_map.get(srcNode); tgtName = id_map.get(tgtNode); } //Optimize using StringBuilder //Get the Individual type (noun, etc.) and the type_property System.out.println("\n\tRELATION (binary) = " + relName + "(" + srcName + ", " + tgtName + ")\n"); //Cleaning if (relName.charAt(0)=='_') relName = relName.replaceFirst("_", ""); if (relName.length()>1) if (relName.charAt(1)=='%') relName = relName.replaceFirst("%", ""); if (tgtName.contains("[") || tgtName.contains("]") || srcName.contains("[") || srcName.contains("]") || tgtName.equals("WORD") || srcName.equals("WORD") || tgtName.contains("misc-") || srcName.contains("misc-")) return false; if (srcName.length()>0 && tgtName.length()>0) { //1º Add the first term to Word Class srcName=srcName.replaceAll("[\\%\\s]", ""); //System.out.println("srcName = " + srcName); OWLIndividual src_word = factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#" + srcName)); OWLClassAssertionAxiom addSrcWord = factory.getOWLClassAssertionAxiom(word,src_word); manager.applyChange(new AddAxiom(ontology, addSrcWord)); //2º Create the property relName = relName.replaceAll("[\\%\\ss]", ""); OWLObjectProperty rel = factory.getOWLObjectProperty(IRI.create(ontologyURI + "#" + relName)); //3º Add the second term to Word Class tgtName = tgtName.replaceAll("[\\%\\s]", ""); OWLIndividual dst_word = factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#" + tgtName)); OWLClassAssertionAxiom addDstWord = factory.getOWLClassAssertionAxiom(word,dst_word ); manager.applyChange(new AddAxiom(ontology, addDstWord)); //4º Create axiom for the relation OWLObjectPropertyAssertionAxiom addrel = factory.getOWLObjectPropertyAssertionAxiom(rel,src_word, dst_word); manager.applyChange(new AddAxiom(ontology, addrel)); //5º Add the words (Class) to the sentence (Class) OWLObjectPropertyAssertionAxiom addw1 = factory.getOWLObjectPropertyAssertionAxiom(has,sentenceInd, src_word); //OWLObjectPropertyAssertionAxiom addw2 = factory.getOWLObjectPropertyAssertionAxiom(sentenceInd, has, //dst_word); manager.applyChange(new AddAxiom(ontology, addw1)); //manager.applyChange(new AddAxiom(ontology, addw2)); } return false; }