本文整理匯總了Java中org.semanticweb.owlapi.model.OWLDataFactory.getOWLObjectIntersectionOf方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLDataFactory.getOWLObjectIntersectionOf方法的具體用法?Java OWLDataFactory.getOWLObjectIntersectionOf怎麽用?Java OWLDataFactory.getOWLObjectIntersectionOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLDataFactory
的用法示例。
在下文中一共展示了OWLDataFactory.getOWLObjectIntersectionOf方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTinyOntology8
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
* @throws OWLOntologyCreationException
* if something goes wrong with the ontology creation
*/
@Test
public void testTinyOntology8() throws OWLOntologyCreationException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
Set<OWLAxiom> axiomSet = new HashSet<>();
OWLClass a = createNewClass(factory, "A");
OWLClass b = createNewClass(factory, "B");
OWLClass ab = createNewClass(factory, "AB");
Set<OWLClass> aAndBSet = new HashSet<>();
aAndBSet.add(a);
aAndBSet.add(b);
OWLClassExpression aAndB = factory.getOWLObjectIntersectionOf(aAndBSet);
axiomSet.add(factory.getOWLEquivalentClassesAxiom(ab, aAndB));
OWLOntology ontology = manager.createOntology(axiomSet);
JcelReasonerFactory reasonerFactory = new JcelReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
Set<OWLClass> expectedSet = new HashSet<>();
expectedSet.add(ab);
Node<OWLClass> expected = new OWLClassNode(expectedSet);
Assert.assertEquals(expected, reasoner.getEquivalentClasses(ab));
Assert.assertEquals(expected, reasoner.getEquivalentClasses(aAndB));
}
示例2: getClassExpressionFor
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
protected OWLClassExpression getClassExpressionFor(OWLDataFactory factory,OWLAnonymousIndividual node,OWLAnonymousIndividual predecessor) {
Set<OWLAnonymousIndividual> successors=edges.get(node);
if (successors==null||(successors.size()==1&&successors.iterator().next()==predecessor)) {
// the tree consists of a single node
if (!nodelLabels.containsKey(node)) {
return factory.getOWLThing();
}
else if (nodelLabels.get(node).size()==1) {
return nodelLabels.get(node).iterator().next();
}
else {
return factory.getOWLObjectIntersectionOf(nodelLabels.get(node));
}
}
Set<OWLClassExpression> concepts=new HashSet<OWLClassExpression>();
for (OWLAnonymousIndividual successor : successors) {
OWLObjectProperty op;
Edge pair=new Edge(node,successor);
if (edgeOPLabels.containsKey(pair)) {
op=edgeOPLabels.get(pair);
}
else {
pair=new Edge(successor,node);
if (!edgeOPLabels.containsKey(pair)) {
throw new RuntimeException("Internal error: some edge in the forest of anonymous individuals has no edge label although it should. ");
}
else {
op=edgeOPLabels.get(pair);
}
}
concepts.add(factory.getOWLObjectSomeValuesFrom(op,getClassExpressionFor(factory,successor,node)));
}
return concepts.size()==1 ? concepts.iterator().next() : factory.getOWLObjectIntersectionOf(concepts);
}
示例3: getLCS
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public OWLClassExpression getLCS() {
OWLDataFactory df = simEngine.getGraph().getDataFactory();
OWLObjectProperty topRel = df.getOWLTopObjectProperty();
Set<OWLClassExpression> ces = new HashSet<OWLClassExpression>();
for (OWLObject obj : lcsIntersectionSet) {
if (obj instanceof OWLClassExpression)
ces.add(df.getOWLObjectSomeValuesFrom(topRel,
(OWLClassExpression) obj));
}
OWLClassExpression ce =
df.getOWLObjectIntersectionOf(ces);
return ce;
}
示例4: shouldGetEdgeToSourceExpression
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
* Test {@link OWLGraphWrapperEdgesExtended#edgeToSourceExpression(OWLGraphEdge)}
*/
@Test
public void shouldGetEdgeToSourceExpression() throws OWLOntologyCreationException,
OBOFormatParserException, IOException {
ParserWrapper parserWrapper = new ParserWrapper();
OWLOntology ont = parserWrapper.parse(this.getClass().getResource(
"/graph/gciRelRetrieval.obo").getFile());
OWLGraphWrapper wrapper = new OWLGraphWrapper(ont);
OWLObjectProperty partOf = wrapper.getOWLObjectPropertyByIdentifier("BFO:0000050");
OWLClass cls1 = wrapper.getOWLClassByIdentifier("ID:1");
OWLClass cls2 = wrapper.getOWLClassByIdentifier("ID:2");
OWLClass taxon1 = wrapper.getOWLClassByIdentifier("NCBITaxon:9606");
OWLGraphEdge edge = new OWLGraphEdge(cls2, cls1, partOf, Quantifier.SOME, ont,
null, taxon1, partOf);
OWLDataFactory factory = ont.getOWLOntologyManager().getOWLDataFactory();
OWLClassExpression expectedExpression = factory.getOWLObjectIntersectionOf(
cls2, factory.getOWLObjectSomeValuesFrom(partOf, taxon1));
assertEquals("Incorrect edgeToSourceExpression returned", expectedExpression,
wrapper.edgeToSourceExpression(edge));
//non-GCI
edge = new OWLGraphEdge(cls2, cls1, ont);
assertEquals("Incorrect edgeToSourceExpression returned", cls2,
wrapper.edgeToSourceExpression(edge));
}
示例5: getType
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的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;
}
示例6: visit
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
@Override
public OWLAxiom visit(GCI1Axiom axiom) {
Objects.requireNonNull(axiom);
OWLClass owlLeftSubClass = translator.getTranslationRepository().getOWLClass(axiom.getLeftSubClass());
OWLClass owlRightSubClass = translator.getTranslationRepository().getOWLClass(axiom.getRightSubClass());
OWLClass owlSuperClass = translator.getTranslationRepository().getOWLClass(axiom.getSuperClass());
Set<OWLAnnotation> owlAnnotations = translateAnnotations(axiom.getAnnotations());
OWLDataFactory dataFactory = ontology.getOWLOntologyManager().getOWLDataFactory();
Set<OWLClass> set = new HashSet<>();
set.add(owlLeftSubClass);
set.add(owlRightSubClass);
OWLClassExpression owlObjectIntersectionOf = dataFactory.getOWLObjectIntersectionOf(set);
return dataFactory.getOWLSubClassOfAxiom(owlObjectIntersectionOf, owlSuperClass, owlAnnotations);
}
示例7: main
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws OWLOntologyCreationException {
OWLOntologyManager man = OWLManager.createOWLOntologyManager();
OWLDataFactory dataFactory = man.getOWLDataFactory();
// Load your ontology.
OWLOntology ont = man.loadOntologyFromOntologyDocument(new File(
"c:/ontologies/ontology.owl"));
// Create an ELK reasoner.
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(ont);
// Create your desired query class expression. In this example we
// will query ObjectIntersectionOf(A ObjectSomeValuesFrom(R B)).
PrefixManager pm = new DefaultPrefixManager("http://example.org/");
OWLClass A = dataFactory.getOWLClass(":A", pm);
OWLObjectProperty R = dataFactory.getOWLObjectProperty(":R", pm);
OWLClass B = dataFactory.getOWLClass(":B", pm);
OWLClassExpression query = dataFactory.getOWLObjectIntersectionOf(A,
dataFactory.getOWLObjectSomeValuesFrom(R, B));
// Create a fresh name for the query.
OWLClass newName = dataFactory.getOWLClass(IRI.create("temp001"));
// Make the query equivalent to the fresh class
OWLAxiom definition = dataFactory.getOWLEquivalentClassesAxiom(newName,
query);
man.addAxiom(ont, definition);
// Remember to either flush the reasoner after the ontology change
// or create the reasoner in non-buffering mode. Note that querying
// a reasoner after an ontology change triggers re-classification of
// the whole ontology which might be costly. Therefore, if you plan
// to query for multiple complex class expressions, it will be more
// efficient to add the corresponding definitions to the ontology at
// once before asking any queries to the reasoner.
reasoner.flush();
// You can now retrieve subclasses, superclasses, and instances of
// the query class by using its new name instead.
reasoner.getSubClasses(newName, true);
reasoner.getSuperClasses(newName, true);
reasoner.getInstances(newName, false);
// After you are done with the query, you should remove the definition
man.removeAxiom(ont, definition);
// You can now add new definitions for new queries in the same way
// After you are done with all queries, do not forget to free the
// resources occupied by the reasoner
reasoner.dispose();
}
示例8: generateAxioms
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
private Map<Bioentity, Set<OWLClass>> generateAxioms(OWLOntology generatedContainer, Map<Bioentity, ? extends Collection<GeneAnnotation>> annMap, Map<Bioentity, Set<OWLClass>> allExistingAnnotations, Map<OWLClass, PredicationDataContainer> sourceData) {
final OWLGraphWrapper g = getGraph();
final OWLDataFactory f = g.getDataFactory();
final OWLOntologyManager m = g.getManager();
Map<Bioentity, Set<OWLClass>> allGeneratedClasses = new HashMap<Bioentity, Set<OWLClass>>();
for(Entry<Bioentity, ? extends Collection<GeneAnnotation>> entry : annMap.entrySet()) {
Set<OWLClass> generatedClasses = new HashSet<OWLClass>();
Set<OWLClass> existingAnnotations = new HashSet<OWLClass>();
Bioentity e = entry.getKey();
for (GeneAnnotation ann : entry.getValue()) {
// skip ND evidence annotations
String evidenceString = ann.getShortEvidence();
if ("ND".equals(evidenceString)) {
continue;
}
// parse annotation cls
String annotatedToClassString = ann.getCls();
OWLClass annotatedToClass = g.getOWLClassByIdentifierNoAltIds(annotatedToClassString);
if (annotatedToClass == null) {
LOG.warn("Skipping annotation for prediction. Could not find cls for id: "+annotatedToClassString);
continue;
}
// add annotation class (and its super classes as known annotation)
existingAnnotations.add(annotatedToClass);
existingAnnotations.addAll(reasoner.getSuperClasses(annotatedToClass, false).getFlattened());
// parse c16 expressions
List<List<ExtensionExpression>> extensionExpressionGroups = ann.getExtensionExpressions();
if (extensionExpressionGroups != null && !extensionExpressionGroups.isEmpty()) {
for (List<ExtensionExpression> group : extensionExpressionGroups) {
Set<OWLClassExpression> units = new HashSet<OWLClassExpression>();
for (ExtensionExpression ext : group) {
String extClsString = ext.getCls();
String extRelString = ext.getRelation();
OWLClass extCls = f.getOWLClass(g.getIRIByIdentifier(extClsString));
OWLObjectProperty extRel = g.getOWLObjectPropertyByIdentifier(extRelString);
if (extRel == null) {
continue;
}
units.add(f.getOWLObjectSomeValuesFrom(extRel, extCls));
}
if (units.isEmpty()) {
continue;
}
units.add(annotatedToClass);
final OWLClassExpression groupExpression = f.getOWLObjectIntersectionOf(units);
OWLClass generatedClass = f.getOWLClass(IRI.generateDocumentIRI());
OWLAxiom axiom = f.getOWLEquivalentClassesAxiom(generatedClass, groupExpression);
m.addAxiom(generatedContainer, axiom);
generatedClasses.add(generatedClass);
sourceData.put(generatedClass, new PredicationDataContainer(ann, annotatedToClass, evidenceString, groupExpression, group));
}
}
}
if (generatedClasses.isEmpty() == false) {
allGeneratedClasses.put(e, generatedClasses);
allExistingAnnotations.put(e, existingAnnotations);
}
}
return allGeneratedClasses;
}
示例9: edgeToSourceExpression
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
* Translates the source of an {@code OWLGraphEdge} into an {@code OWLClassExpression}
* (but, as the method {@link OWLGraphEdge#getSource()} returns an {@code OWLObject},
* this method also returns an {@code OWLObject}). This is the equivalent method
* to {@link OWLGraphWrapperEdges#edgeToTargetExpression(OWLGraphEdge)},
* but for the source.
* <p>
* This is useful when an {@code OWLGraphEdge} corresponds to an OBO gci_relation
* ({@link OWLGraphEdge#isGCI()} returns {@code true}). In that case, the returned value
* is an {@code OWLObjectIntersectionOf}. If it is not a GCI, the returned value
* is equal to {@link OWLGraphEdge#getSource()}.
*
* @param e The {@code OWLGraphEdge} for which we want to translate the source
* into an {@code OWLClassExpression}.
* @return An {@code OWLObject} corresponding to the source of {@code e}.
*/
public OWLObject edgeToSourceExpression(OWLGraphEdge e) {
if (!e.isGCI()) {
return e.getSource();
}
OWLDataFactory factory = e.getOntology().getOWLOntologyManager().getOWLDataFactory();
return factory.getOWLObjectIntersectionOf((OWLClassExpression) e.getSource(),
factory.getOWLObjectSomeValuesFrom(e.getGCIRelation(), e.getGCIFiller()));
}