本文整理汇总了Java中org.semanticweb.owlapi.model.OWLObjectPropertyExpression类的典型用法代码示例。如果您正苦于以下问题:Java OWLObjectPropertyExpression类的具体用法?Java OWLObjectPropertyExpression怎么用?Java OWLObjectPropertyExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OWLObjectPropertyExpression类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLObjectPropertyExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OWLAxioms
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
public OWLAxioms() {
m_classes=new HashSet<OWLClass>();
m_objectProperties=new HashSet<OWLObjectProperty>();
m_objectPropertiesOccurringInOWLAxioms=new HashSet<OWLObjectProperty>();
m_complexObjectPropertyExpressions=new HashSet<OWLObjectPropertyExpression>();
m_dataProperties=new HashSet<OWLDataProperty>();
m_namedIndividuals=new HashSet<OWLNamedIndividual>();
m_conceptInclusions=new ArrayList<OWLClassExpression[]>();
m_dataRangeInclusions=new ArrayList<OWLDataRange[]>();
m_simpleObjectPropertyInclusions=new ArrayList<OWLObjectPropertyExpression[]>();
m_complexObjectPropertyInclusions=new ArrayList<ComplexObjectPropertyInclusion>();
m_disjointObjectProperties=new ArrayList<OWLObjectPropertyExpression[]>();
m_reflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>();
m_irreflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>();
m_asymmetricObjectProperties=new HashSet<OWLObjectPropertyExpression>();
m_disjointDataProperties=new ArrayList<OWLDataPropertyExpression[]>();
m_dataPropertyInclusions=new ArrayList<OWLDataPropertyExpression[]>();
m_facts=new HashSet<OWLIndividualAxiom>();
m_hasKeys=new HashSet<OWLHasKeyAxiom>();
m_definedDatatypesIRIs=new HashSet<String>();
m_rules=new HashSet<DisjunctiveRule>();
}
示例2: getSuperObjectProperties
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
private static Set<OWLObjectPropertyExpression> getSuperObjectProperties(OWLObjectPropertyExpression p, OWLReasoner reasoner, OWLOntology ont) {
if (reasoner != null) {
return reasoner.getSuperObjectProperties(p, false).getFlattened();
}
// Elk does not support this (sigh), so we do it ourselves
Set<OWLObjectPropertyExpression> sups = new HashSet<>();
Stack<OWLObjectPropertyExpression> seeds = new Stack<>();
seeds.add(p);
while (seeds.size() > 0) {
OWLObjectPropertyExpression nextp = seeds.pop();
Set<OWLObjectPropertyExpression> xset =
ont.getObjectSubPropertyAxiomsForSubProperty(nextp).stream().
map(a -> a.getSuperProperty()).collect(Collectors.toSet());
seeds.addAll(xset);
seeds.removeAll(sups);
sups.addAll(xset);
}
return sups;
}
示例3: objectPropertyHierarchyNodeToNode
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
protected Node<OWLObjectPropertyExpression> objectPropertyHierarchyNodeToNode(
HierarchyNode<Role> hierarchyNode) {
Set<OWLObjectPropertyExpression> result = new HashSet<OWLObjectPropertyExpression>();
OWLDataFactory factory = getDataFactory();
for (Role role : hierarchyNode.getEquivalentElements()) {
if (role instanceof AtomicRole)
result.add(factory.getOWLObjectProperty(IRI
.create(((AtomicRole) role).getIRI())));
else {
OWLObjectPropertyExpression ope = factory
.getOWLObjectProperty(IRI.create(((InverseRole) role)
.getInverseOf().getIRI()));
result.add(factory.getOWLObjectInverseOf(ope));
}
}
return new OWLObjectPropertyNode(result);
}
示例4: findEquivalentProperties
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
protected Map<OWLObjectPropertyExpression,Set<OWLObjectPropertyExpression>> findEquivalentProperties(Collection<OWLObjectPropertyExpression[]> simpleObjectPropertyInclusions) {
Graph<OWLObjectPropertyExpression> propertyDependencyGraph=new Graph<OWLObjectPropertyExpression>();
Map<OWLObjectPropertyExpression,Set<OWLObjectPropertyExpression>> equivalentObjectPropertiesMapping=new HashMap<OWLObjectPropertyExpression,Set<OWLObjectPropertyExpression>>();
for (OWLObjectPropertyExpression[] inclusion : simpleObjectPropertyInclusions)
if (!inclusion[0].equals(inclusion[1]) && !inclusion[0].equals(inclusion[1].getInverseProperty().getSimplified()))
propertyDependencyGraph.addEdge(inclusion[0],inclusion[1]);
propertyDependencyGraph.transitivelyClose();
for (OWLObjectPropertyExpression objExpr : propertyDependencyGraph.getElements()) {
if (propertyDependencyGraph.getSuccessors(objExpr).contains(objExpr) || propertyDependencyGraph.getSuccessors(objExpr).contains(objExpr.getInverseProperty().getSimplified())) {
Set<OWLObjectPropertyExpression> equivPropertiesSet=new HashSet<OWLObjectPropertyExpression>();
for (OWLObjectPropertyExpression succ : propertyDependencyGraph.getSuccessors(objExpr)) {
if (!succ.equals(objExpr) && (propertyDependencyGraph.getSuccessors(succ).contains(objExpr) || propertyDependencyGraph.getSuccessors(succ).contains(objExpr.getInverseProperty().getSimplified())))
equivPropertiesSet.add(succ);
}
equivalentObjectPropertiesMapping.put(objExpr,equivPropertiesSet);
}
}
return equivalentObjectPropertiesMapping;
}
示例5: trTypeLevel
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
/**
* @param p
* @return type-level form of relation
*/
private OWLObjectPropertyExpression trTypeLevel(
OWLObjectPropertyExpression p) {
if (!this.isTranslateObjectProperty) {
return p;
}
if (p instanceof OWLObjectInverseOf) {
OWLObjectPropertyExpression p2 = trTypeLevel(((OWLObjectInverseOf)p).getInverse());
return getOWLDataFactory().getOWLObjectInverseOf(p2);
}
else {
instanceLevelRelations.add((OWLObjectProperty)p);
IRI iri = ((OWLObjectProperty) p).getIRI();
return trTypeLevel(iri);
}
}
示例6: isAsymmetric
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
protected boolean isAsymmetric(
OWLObjectPropertyExpression propertyExpression) {
checkPreConditions(propertyExpression);
if (!m_isConsistent)
return true;
OWLDataFactory factory = getDataFactory();
OWLIndividual freshIndividualA = factory
.getOWLAnonymousIndividual("fresh-individual-A");
OWLIndividual freshIndividualB = factory
.getOWLAnonymousIndividual("fresh-individual-B");
OWLAxiom assertion1 = factory.getOWLObjectPropertyAssertionAxiom(
propertyExpression, freshIndividualA, freshIndividualB);
OWLAxiom assertion2 = factory.getOWLObjectPropertyAssertionAxiom(
propertyExpression.getInverseProperty(), freshIndividualA,
freshIndividualB);
Tableau tableau = getTableau(assertion1, assertion2);
boolean result = tableau.isSatisfiable(true, null, null, null, null,
null, new ReasoningTaskDescription(true, "asymmetry of {0}",
H(propertyExpression)));
tableau.clearAdditionalDLOntology();
return !result;
}
示例7: getObjectPropertyValues
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
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);
}
示例8: hasObjectPropertyRelationship
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
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);
}
示例9: shouldGetSubPropertyClosureOf
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
/**
* Test {@link OWLGraphWrapperEdgesExtended#getSubPropertyClosureOf(OWLObjectPropertyExpression)}.
*/
@Test
public void shouldGetSubPropertyClosureOf()
{
OWLObjectProperty fakeRel1 =
wrapper.getOWLObjectPropertyByIdentifier("fake_rel1");
List<OWLObjectProperty> expectedSubProps = new ArrayList<OWLObjectProperty>();
expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel2"));
expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel3"));
expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel4"));
//fake_rel3 and fake_rel4 are sub-properties of fake_rel2,
//which is the sub-property of fake_rel1
//we also test the order of the returned properties
LinkedHashSet<OWLObjectPropertyExpression> subprops =
wrapper.getSubPropertyClosureOf(fakeRel1);
assertEquals("Incorrect sub-properties returned: ",
expectedSubProps, new ArrayList<OWLObjectPropertyExpression>(subprops));
}
示例10: visit
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
public void visit(OWLSubPropertyChainOfAxiom axiom) {
List<OWLObjectPropertyExpression> subPropertyChain=axiom.getPropertyChain();
if (!containsBottomObjectProperty(subPropertyChain) && !axiom.getSuperProperty().isOWLTopObjectProperty()) {
OWLObjectPropertyExpression superObjectPropertyExpression=axiom.getSuperProperty();
if (subPropertyChain.size()==1)
addInclusion(subPropertyChain.get(0),superObjectPropertyExpression);
else if (subPropertyChain.size()==2 && subPropertyChain.get(0).equals(superObjectPropertyExpression) && subPropertyChain.get(1).equals(superObjectPropertyExpression))
makeTransitive(axiom.getSuperProperty());
else if (subPropertyChain.size()==0)
throw new IllegalArgumentException("Error: In OWL 2 DL, an empty property chain in property chain axioms is not allowd, but the ontology contains an axiom that the empty chain is a subproperty of "+superObjectPropertyExpression+".");
else {
OWLObjectPropertyExpression[] subObjectProperties=new OWLObjectPropertyExpression[subPropertyChain.size()];
subPropertyChain.toArray(subObjectProperties);
addInclusion(subObjectProperties,superObjectPropertyExpression);
}
}
for (OWLObjectPropertyExpression objectPropertyExpression : subPropertyChain)
m_axioms.m_objectPropertiesOccurringInOWLAxioms.add(objectPropertyExpression.getNamedProperty());
m_axioms.m_objectPropertiesOccurringInOWLAxioms.add(axiom.getSuperProperty().getNamedProperty());
}
示例11: increaseWithDefinedInverseIfNecessary
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
protected void increaseWithDefinedInverseIfNecessary(OWLObjectPropertyExpression propertyToBuildAutomatonFor,Automaton leafPropertyAutomaton,Map<OWLObjectPropertyExpression,Set<OWLObjectPropertyExpression>> inversePropertiesMap,Map<OWLObjectPropertyExpression,Automaton> individualAutomata) {
Set<OWLObjectPropertyExpression> inverses=inversePropertiesMap.get(propertyToBuildAutomatonFor);
if (inverses!=null) {
Automaton inversePropertyAutomaton=null;
for (OWLObjectPropertyExpression inverse : inverses) {
if (individualAutomata.containsKey(inverse) && !inverse.equals(propertyToBuildAutomatonFor)) {
inversePropertyAutomaton=individualAutomata.get(inverse);
increaseAutomatonWithInversePropertyAutomaton(leafPropertyAutomaton,inversePropertyAutomaton);
}
}
}
else if (individualAutomata.containsKey(propertyToBuildAutomatonFor.getInverseProperty().getSimplified())) {
Automaton autoOfInv_Role = individualAutomata.get(propertyToBuildAutomatonFor.getInverseProperty().getSimplified());
increaseAutomatonWithInversePropertyAutomaton(leafPropertyAutomaton,autoOfInv_Role);
}
}
示例12: visit
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
public void visit(OWLObjectComplementOf object) {
OWLClassExpression description=object.getOperand();
if (description instanceof OWLObjectHasSelf) {
OWLObjectPropertyExpression objectProperty=((OWLObjectHasSelf)description).getProperty();
Atom roleAtom=getRoleAtom(objectProperty,X,X);
m_bodyAtoms.add(roleAtom);
}
else if (description instanceof OWLObjectOneOf && ((OWLObjectOneOf)description).getIndividuals().size()==1) {
OWLIndividual individual=((OWLObjectOneOf)description).getIndividuals().iterator().next();
m_bodyAtoms.add(Atom.create(getConceptForNominal(individual),X));
}
else if (!(description instanceof OWLClass))
throw new IllegalStateException("Internal error: invalid normal form.");
else
m_bodyAtoms.add(Atom.create(AtomicConcept.create(((OWLClass)description).getIRI().toString()),X));
}
示例13: getRoleAtom
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
protected Atom getRoleAtom(OWLObjectPropertyExpression objectProperty,Term first,Term second) {
AtomicRole atomicRole;
objectProperty=objectProperty.getSimplified();
if (objectProperty.isAnonymous()) {
OWLObjectProperty internalObjectProperty=objectProperty.getNamedProperty();
atomicRole=AtomicRole.create(internalObjectProperty.getIRI().toString());
Term tmp=first;
first=second;
second=tmp;
}
else
atomicRole=AtomicRole.create(objectProperty.asOWLObjectProperty().getIRI().toString());
if (m_allAtomicObjectRoles.contains(atomicRole))
return Atom.create(atomicRole,first,second);
else
throw new IllegalArgumentException("Internal error: fresh properties in property assertions are not compatible with incremental ABox loading!");
}
示例14: getPropertyChainMap
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
private Map<OWLObjectProperty,Set<List<OWLObjectProperty>>> getPropertyChainMap() {
if (pcMap == null) {
pcMap = new HashMap<OWLObjectProperty,Set<List<OWLObjectProperty>>>();
for (OWLSubPropertyChainOfAxiom a : sourceOntology.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) {
//LOG.info("CHAIN:"+a+" // "+a.getPropertyChain().size());
if (a.getPropertyChain().size() == 2) {
OWLObjectPropertyExpression p1 = a.getPropertyChain().get(0);
OWLObjectPropertyExpression p2 = a.getPropertyChain().get(1);
//LOG.info(" xxCHAIN:"+p1+" o "+p2);
if (p1 instanceof OWLObjectProperty && p2 instanceof OWLObjectProperty) {
List<OWLObjectProperty> list = new Vector<OWLObjectProperty>();
list.add((OWLObjectProperty) p2);
list.add((OWLObjectProperty) a.getSuperProperty());
if (!pcMap.containsKey(p1))
pcMap.put((OWLObjectProperty) p1, new HashSet<List<OWLObjectProperty>>());
pcMap.get((OWLObjectProperty) p1).add(list);
//LOG.info(" xxxCHAIN:"+p1+" ... "+list);
}
}
else {
// TODO
}
}
}
return pcMap;
}
示例15: getStrings
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; //导入依赖的package包/类
/**
* Returns the URIs of a list of object properties.
*
* @param properties object properties
* @return list of URIs
*/
protected static List<String> getStrings(List<OWLObjectPropertyExpression> properties) {
List<String> strs = new ArrayList<>();
for (OWLObjectPropertyExpression op : properties) {
strs.add(getString(op));
}
return strs;
}