本文整理汇总了Java中org.semanticweb.owlapi.model.OWLAxiom.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java OWLAxiom.getAnnotations方法的具体用法?Java OWLAxiom.getAnnotations怎么用?Java OWLAxiom.getAnnotations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.semanticweb.owlapi.model.OWLAxiom
的用法示例。
在下文中一共展示了OWLAxiom.getAnnotations方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAxiomAnnotationValues
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
/**
* Retrieve the literal values for the axiom annotations with the given
* annotation property IRI.
*
* @param iri
* @param axiom
* @return literal values or null
*/
public static List<String> getAxiomAnnotationValues(IRI iri, OWLAxiom axiom) {
List<String> result = null;
for(OWLAnnotation annotation : axiom.getAnnotations()) {
OWLAnnotationProperty property = annotation.getProperty();
if (property.getIRI().equals(iri)) {
OWLAnnotationValue value = annotation.getValue();
if (value instanceof OWLLiteral) {
String literal = ((OWLLiteral) value).getLiteral();
if (result == null) {
result = Collections.singletonList(literal);
}
else if (result.size() == 1) {
result = new ArrayList<String>(result);
result.add(literal);
}
else {
result.add(literal);
}
}
}
}
return result;
}
示例2: getConfidenceValue
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
private Double getConfidenceValue(OWLAxiom axiom) {
Set<OWLAnnotation> annotations = axiom
.getAnnotations(dataFactory.getOWLAnnotationProperty(confidencePropertyIRI));
if (!annotations.isEmpty()) {
OWLLiteral val = (OWLLiteral) annotations.iterator().next().getValue();
return val.parseDouble();
}
return null;
}
示例3: loadDefaultConstraintsFromOWL
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
/**
* Loads conditional constraints from an ontology with annotated axioms
*
* @param ontology
* @param signature
* @param declAxioms Used to return declaration axioms for auto-generated class names
* @param iriPrefix IRI prefix for auto-generated class names
* @param raxList
* @return
*/
public static Set<ConditionalConstraint> loadDefaultConstraintsFromOWL(
OWLOntology ontology,
Map<String, OWLClassExpression> nameMap,
Set<OWLEntity> signature,
List<RemoveAxiom> raxList, String iriPrefix,
OWLOntologyManager manager) {
Set<ConditionalConstraint> ccSet = new HashSet<ConditionalConstraint>();
//Begin with generic (default) subclass-of axioms
for( OWLAxiom axiom : ontology.getAxioms( AxiomType.SUBCLASS_OF ) ) {
for( OWLAnnotation annotation : axiom.getAnnotations() ) {
if( Constants.CERTAINTY_ANNOTATION_URI.equals(annotation.getProperty().getIRI().toURI() ) ) {
OWLSubClassOfAxiom sbAxiom = (OWLSubClassOfAxiom) axiom;
String subClassIRI = generateClassName(sbAxiom.getSubClass(), nameMap, iriPrefix);
String superClassIRI = generateClassName(sbAxiom.getSuperClass(), nameMap, iriPrefix);
ConditionalConstraint cc = newConstraint(subClassIRI, superClassIRI, annotation.getValue().toString());
signature.addAll( sbAxiom.getSubClass().getClassesInSignature() );
signature.addAll( sbAxiom.getSuperClass().getClassesInSignature() );
if( null != cc ) {
ccSet.add( cc );
if( null != raxList ) {
raxList.add( new RemoveAxiom( ontology, axiom ) );
}
}
}
}
}
return ccSet;
}
示例4: traceAxioms
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
static Set<OWLAxiom> traceAxioms(Set<OWLAxiom> axioms, OWLGraphWrapper g, OWLDataFactory df) {
final OWLAnnotationProperty p = df.getOWLAnnotationProperty(IRI.create("http://trace.module/source-ont"));
final Set<OWLOntology> ontologies = g.getSourceOntology().getImportsClosure();
final Set<OWLAxiom> traced = new HashSet<OWLAxiom>();
for (OWLAxiom axiom : axioms) {
Set<OWLOntology> hits = new HashSet<OWLOntology>();
for(OWLOntology ont : ontologies) {
if (ont.containsAxiom(axiom)) {
hits.add(ont);
}
}
if (hits.isEmpty()) {
traced.add(axiom);
}
else {
Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>(axiom.getAnnotations());
for (OWLOntology hit : hits) {
Optional<IRI> hitIRI = hit.getOntologyID().getOntologyIRI();
if(hitIRI.isPresent()) {
annotations.add(df.getOWLAnnotation(p, hitIRI.get()));
}
}
traced.add(AxiomAnnotationTools.changeAxiomAnnotations(axiom, annotations, df));
}
}
return traced;
}
示例5: appendXrefAnnotations
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
/**
* Append xref annotations onto an existing axiom
*
* @param axiom
* @param xrefs
* @param ontology
* @return
*/
public static OWLAxiom appendXrefAnnotations(OWLAxiom axiom, Set<String> xrefs, OWLOntology ontology) {
// filter existing
Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations());
final OWLOntologyManager manager = ontology.getOWLOntologyManager();
final OWLDataFactory factory = manager.getOWLDataFactory();
for (String x : xrefs) {
OWLAnnotationProperty p = factory.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#hasDbXref"));
OWLLiteral v = factory.getOWLLiteral(x);
newAnnotations.add(factory.getOWLAnnotation(p, v));
}
final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology);
return newAxiom;
}
示例6: reduceAxiomAnnotationsToOboBasic
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
/**
* Remove axiom annotations, which do not comply with the OBO-Basic level,
* i.e. trailing qualifier values in OBO.<br>
* <b>Side effect</b>: This removes the old axiom and adds the new axiom to
* the given ontology. The method also returns the new axiom to enable
* chaining.
*
* @param axiom
* @param ontology
* @return axiom
*/
public static OWLAxiom reduceAxiomAnnotationsToOboBasic(OWLAxiom axiom, OWLOntology ontology) {
Set<OWLAnnotation> annotations = axiom.getAnnotations();
if (annotations != null && !annotations.isEmpty()) {
boolean changed = false;
Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>();
for (OWLAnnotation owlAnnotation : annotations) {
OWLAnnotationProperty p = owlAnnotation.getProperty();
IRI iri = p.getIRI();
/*
* if the property IRI is not in a predefined annotation property in
* Obo2Owl assume that it's not OBO-Basic
*/
if (Obo2Owl.ANNOTATIONPROPERTYMAP.containsValue(iri) == false) {
// remove axiom annotation
changed = true;
}
else {
newAnnotations.add(owlAnnotation);
}
}
if (changed) {
// only update the axiom if the annotations have been changed
OWLAxiom newAxiom = AxiomAnnotationTools.changeAxiomAnnotations(axiom, newAnnotations, ontology);
return newAxiom;
}
}
return axiom;
}
示例7: generateClassName
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
public static Map<ATermAppl, Set<ConditionalConstraint>>
loadConcreteConstraintsFromOWL( OWLOntology ontology,
Map<String, OWLClassExpression> nameMap,
Set<OWLEntity> signature,
List<RemoveAxiom> raxList,
String iriPrefix,
OWLOntologyManager manager) {
Map<ATermAppl, Set<ConditionalConstraint>> ccMap = new HashMap<ATermAppl, Set<ConditionalConstraint>>();
ConditionalConstraint cc = null;
Set<ConditionalConstraint> ccSet = null;
OWLDataFactory factory = manager.getOWLDataFactory();
for( OWLAxiom axiom : ontology.getAxioms( AxiomType.CLASS_ASSERTION ) ) {
for( OWLAnnotation annotation : axiom.getAnnotations() ) {
if( Constants.CERTAINTY_ANNOTATION_URI.equals( annotation.getProperty().getIRI().toURI() ) ) {
OWLClassAssertionAxiom caAxiom = (OWLClassAssertionAxiom) axiom;
String classNameIRI = generateClassName(caAxiom.getClassExpression(), nameMap, iriPrefix);
OWLIndividual individ = caAxiom.getIndividual();
ATermAppl indTerm = ATermUtils.makeTermAppl( individ.asOWLNamedIndividual().getIRI().toURI().toString() );
ccSet = (Set<ConditionalConstraint>) ccMap.get( indTerm );
cc = newConstraint( factory.getOWLThing().getIRI().toString(), classNameIRI, annotation.getValue().toString() );
signature.addAll( caAxiom.getClassExpression().getClassesInSignature() );
if( null != cc ) {
if( null == ccSet ) {
ccSet = new HashSet<ConditionalConstraint>();
}
ccSet.add( cc );
ccMap.put( indTerm, ccSet );
if( null != raxList ) {
raxList.add( new RemoveAxiom( ontology, axiom ) );
}
}
}
}
}
return ccMap;
}
示例8: makeLinks
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
/**
* Start search for matches of the given patterns. Annotate new axioms with
* the given source annotation. Furthermore create a new axiom for existing
* annotations, if they do not have a matching source annotation.<br>
* <br>
* This method does not modify the ontology, it only returns the axioms.
*
* @param patterns
* @param sourceAnnotation
* @return result
*/
public LinkMakerResult makeLinks(List<LinkPattern> patterns, OWLAnnotation sourceAnnotation, boolean updateExisting) {
final Set<OWLAxiom> resultAxioms = new HashSet<OWLAxiom>();
final Set<OWLAxiom> existingAxioms = new HashSet<OWLAxiom>();
final Set<OWLAxiom> modified = new HashSet<OWLAxiom>();
for (LinkPattern linkPattern : patterns) {
for (OWLClass currentSubClass : getRelevantClasses(linkPattern.subGenus)) {
OWLClass differentiaCls = hasMatchingIntersection(currentSubClass, linkPattern.subGenus, linkPattern.differentiaRelation);
if (differentiaCls != null) {
// found a matching class, now search for the corresponding one.
for(OWLClass currentSuperClass : getRelevantClasses(linkPattern.superGenus)) {
OWLClass potentialMatch = hasMatchingIntersection(currentSuperClass, linkPattern.superGenus, linkPattern.differentiaRelation);
if (differentiaCls.equals(potentialMatch)) {
// the class has the required xp
// now check that the link does not already exist
OWLAxiom existing = hasLinks(currentSubClass, linkPattern.newRelation, currentSuperClass);
OWLObjectSomeValuesFrom someValuesFrom = f.getOWLObjectSomeValuesFrom(linkPattern.newRelation, currentSuperClass);
if (existing == null) {
OWLSubClassOfAxiom a = f.getOWLSubClassOfAxiom(currentSubClass, someValuesFrom, Collections.singleton(sourceAnnotation));
resultAxioms.add(a);
}
else {
if (updateExisting) {
existingAxioms.add(existing);
Set<OWLAnnotation> existingAnnotations = existing.getAnnotations();
if (existingAnnotations.contains(sourceAnnotation)) {
modified.add(existing);
}
else {
Set<OWLAnnotation> mergedAnnotations = new HashSet<OWLAnnotation>();
mergedAnnotations.add(sourceAnnotation);
mergedAnnotations.addAll(existingAnnotations);
OWLSubClassOfAxiom mod = f.getOWLSubClassOfAxiom(currentSubClass, someValuesFrom, mergedAnnotations);
modified.add(mod);
}
}
}
}
}
}
}
}
return new LinkMakerResult(resultAxioms, existingAxioms, modified);
}
示例9: extractMetadata
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
/**
* @param node
* @param axiom
*/
public static void extractMetadata(LegoMetadata node, OWLAxiom axiom) {
// extract meta data from annotations
Set<OWLAnnotation> annotations = axiom.getAnnotations();
for (OWLAnnotation annotation : annotations) {
String propertyId = annotation.getProperty().getIRI().toString();
OWLAnnotationValue annValue = annotation.getValue();
String value = annValue.accept(LiteralValueVisitor.INSTANCE);
if (value != null) {
if ("http://geneontology.org/lego/evidence".equals(propertyId)) {
Set<String> evidence = node.getEvidence();
if (evidence == null) {
evidence = new HashSet<String>();
node.setEvidence(evidence);
}
evidence.add(value);
}
else if ("http://purl.org/dc/elements/1.1/date".equals(propertyId)) {
Set<String> dates = node.getDates();
if (dates == null) {
dates = new HashSet<String>();
node.setDates(dates);
}
dates.add(value);
}
else if ("http://purl.org/dc/elements/1.1/source".equals(propertyId)) {
Set<String> sources = node.getSources();
if (sources == null) {
sources = new HashSet<String>();
node.setSources(sources);
}
sources.add(value);
}
else if ("http://purl.org/dc/elements/1.1/contributor".equals(propertyId)) {
Set<String> contributors = node.getContributors();
if (contributors == null) {
contributors = new HashSet<String>();
node.setContributors(contributors);
}
contributors.add(value);
}
}
}
}
示例10: appendAxiomAnnotations
import org.semanticweb.owlapi.model.OWLAxiom; //导入方法依赖的package包/类
/**
* Append annotations to an existing axiom
*
* @param axiom
* @param annotations
* @param ontology
* @return
*/
public static OWLAxiom appendAxiomAnnotations(OWLAxiom axiom, Set<OWLAnnotation> annotations, OWLOntology ontology) {
// filter existing
Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations());
newAnnotations.addAll(annotations);
final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology);
return newAxiom;
}