本文整理汇总了Java中org.semanticweb.owlapi.reasoner.NodeSet类的典型用法代码示例。如果您正苦于以下问题:Java NodeSet类的具体用法?Java NodeSet怎么用?Java NodeSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeSet类属于org.semanticweb.owlapi.reasoner包,在下文中一共展示了NodeSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendEvent
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
@Override
public void sendEvent(SemanticEvent se) {
Set<String> triggeredFilters = new HashSet<String>();
// add event to ontology
manager.addAxioms(ontology, se.getAxioms());
// extract types event
reasoner.flush();
NodeSet<OWLClass> inferedClasses = reasoner.getTypes(se.getMessage(), false);
for (OWLClass owlclss : inferedClasses.getFlattened()) {
String clss = owlclss.getIRI().toString();
if (eventDefinitions.contains(clss)) {
triggeredFilters.add(clss);
}
}
se.setTriggeredFilterIRIs(triggeredFilters);
//send event back to engie
obep.sendEvent(se);
}
示例2: extractMeaningfulRoots
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
/**
* @deprecated
*/
private Set<Integer> extractMeaningfulRoots(NodeSet<OWLClass> nodes, int level){
Set<Integer> mroots=new HashSet<Integer>();
OWLClassNodeSet mrootsClass = new OWLClassNodeSet();
for (Node<OWLClass> node : nodes.getNodes()){
for (Node<OWLClass> topNode : reasoner.getSubClasses(node.getRepresentativeElement(), true)){
mrootsClass.addNode(topNode);
if (class2identifier.containsKey(topNode.getRepresentativeElement())){
mroots.add(class2identifier.get(topNode.getRepresentativeElement()));
}
}
}
if (mroots.size()>=minNumberOfRoots || level==3){ //we want to avoid infinite recursion
return mroots;
}
else {
return extractMeaningfulRoots(mrootsClass, level+1);
}
}
示例3: extractHierarchyLevel
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
/**
* @deprecated
*/
private void extractHierarchyLevel(NodeSet<OWLClass> classes, int level){
//TOP CONCEPTS
//NodeSet<OWLClass> topClasses = reasoner.getSubClasses(reasoner.getTopClassNode().getRepresentativeElement(), true);
int ident;
for (Node<OWLClass> node : classes.getNodes()){
if (class2identifier.containsKey(node.getRepresentativeElement())){
ident = class2identifier.get(node.getRepresentativeElement());
//We add the deeper level
if (index.getClassIndex(ident).getHierarchyLevel()<level){
index.getClassIndex(ident).setHierarchyLevel(level);
}
}
extractHierarchyLevel(reasoner.getSubClasses(node.getRepresentativeElement(), true), level+1);
}
}
示例4: getDisjointClasses
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
public NodeSet<OWLClass> getDisjointClasses(OWLClassExpression ce) {
ensurePrepared();
OWLClassNodeSet nodeSet = new OWLClassNodeSet();
if (!ce.isAnonymous()) {
for (OWLOntology ontology : getRootOntology().getImportsClosure()) {
for (OWLDisjointClassesAxiom ax : ontology.getDisjointClassesAxioms(ce.asOWLClass())) {
for (OWLClassExpression op : ax.getClassExpressions()) {
if (!op.isAnonymous()) {
nodeSet.addNode(getEquivalentClasses(op));
}
}
}
}
}
return nodeSet;
}
示例5: skipsExplicitAssertionValueIfThereIsTheSameAssertionAlsoWithInference
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
@Test
public void skipsExplicitAssertionValueIfThereIsTheSameAssertionAlsoWithInference() {
final URI opUri = URI.create("http://krizik.felk.cvut.cz/PropertyOne");
final Assertion opAsserted = Assertion.createObjectPropertyAssertion(opUri, false);
final Assertion opInferred = Assertion.createObjectPropertyAssertion(opUri, true);
final OWLObjectProperty owlOp = dataFactory.getOWLObjectProperty(IRI.create(opUri));
final Set<Node<OWLNamedIndividual>> indSet = new HashSet<>();
final OWLNamedIndividual commonInd = dataFactory.getOWLNamedIndividual(
IRI.create("http://krizik.felk.cvut.cz/IndividialOne"));
indSet.add(NodeFactory.getOWLNamedIndividualNode(commonInd));
indSet.add(NodeFactory.getOWLNamedIndividualNode(
dataFactory.getOWLNamedIndividual(IRI.create("http://krizik.felk.cvut.cz/IndividialTwo"))));
final NodeSet<OWLNamedIndividual> individuals = new OWLNamedIndividualNodeSet(indSet);
when(reasonerMock.getObjectPropertyValues(individual, owlOp)).thenReturn(individuals);
final Stream<OWLObjectPropertyAssertionAxiom> axioms = Stream.of(dataFactory.getOWLObjectPropertyAssertionAxiom(
dataFactory.getOWLObjectProperty(IRI.create(opUri)), individual, commonInd));
when(ontologyMock.objectPropertyAssertionAxioms(individual)).thenReturn(axioms);
when(ontologyMock.dataPropertyAssertionAxioms(any())).thenReturn(Stream.empty());
when(ontologyMock.annotationAssertionAxioms(any())).thenReturn(Stream.empty());
final Collection<Axiom<?>> result = axiomLoader.findAxioms(descriptor(opAsserted, opInferred));
assertEquals(indSet.size(), result.size());
for (Axiom ax : result) {
assertEquals(opInferred, ax.getAssertion());
}
}
示例6: getDifferentIndividuals
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
public NodeSet<OWLNamedIndividual> getDifferentIndividuals(
OWLNamedIndividual namedIndividual) {
checkPreConditions(namedIndividual);
if (!m_isConsistent) {
Node<OWLNamedIndividual> node = new OWLNamedIndividualNode(
getAllNamedIndividuals());
return new OWLNamedIndividualNodeSet(Collections.singleton(node));
}
Individual individual = H(namedIndividual);
Tableau tableau = getTableau();
Set<Individual> result = new HashSet<Individual>();
for (Individual potentiallyDifferentIndividual : m_dlOntology
.getAllIndividuals())
if (isResultRelevantIndividual(potentiallyDifferentIndividual)
&& !individual.equals(potentiallyDifferentIndividual))
if (!tableau.isSatisfiable(true, true, Collections
.singleton(Atom.create(Equality.INSTANCE, individual,
potentiallyDifferentIndividual)), null, null,
null, null, new ReasoningTaskDescription(true,
"is {0} different from {1}", individual,
potentiallyDifferentIndividual)))
result.add(potentiallyDifferentIndividual);
return sortBySameAsIfNecessary(result);
}
示例7: getObjectPropertyValues
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的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: getSubClasses
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
public Set<OWLClass> getSubClasses(String expression) {
// Convert the class expression (string) into an OWL class expression,
// which is used to retrieved the named class.
// In principle, this allows for parsing arbitrary class expressions in
// OWL, not just named classes (for which a simple
// OWLDataFactory.getOWLClass(..) would do. However, Elk currently
// doesn't yet implement getSubClasses for class expressions.
// It will be supported in a future release.
OWLClassExpression classExpression = parseClassExpression(expression
.trim());
// The flag "true" means that we want to retrieve only the direct
// subclasses. The flag set in "false" should retrieve the descendant
// classes.
NodeSet<OWLClass> subClasses = reasoner.getSubClasses(classExpression,
true);
// IMPORTANT: This method will stop the reasoning process and free the
// Elk threads/workers.
reasoner.dispose();
return subClasses.getFlattened();
}
示例9: getDisjointDataProperties
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
@Override
public NodeSet<OWLDataProperty> getDisjointDataProperties(
OWLDataPropertyExpression arg0)
throws InconsistentOntologyException, FreshEntitiesException,
ReasonerInterruptedException, TimeOutException {
LOGGER_.trace("getDisjointDataProperties(OWLDataPropertyExpression)");
checkInterrupted();
// TODO Provide implementation
throw unsupportedOwlApiMethod(
"getDisjointDataProperties(OWLDataPropertyExpression)");
}
示例10: OwlApiClassExpressionInstancesQueryTest
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
public OwlApiClassExpressionInstancesQueryTest(
final QueryTestManifest<OWLClassExpression, RelatedEntitiesTestOutput<OWLNamedIndividual>> manifest) {
super(manifest,
new OwlApiReasoningTestDelegate<RelatedEntitiesTestOutput<OWLNamedIndividual>>(
manifest) {
@Override
public RelatedEntitiesTestOutput<OWLNamedIndividual> getActualOutput()
throws Exception {
final NodeSet<OWLNamedIndividual> subNodes = getReasoner()
.getInstances(manifest.getInput().getQuery(),
true);
return new OwlApiRelatedEntitiesTestOutput<OWLNamedIndividual>(
subNodes);
}
@Override
public Class<? extends Exception> getInterruptionExceptionClass() {
return ReasonerInterruptedException.class;
}
});
}
示例11: getTypes
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
public NodeSet<OWLClass> getTypes(OWLNamedIndividual namedIndividual,
boolean direct) {
checkPreConditions(namedIndividual);
Set<HierarchyNode<AtomicConcept>> result;
if (!isDefined(namedIndividual)) {
classifyClasses();
result = new HashSet<HierarchyNode<AtomicConcept>>();
result.add(m_atomicConceptHierarchy.getTopNode());
} else {
if (direct)
classifyClasses();
initialiseClassInstanceManager();
if (direct)
m_instanceManager
.setToClassifiedConceptHierarchy(m_atomicConceptHierarchy);
result = m_instanceManager.getTypes(H(namedIndividual), direct);
}
return atomicConceptHierarchyNodesToNodeSet(result);
}
示例12: hasFilterClass
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
/**
* Check that there is an axiom, which use a class (in its signature) that
* has a ancestor in the root term set.
*
* @param axioms set to check
* @param rootTerms set root of terms
* @return boolean
*/
private boolean hasFilterClass(Set<OWLClassAxiom> axioms, Set<OWLClass> rootTerms) {
if (axioms != null && !axioms.isEmpty()) {
for (OWLClassAxiom ax : axioms) {
if (ax instanceof OWLEquivalentClassesAxiom) {
Set<OWLClass> signature = ax.getClassesInSignature();
for (OWLClass sigCls : signature) {
NodeSet<OWLClass> superClasses = reasoner.getSuperClasses(sigCls, false);
for(OWLClass root : rootTerms) {
if (superClasses.containsEntity(root)) {
return true;
}
}
}
}
}
}
return false;
}
示例13: loadLinks
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
private void loadLinks() throws Exception {
final OWLReasoner reasoner = getReasoner();
if (!reasoner.isConsistent()) throw new Exception("Ontology is inconsistent");
Transaction tx = graphDb.beginTx();
try {
ontology.classesInSignature().forEach((OWLClass c) -> {
Node thingNode = getOrCreateWithUniqueFactory(OWL_THING);
String classString = c.toString(), classLabel = classString;
if (classString.contains(HASH)) {
classString = classString.substring(classString.indexOf(HASH)+1, classString.lastIndexOf(GREATER_THAN));
}
Node classNode = getOrCreateWithUniqueFactory(classString);
NodeSet<OWLClass> superClasses = reasoner.getSuperClasses(c, true);
if (superClasses.isEmpty()) {
classNode.createRelationshipTo(thingNode, RelationshipType.withName(IS_A));
}
else {
for (org.semanticweb.owlapi.reasoner.Node<OWLClass> parentOWLNode: superClasses) {
OWLClassExpression parent = parentOWLNode.getRepresentativeElement();
String parentString = parent.toString();
if (parentString.contains(HASH)) {
parentString = parentString.substring(parentString.indexOf(HASH)+1, parentString.lastIndexOf(GREATER_THAN));
}
Node parentNode = getOrCreateWithUniqueFactory(parentString);
classNode.createRelationshipTo(parentNode, RelationshipType.withName(PART_OF));
}
}
});
tx.success();
}
finally {
tx.close();
}
}
示例14: getDisjointClasses
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
/**
* Getting all disjoint classes is costly. We get only explicit disjointness.
* We will complete with questions (A intersection B) later if necessary
*/
public NodeSet<OWLClass> getDisjointClasses(OWLClassExpression ce) {
OWLClassNodeSet nodeSet = new OWLClassNodeSet();
if (!ce.isAnonymous()) {
for (OWLOntology ontology : getRootOntology().getImportsClosure()) {
nodeSet.addAllNodes(DisjointnessAxiomExtractor.getExplicitOWLDisjointnessAxioms(this, ontology, ce.asOWLClass()).getNodes());
nodeSet.addAllNodes(DisjointnessAxiomExtractor.getExplicitOWLDisjointnessAxioms(this, ontology, ce.asOWLClass()).getNodes());
nodeSet.addAllNodes(DisjointnessAxiomExtractor.getExplicitOWLDisjointnessAxioms(this, ontology, ce.asOWLClass()).getNodes());
}
}
return nodeSet;
/*if (!ce.isAnonymous()) {
for (OWLOntology ontology : getRootOntology().getImportsClosure()) {
for (OWLDisjointClassesAxiom ax : ontology.getDisjointClassesAxioms(ce.asOWLClass())) {
for (OWLClassExpression op : ax.getClassExpressions()) {
if (!op.isAnonymous() && !op.equals(ce)) { //Op must be differnt to ce
nodeSet.addNode(getEquivalentClasses(op));
}
}
}
}
} */
}
示例15: getDifferentIndividuals
import org.semanticweb.owlapi.reasoner.NodeSet; //导入依赖的package包/类
@Override
public NodeSet<OWLNamedIndividual> getDifferentIndividuals(OWLNamedIndividual individual)
throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
TimeOutException {
Objects.requireNonNull(individual);
logger.finer("getDifferentIndividuals(" + individual + ")");
throw new UnsupportedReasonerOperationInBornException(
"Unsupported operation : getDifferentIndividuals(OWLNamedIndividual)");
}