本文整理汇总了Java中org.semanticweb.owlapi.reasoner.NodeSet.getFlattened方法的典型用法代码示例。如果您正苦于以下问题:Java NodeSet.getFlattened方法的具体用法?Java NodeSet.getFlattened怎么用?Java NodeSet.getFlattened使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.semanticweb.owlapi.reasoner.NodeSet
的用法示例。
在下文中一共展示了NodeSet.getFlattened方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例3: GoIEPRestrictionsRule
import org.semanticweb.owlapi.reasoner.NodeSet; //导入方法依赖的package包/类
public GoIEPRestrictionsRule(OWLGraphWrapper graph, TraversingEcoMapper eco) {
this.message = MESSAGE;
this.violationType = ViolationType.Warning;
evidences = eco.getAllValidEvidenceIds("IEP", true);
classSubSet = new HashSet<String>();
OWLClass rootClass = graph.getOWLClassByIdentifier("GO:0008150");
OWLReasonerFactory factory = new ElkReasonerFactory();
OWLReasoner reasoner = factory.createReasoner(graph.getSourceOntology());
try {
NodeSet<OWLClass> nodeSet = reasoner.getSubClasses(rootClass, false);
for(OWLClass cls : nodeSet.getFlattened()) {
if (cls.isBottomEntity() || cls.isTopEntity()) {
continue;
}
String oboId = graph.getIdentifier(cls);
if (oboId != null) {
classSubSet.add(oboId);
}
}
}
finally {
reasoner.dispose();
}
}
示例4: GoIPICatalyticActivityRestrictionsRule
import org.semanticweb.owlapi.reasoner.NodeSet; //导入方法依赖的package包/类
public GoIPICatalyticActivityRestrictionsRule(OWLGraphWrapper graph, TraversingEcoMapper eco) {
this.message = MESSAGE;
this.violationType = ViolationType.Warning;
evidences = eco.getAllValidEvidenceIds("IPI", true);
classSubSet = new HashSet<String>();
OWLClass rootClass = graph.getOWLClassByIdentifier("GO:0003824"); // catalytic activity
OWLReasonerFactory factory = new ElkReasonerFactory();
OWLReasoner reasoner = factory.createReasoner(graph.getSourceOntology());
try {
NodeSet<OWLClass> nodeSet = reasoner.getSubClasses(rootClass, false);
for(OWLClass cls : nodeSet.getFlattened()) {
if (cls.isBottomEntity() || cls.isTopEntity()) {
continue;
}
String oboId = graph.getIdentifier(cls);
if (oboId != null) {
classSubSet.add(oboId);
}
}
}
finally {
reasoner.dispose();
}
}
示例5: executeQuery
import org.semanticweb.owlapi.reasoner.NodeSet; //导入方法依赖的package包/类
/**
* Execute the DL query on the given ontology graph. Uses the factory to create
* the {@link OWLReasoner} for an internal query ontology.
*
* @param queryObject
* @param ontology
* @param reasonerFactory
* @return set of {@link OWLClass} which
*/
static Set<OWLClass> executeQuery(OWLClassExpression queryObject, OWLOntology ontology,
OWLReasonerFactory reasonerFactory)
{
Set<OWLClass> subset = new HashSet<OWLClass>();
LOG.info("Create reasoner for query ontology.");
// Create an instance of an OWL API reasoner
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
try {
LOG.info("Start evaluation for DL query subclass of: "+queryObject);
NodeSet<OWLClass> node = reasoner.getSubClasses(queryObject, false);
if (node != null) {
Set<OWLClass> classes = node.getFlattened();
for (OWLClass owlClass : classes) {
if (!owlClass.isBottomEntity() && !owlClass.isTopEntity()) {
subset.add(owlClass);
}
}
LOG.info("Number of found classes for dl query subclass of: "+classes.size());
}
return subset;
}
finally {
reasoner.dispose();
}
}
示例6: getType
import org.semanticweb.owlapi.reasoner.NodeSet; //导入方法依赖的package包/类
private OWLClassExpression getType(OWLNamedIndividual individual) {
NodeSet<OWLClass> types = reasoner.getTypes(individual, true);
if (types.isEmpty() || types.isBottomSingleton() || types.isTopSingleton()) {
return null;
}
Set<OWLClass> set = types.getFlattened();
if (set.size() == 1) {
return set.iterator().next();
}
OWLDataFactory fac = graph.getManager().getOWLDataFactory();
OWLObjectIntersectionOf intersectionOf = fac.getOWLObjectIntersectionOf(set);
return intersectionOf;
}
示例7: run
import org.semanticweb.owlapi.reasoner.NodeSet; //导入方法依赖的package包/类
public void run(Wolpertinger wolpertinger, Configuration configuration, StatusOutput status, PrintWriter output) {
OWLClass owlClass = wolpertinger.getClass(conceptName);
NodeSet<OWLClass> subconcepts = wolpertinger.getSubClasses(owlClass, direct);
for (OWLClass cl : subconcepts.getFlattened()) {
output.println(cl);
}
output.flush();
}
示例8: setOntologies
import org.semanticweb.owlapi.reasoner.NodeSet; //导入方法依赖的package包/类
public void setOntologies(Set<OWLOntology> ontologies) {
reasoner = modelManager.getOWLReasonerManager().getCurrentReasoner();
if (reasoner != null) {
isClassified = true;
}
if (!isClassified) {
return;
}
setFireEvents(false);
conceptsToView.clear();
setUp();
Set<OWLObjectProperty> allObjectProperties = reasoner.getRootOntology().getObjectPropertiesInSignature(true);
for (OWLNamedIndividual ind : reasoner.getInstances( skosConcept, false).getFlattened()) {
for (OWLObjectProperty prop : allObjectProperties) {
if (prop.equals(getManager().getOWLDataFactory().getOWLTopObjectProperty())) {
continue;
}
NodeSet<OWLNamedIndividual> values = reasoner.getObjectPropertyValues(ind, prop);
for (OWLNamedIndividual relInd : values.getFlattened()) {
OWLObjectPropertyAssertionAxiom ax = getManager().getOWLDataFactory().getOWLObjectPropertyAssertionAxiom(prop, ind, relInd);
ax.accept(getSKOSFilter());
}
}
conceptsToView.add(ind);
}
for (OWLOntology ont : ontologies) {
// for (OWLClassAssertionAxiom axiom : ont.getAxioms(AxiomType.CLASS_ASSERTION)) {
// if (axiom.getDescription().equals(skosConcept)) {
// conceptsToView.add(axiom.getIndividual());
// }
// }
updateRoots(ont, conceptsToView);
}
fireHierarchyChanged();
setFireEvents(true);
}
示例9: assertAboxInferences
import org.semanticweb.owlapi.reasoner.NodeSet; //导入方法依赖的package包/类
@CLIMethod("--assert-abox-inferences")
public void assertAboxInferences(Opts opts) throws Exception {
opts.info("", "Finds all inferred OPEs and ClassAssertions and asserts them. Does not handle DPEs. Resulting ontology can be used for sparql queries");
boolean isNew = false;
while (opts.hasOpts()) {
if (opts.nextEq("-n|--new")) {
isNew = true;
}
else
break;
}
Set<OWLAxiom> newAxioms = new HashSet<OWLAxiom>();
OWLOntology ont = g.getSourceOntology();
// TODO : move this to a utility class
OWLOntologyManager mgr = ont.getOWLOntologyManager();
OWLDataFactory df = mgr.getOWLDataFactory();
LOG.info("Initial axioms:"+ont.getAxioms(true).size());
for (OWLNamedIndividual ind : ont.getIndividualsInSignature(Imports.INCLUDED)) {
//LOG.info("Checking: "+ind);
for (OWLObjectProperty p : ont.getObjectPropertiesInSignature(Imports.INCLUDED)) {
NodeSet<OWLNamedIndividual> vs = reasoner.getObjectPropertyValues(ind, p);
for (OWLNamedIndividual v : vs.getFlattened()) {
//LOG.info("NEW: "+ind+" -> "+p+" -> "+v);
newAxioms.add(df.getOWLObjectPropertyAssertionAxiom(p, ind, v));
}
}
for (OWLClass c : reasoner.getTypes(ind, false).getFlattened()) {
newAxioms.add(df.getOWLClassAssertionAxiom(c, ind));
//LOG.info("NEW: "+ind+" :: "+c);
}
}
OWLPrettyPrinter owlpp = new OWLPrettyPrinter(g);
for (OWLAxiom a : newAxioms) {
LOG.info("NEW: "+owlpp.render(a));
}
LOG.info("# OF NEW AXIOMS: "+newAxioms.size());
if (isNew) {
g.setSourceOntology(mgr.createOntology());
}
mgr.addAxioms(g.getSourceOntology(), newAxioms);
}