当前位置: 首页>>代码示例>>Java>>正文


Java OWLOntology.getAxioms方法代码示例

本文整理汇总了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);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:23,代码来源:NCBI2OWLTest.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:34,代码来源:OWLGraphWrapperExtended.java

示例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);
	}

}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:27,代码来源:MgiGAFOWLBridgeTest.java

示例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();
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:NCBI2OWL.java

示例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;
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:36,代码来源:PredicateVariableExtractor.java

示例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());
	}
}
 
开发者ID:md-k-sarker,项目名称:OWLAx,代码行数:13,代码来源:IntegrateOntologyWithProtege.java

示例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()));
					}
				}
			}
		}
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:33,代码来源:ObsoleteClassInSignature.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:12,代码来源:OwlHelper.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:15,代码来源:CardinalityContraintsTools.java

示例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());
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:14,代码来源:OWLGsonRendererTest.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:31,代码来源:Mooncat.java

示例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);
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:13,代码来源:CardinalityContraintsTools.java

示例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()));
						}
					}
				}
			}
		}
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:39,代码来源:AltIdInSignature.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:68,代码来源:DiffUtil.java


注:本文中的org.semanticweb.owlapi.model.OWLOntology.getAxioms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。