/** * Realise object properties. */ public void realiseObjectProperties() { checkPreConditions(); if (!m_dlOntology.getAllIndividuals().isEmpty()) { classifyObjectProperties(); initialisePropertiesInstanceManager(); m_instanceManager.realizeObjectRoles(m_configuration.reasonerProgressMonitor); } } /**
public void realiseObjectProperties() { checkPreConditions(); if (m_dlOntology.getAllIndividuals().size()>0) { classifyObjectProperties(); initialisePropertiesInstanceManager(); m_instanceManager.realizeObjectRoles(m_configuration.reasonerProgressMonitor); } } public void precomputeSameAsEquivalenceClasses() {
public Map<OWLNamedIndividual,Set<OWLNamedIndividual>> getObjectPropertyInstances(OWLObjectProperty property) { checkPreConditions(property); Map<OWLNamedIndividual,Set<OWLNamedIndividual>> result=new HashMap<OWLNamedIndividual,Set<OWLNamedIndividual>>(); if (!m_isConsistent) { Set<OWLNamedIndividual> all=getAllNamedIndividuals(); for (OWLNamedIndividual ind : all) result.put(ind,all); return result; } initialisePropertiesInstanceManager(); AtomicRole role=H(property); Map<Individual,Set<Individual>> relations=m_instanceManager.getObjectPropertyInstances(role); OWLDataFactory factory=getDataFactory(); for (Individual individual : relations.keySet()) { Set<OWLNamedIndividual> successors=new HashSet<OWLNamedIndividual>(); result.put(factory.getOWLNamedIndividual(IRI.create(individual.getIRI())),successors); for (Individual successorIndividual : relations.get(individual)) successors.add(factory.getOWLNamedIndividual(IRI.create(successorIndividual.getIRI()))); } return result; } public boolean hasObjectPropertyRelationship(OWLNamedIndividual subject,OWLObjectPropertyExpression propertyExpression,OWLNamedIndividual object) {
/** * @param property property * @return object property instances */ public Map<OWLNamedIndividual,Set<OWLNamedIndividual>> getObjectPropertyInstances(OWLObjectProperty property) { checkPreConditions(property); Map<OWLNamedIndividual,Set<OWLNamedIndividual>> result=new HashMap<>(); if (!m_isConsistent.booleanValue()) { Set<OWLNamedIndividual> all=getAllNamedIndividuals(); for (OWLNamedIndividual ind : all) result.put(ind,all); return result; } initialisePropertiesInstanceManager(); AtomicRole role=H(property); Map<Individual,Set<Individual>> relations=m_instanceManager.getObjectPropertyInstances(role); OWLDataFactory factory=getDataFactory(); relations.forEach((individual, set)->{ Set<OWLNamedIndividual> successors=new HashSet<>(); result.put(factory.getOWLNamedIndividual(IRI.create(individual.getIRI())),successors); for (Individual successorIndividual : set) successors.add(factory.getOWLNamedIndividual(IRI.create(successorIndividual.getIRI()))); }); return result; } /**
/** * @param _subject subject * @param propertyExpression propertyExpression * @param _object object * @return true if has object property relationships */ public boolean hasObjectPropertyRelationship(OWLNamedIndividual _subject,OWLObjectPropertyExpression propertyExpression,OWLNamedIndividual _object) { OWLNamedIndividual subject=_subject; OWLNamedIndividual object=_object; checkPreConditions(subject,propertyExpression,object); if (!m_isConsistent.booleanValue()) return true; initialisePropertiesInstanceManager(); OWLObjectProperty property=propertyExpression.getNamedProperty(); if (propertyExpression.isAnonymous()) { OWLNamedIndividual tmp=subject; subject=object; object=tmp; } AtomicRole role=H(property); Individual subj=H(subject); Individual obj=H(object); return m_instanceManager.hasObjectRoleRelationship(role,subj,obj); } @Override
@Override public NodeSet<OWLNamedIndividual> getObjectPropertyValues(OWLNamedIndividual namedIndividual,OWLObjectPropertyExpression propertyExpression) { checkPreConditions(namedIndividual,propertyExpression); if (!m_isConsistent.booleanValue()) { Node<OWLNamedIndividual> node=new OWLNamedIndividualNode(getAllNamedIndividuals()); return new OWLNamedIndividualNodeSet(Collections.singleton(node)); } AtomicRole role=H(propertyExpression.getNamedProperty()); if (!m_dlOntology.containsObjectRole(role)) return new OWLNamedIndividualNodeSet(); initialisePropertiesInstanceManager(); Individual individual=H(namedIndividual); Set<Individual> result; if (propertyExpression.isAnonymous()) { // inverse role result=m_instanceManager.getObjectPropertySubjects(role,individual); } else { // named role result=m_instanceManager.getObjectPropertyValues(role,individual); } return sortBySameAsIfNecessary(result); } /**
public boolean hasObjectPropertyRelationship(OWLNamedIndividual subject,OWLObjectPropertyExpression propertyExpression,OWLNamedIndividual object) { checkPreConditions(subject,propertyExpression,object); if (!m_isConsistent) return true; initialisePropertiesInstanceManager(); OWLObjectProperty property=propertyExpression.getNamedProperty(); if (propertyExpression.getSimplified().isAnonymous()) { OWLNamedIndividual tmp=subject; subject=object; object=tmp; } AtomicRole role=H(property); Individual subj=H(subject); Individual obj=H(object); return m_instanceManager.hasObjectRoleRelationship(role,subj,obj); } public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual namedIndividual,OWLDataProperty property) {
public NodeSet<OWLNamedIndividual> getObjectPropertyValues(OWLNamedIndividual namedIndividual,OWLObjectPropertyExpression propertyExpression) { checkPreConditions(namedIndividual,propertyExpression); if (!m_isConsistent) { Node<OWLNamedIndividual> node=new OWLNamedIndividualNode(getAllNamedIndividuals()); return new OWLNamedIndividualNodeSet(Collections.singleton(node)); } AtomicRole role=H(propertyExpression.getNamedProperty()); if (!m_dlOntology.containsObjectRole(role)) return new OWLNamedIndividualNodeSet(); initialisePropertiesInstanceManager(); Individual individual=H(namedIndividual); Set<Individual> result; if (propertyExpression.getSimplified().isAnonymous()) { // inverse role result=m_instanceManager.getObjectPropertySubjects(role,individual); } else { // named role result=m_instanceManager.getObjectPropertyValues(role,individual); } return sortBySameAsIfNecessary(result); } public Map<OWLNamedIndividual,Set<OWLNamedIndividual>> getObjectPropertyInstances(OWLObjectProperty property) {