本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntology.getAxioms方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntology.getAxioms方法的具體用法?Java OWLOntology.getAxioms怎麽用?Java OWLOntology.getAxioms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLOntology
的用法示例。
在下文中一共展示了OWLOntology.getAxioms方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testExactSynonym
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
private void testExactSynonym(OWLOntology ontology) {
IRI iri = IRI.create("http://www.geneontology.org/formats/oboInOwl#hasExactSynonym");
OWLDataFactory df = ontology.getOWLOntologyManager().
getOWLDataFactory();
OWLAnnotationProperty property = df.getOWLAnnotationProperty(iri);
assertTrue("Exact Synonym property in signature",
ontology.containsAnnotationPropertyInSignature(iri));
// Check axioms
Set<OWLAnnotationAxiom> axioms = ontology.getAxioms(property, Imports.EXCLUDED);
assertEquals("Count class axioms", 0, axioms.size());
// Check annotations
List<String> values = new ArrayList<String>();
values.add("AnnotationAssertion(rdfs:label <http://www.geneontology.org/formats/oboInOwl#hasExactSynonym> \"has_exact_synonym\"^^xsd:string)");
Set<OWLAnnotationAssertionAxiom> annotations =
ontology.getAnnotationAssertionAxioms(iri);
assertEquals("Count annotations for Exact", 1, annotations.size());
checkAnnotations(annotations, values);
}
示例2: getAllOWLObjectsByAltId
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Find all corresponding {@link OWLObject}s with an OBO-style alternate identifier.
* <p>
* WARNING: This methods scans all object annotations in all ontologies.
* This is an expensive method.
*
* @return map of altId to OWLObject (never null)
*/
public Map<String, OWLObject> getAllOWLObjectsByAltId() {
final Map<String, OWLObject> results = new HashMap<String, OWLObject>();
final OWLAnnotationProperty altIdProperty = getAnnotationProperty(OboFormatTag.TAG_ALT_ID.getTag());
if (altIdProperty == null) {
return Collections.emptyMap();
}
for (OWLOntology o : getAllOntologies()) {
Set<OWLAnnotationAssertionAxiom> aas = o.getAxioms(AxiomType.ANNOTATION_ASSERTION);
for (OWLAnnotationAssertionAxiom aa : aas) {
OWLAnnotationValue v = aa.getValue();
OWLAnnotationProperty property = aa.getProperty();
if (altIdProperty.equals(property) && v instanceof OWLLiteral) {
String altId = ((OWLLiteral)v).getLiteral();
OWLAnnotationSubject subject = aa.getSubject();
if (subject instanceof IRI) {
OWLObject obj = getOWLObject((IRI) subject);
if (obj != null) {
results.put(altId, obj);
}
}
}
}
}
return results;
}
示例3: testConversionToIndividuals
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
@Test
public void testConversionToIndividuals() throws Exception{
ParserWrapper pw = new ParserWrapper();
OWLOntology ont = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
OWLGraphWrapper g = new OWLGraphWrapper(ont);
g.addSupportOntology(pw.parse(getResourceIRIString("gorel.owl")));
GafObjectsBuilder builder = new GafObjectsBuilder();
GafDocument gafdoc = builder.buildDocument(getResource("mgi-exttest.gaf"));
GAFOWLBridge bridge = new GAFOWLBridge(g);
bridge.setGenerateIndividuals(false);
OWLOntology gafOnt = g.getManager().createOntology();
bridge.setTargetOntology(gafOnt);
bridge.setBasicAboxMapping(true);
bridge.translate(gafdoc);
OWLDocumentFormat owlFormat = new RDFXMLDocumentFormat();
g.getManager().saveOntology(gafOnt, owlFormat, IRI.create(new File("target/gaf-abox.owl")));
for (OWLAxiom ax : gafOnt.getAxioms()) {
//LOG.info("AX:"+ax);
}
}
示例4: printAxioms
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Print string representations of all the axioms in an ontology,
* one axiom statement per line. Sorted lists of axioms can be used
* to compare ontologies.
*
* @param ontology the ontology to print
* @param outputPath the path for the output file
* @throws IOException if it cannot write to the outputPath
*/
public static void printAxioms(OWLOntology ontology, String outputPath)
throws IOException {
logger.debug("Printing axioms...");
java.util.Set<OWLAxiom> axioms = ontology.getAxioms();
Iterator<OWLAxiom> iterator = axioms.iterator();
FileWriter fw = new FileWriter(outputPath);
BufferedWriter bw = new BufferedWriter(fw);
while(iterator.hasNext()) {
OWLAxiom axiom = iterator.next();
bw.write(axiom.toString() + "\n");
}
bw.close();
}
示例5: extract
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Extracts {@link PredicateVariableExtractor} rules.
*
* @param ot ontology
* @return extracted rules
*/
@Override
public List<Rule> extract(OWLOntology ot) {
List<Rule> list = new ArrayList<>();
// list of predicates in ontology
List<String> ps = new ArrayList<>();
ps.add(TOPOBJ);
ps.add(TOPDATA);
OWLEntity e;
String op;
// check all declarations
for (OWLDeclarationAxiom a : ot.getAxioms(AxiomType.DECLARATION)) {
e = a.getEntity();
if (e.isOWLObjectProperty()) {
// if it is a object property declaration, add it to the list
// and also add it as subproperty of owl:topObjectProperty
op = getString(e.asOWLObjectProperty());
ps.add(op);
list.add(new SubPropertyOf(op, TOPOBJ));
} else if (e.isOWLDataProperty()) {
// if it is a data property declaration, add it to the list
// and also add it as subproperty of owl:topDataProperty
op = getString(e.asOWLDataProperty());
ps.add(op);
list.add(new SubPropertyOf(op, TOPDATA));
}
}
list.add(new PredicateVariable(ps));
return list;
}
示例6: cleanActiveOntology
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
public void cleanActiveOntology() {
Set<OWLAxiom> axiomsToRemove;
for (OWLOntology o : activeOntology.getImportsClosure()) {
axiomsToRemove = new HashSet<OWLAxiom>();
for (OWLAxiom ax : o.getAxioms()) {
axiomsToRemove.add(ax);
}
owlOntologyManager.removeAxioms(o, axiomsToRemove);
// System.out.println("After: " + o.getAxiomCount());
}
}
示例7: check
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
protected void check(OWLClass owlClass, OWLGraphWrapper graph, List<CheckWarning> warnings, OWLPrettyPrinter pp) {
final Set<OWLOntology> allOntologies = graph.getAllOntologies();
for(OWLOntology ontology : allOntologies){
Set<OWLClassAxiom> axioms = ontology.getAxioms(owlClass, Imports.EXCLUDED);
if (axioms != null && !axioms.isEmpty()) {
// check axioms
for (OWLClassAxiom axiom : axioms) {
Set<OWLClass> signature = axiom.getClassesInSignature();
for (OWLClass signatureClass : signature) {
if (graph.isObsolete(signatureClass)) {
StringBuilder sb = new StringBuilder();
sb.append("Obsolete class ");
String id = graph.getIdentifier(signatureClass);
if (id != null) {
sb.append(id);
String sigLabel = graph.getLabel(signatureClass);
if (sigLabel != null) {
sb.append(" '").append(sigLabel).append('\'');
}
}
else {
sb.append(signatureClass.getIRI());
}
sb.append(" in axiom: ");
sb.append(pp.render(axiom));
warnings.add(new CheckWarning(getID(), sb.toString() , isFatal(), owlClass.getIRI()));
}
}
}
}
}
}
示例8: getSuperProperties
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
public static Set<OWLAnnotationProperty> getSuperProperties(OWLAnnotationProperty subProp, Set<OWLOntology> ontologies) {
Set<OWLAnnotationProperty> result = new HashSet<OWLAnnotationProperty>();
for (OWLOntology ont : ontologies) {
for (OWLSubAnnotationPropertyOfAxiom ax : ont.getAxioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF)) {
if (ax.getSubProperty().equals(subProp)) {
result.add(ax.getSuperProperty());
}
}
}
return result;
}
示例9: filter
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
@Override
public void filter(OWLOntology ontology,
Collection<OWLAxiom> staticAxioms,
Collection<OWLAxiom> dynamicAxioms) {
for (OWLAxiom axiom : ontology.getAxioms()) {
if (STATIC_AXIOM_TYPES.contains(axiom.getAxiomType())) {
staticAxioms.add(axiom);
}
else {
dynamicAxioms.add(axiom);
}
}
}
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:15,代碼來源:OWLAPIRandomWalkIncrementalClassificationTest.java
示例10: findCardinalityConstraints
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Find the axioms with cardinality constraints. Creates also the weaker
* axioms as potential replacement.
*
* @param ontology
* @return reporter with the axiom potential changes
*/
public static CardinalityReporter findCardinalityConstraints(OWLOntology ontology) {
CardinalityReporter reporter = new CardinalityReporter(ontology);
for(OWLAxiom axiom : ontology.getAxioms()) {
axiom.accept(reporter);
}
return reporter;
}
示例11: testAxioms
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
@Test
public void testAxioms() throws Exception{
OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("caro.obo");
final StringWriter stringWriter = new StringWriter();
OWLGsonRenderer gr = new OWLGsonRenderer(new PrintWriter(stringWriter));
OWLOntology ont = wrapper.getSourceOntology();
for (OWLAxiom a : ont.getAxioms()) {
gr.render(a);
}
if (RENDER_FLAG) {
System.out.println(stringWriter.toString());
}
}
示例12: findTaggedEntities
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
public static Set<OWLObject> findTaggedEntities(OWLAnnotationProperty p, Set<OWLAnnotationValue> values, final OWLGraphWrapper graph) {
if (p == null || values == null || values.isEmpty()) {
return Collections.emptySet();
}
final Set<OWLObject> entities = new HashSet<OWLObject>();
Set<OWLOntology> allOntologies = graph.getAllOntologies();
for (OWLOntology ontology : allOntologies) {
Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAxioms(AxiomType.ANNOTATION_ASSERTION);
for (OWLAnnotationAssertionAxiom axiom : axioms) {
if (p.equals(axiom.getProperty()) && values.contains(axiom.getValue())) {
axiom.getSubject().accept(new OWLAnnotationSubjectVisitor(){
@Override
public void visit(IRI iri) {
OWLObject owlObject = graph.getOWLObject(iri);
if (owlObject != null) {
entities.add(owlObject);
}
}
@Override
public void visit(OWLAnonymousIndividual individual) {
// do nothing
}
});
}
}
}
return entities;
}
示例13: removeCardinalityConstraints
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Remove the cardinality constraints, by removing the axioms and replacing
* them with the weaker axioms without the constraints.
*
* @param ontology
*/
public static void removeCardinalityConstraints(OWLOntology ontology) {
CardinalityRemover remover = new CardinalityRemover(ontology);
for(OWLAxiom axiom : ontology.getAxioms()) {
axiom.accept(remover);
}
}
示例14: check
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
protected void check(OWLClass owlClass, OWLGraphWrapper graph, Map<String, OWLObject> altIds, List<CheckWarning> warnings, OWLPrettyPrinter pp) {
final Set<OWLOntology> allOntologies = graph.getAllOntologies();
for(OWLOntology ontology : allOntologies){
Set<OWLClassAxiom> axioms = ontology.getAxioms(owlClass, Imports.EXCLUDED);
if (axioms != null && !axioms.isEmpty()) {
// check axioms
for (OWLClassAxiom axiom : axioms) {
Set<OWLClass> signature = axiom.getClassesInSignature();
for (OWLClass signatureClass : signature) {
String identifier = graph.getIdentifier(signatureClass);
if (identifier != null) {
OWLObject replacement = altIds.get(identifier);
if (replacement != null) {
StringBuilder sb = new StringBuilder();
sb.append("Alternate Identifier ");
sb.append(identifier);
sb.append(" for main class ");
String replacementId = graph.getIdentifier(replacement);
if (replacementId != null) {
sb.append(replacementId);
String replacementLabel = graph.getLabel(replacement);
if (replacementLabel != null) {
sb.append(" '").append(replacementLabel).append('\'');
}
}
else {
sb.append(replacement);
}
sb.append(" in axiom: ");
sb.append(pp.render(axiom));
warnings.add(new CheckWarning(getID(), sb.toString() , isFatal(), owlClass.getIRI()));
}
}
}
}
}
}
}
示例15: getDiff
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
public static Diff getDiff(Diff diff) throws OWLOntologyCreationException {
OWLOntology ontology1 = diff.ontology1;
OWLOntology ontology2 = diff.ontology2;
Set<OWLAxiom> axioms1 = ontology1.getAxioms();
Set<OWLAxiom> axioms2 = ontology2.getAxioms();
Set<OWLAxiom> sharedDeclarations = new HashSet<>();
if (diff.isCompareClassesInCommon) {
Set<OWLClass> cs1 = ontology1.getClassesInSignature();
Set<OWLClass> cs2 = ontology2.getClassesInSignature();
Set<OWLClass> cs = Sets.intersection(cs1, cs2);
axioms1 = new HashSet<>();
axioms2 = new HashSet<>();
for (OWLClass c : cs) {
sharedDeclarations.add(ontology1.
getOWLOntologyManager().
getOWLDataFactory().
getOWLDeclarationAxiom(c));
axioms1.addAll(ontology1.getAxioms(c));
axioms1.addAll(ontology1.getAnnotationAssertionAxioms(c.getIRI()));
axioms2.addAll(ontology2.getAxioms(c));
axioms2.addAll(ontology2.getAnnotationAssertionAxioms(c.getIRI()));
}
}
axioms1 = filter(axioms1, diff);
axioms2 = filter(axioms2, diff);
// map from compared axiom to full axiom
Map<OWLAxiom, Set<OWLAxiom>> umap1 = diff.umap1;
Map<OWLAxiom, Set<OWLAxiom>> umap2 = diff.umap2;
axioms1 = unannotateAxioms(axioms1, umap1,
ontology1.getOWLOntologyManager().getOWLDataFactory(),
diff.isCompareUnannotatedForm);
axioms2 = unannotateAxioms(axioms2, umap2,
ontology2.getOWLOntologyManager().getOWLDataFactory(),
diff.isCompareUnannotatedForm);
Set<OWLAxiom> intersectionAxioms = Sets.intersection(axioms1, axioms2);
Set<OWLAxiom> unionAxioms = Sets.union(axioms1, axioms2);
Set<OWLAxiom> axioms1remaining = Sets.difference(axioms1, axioms2);
Set<OWLAxiom> axioms2remaining = Sets.difference(axioms2, axioms1);
//System.out.println("A2R="+axioms2remaining);
if (diff.isCompareUnannotatedForm) {
intersectionAxioms =
Sets.union(
diff.mapAxioms1(intersectionAxioms),
diff.mapAxioms2(intersectionAxioms));
axioms1remaining = diff.mapAxioms1(axioms1remaining);
axioms2remaining = diff.mapAxioms2(axioms2remaining);
}
if (diff.isAddSharedDeclarations) {
axioms1remaining = Sets.union(axioms1remaining, sharedDeclarations);
axioms2remaining = Sets.union(axioms2remaining, sharedDeclarations);
}
diff.intersectionOntology = diff.ontology(intersectionAxioms);
diff.ontology1remaining = diff.ontology(axioms1remaining);
diff.ontology2remaining = diff.ontology(axioms2remaining);
diff.ontologyDiff = diff.ontology(Sets.union(axioms1remaining , axioms2remaining ));
return diff;
}