本文整理汇总了Java中org.semanticweb.owlapi.model.OWLAnnotation.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java OWLAnnotation.getProperty方法的具体用法?Java OWLAnnotation.getProperty怎么用?Java OWLAnnotation.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.semanticweb.owlapi.model.OWLAnnotation
的用法示例。
在下文中一共展示了OWLAnnotation.getProperty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrefLabels
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
@Override
public Set<String> getPrefLabels(OWLEntity cpt) {
Set<String> finalLabels = new HashSet<String>();
Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
for(OWLAnnotation annot : annotations) {
if(annot.getValue() instanceof OWLLiteral) {
OWLAnnotationProperty prop = annot.getProperty();
// The DOE prefLabel, if they exist
if(prop.getIRI().equals(prefLabelIRI) ||
prop.getIRI().equals(SKOSVocabulary.PREFLABEL.getIRI()) ||
prop.getIRI().equals(OWLRDFVocabulary.RDFS_LABEL.getIRI())) {
OWLLiteral literal = (OWLLiteral)annot.getValue();
finalLabels.add(literal.getLiteral());
}
}
}
return finalLabels;
}
示例2: getAltLabels
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
@Override
public Set<String> getAltLabels(OWLEntity cpt) {
Set<String> finalLabels = new HashSet<String>();
Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
for(OWLAnnotation annot : annotations) {
if(annot.getValue() instanceof OWLLiteral) {
OWLAnnotationProperty prop = annot.getProperty();
// The DOE prefLabel, if they exist
if(prop.getIRI().equals(altLabelIRI) ||
prop.getIRI().equals(hiddenLabelIRI) ||
prop.getIRI().equals(SKOSVocabulary.ALTLABEL.getIRI()) ||
prop.getIRI().equals(SKOSVocabulary.HIDDENLABEL.getIRI())) {
OWLLiteral literal = (OWLLiteral)annot.getValue();
finalLabels.add(literal.getLiteral());
}
}
}
return finalLabels;
}
示例3: extractEvidenceIRIValues
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
private static void extractEvidenceIRIValues(OWLAnnotation annotation, final Set<IRI> iriSet) {
if (annotation != null) {
OWLAnnotationProperty property = annotation.getProperty();
if (HAS_EVIDENCE_IRI.equals(property.getIRI()) || HAS_EVIDENCE_IRI_OLD.equals(property.getIRI())){
annotation.getValue().accept(new OWLAnnotationValueVisitor() {
@Override
public void visit(OWLLiteral literal) {
// ignore
}
@Override
public void visit(OWLAnonymousIndividual individual) {
// ignore
}
@Override
public void visit(IRI iri) {
iriSet.add(iri);
}
});
}
}
}
示例4: updateAnnotation
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
OWLObjectPropertyAssertionAxiom updateAnnotation(ModelContainer model,
OWLObjectPropertyAssertionAxiom toModify, OWLAnnotation update,
METADATA metadata) {
OWLObjectPropertyAssertionAxiom newAxiom = null;
if (toModify != null) {
Set<OWLAnnotation> combindedAnnotations = new HashSet<OWLAnnotation>();
OWLAnnotationProperty target = update.getProperty();
for(OWLAnnotation existing : toModify.getAnnotations()) {
if (target.equals(existing.getProperty()) == false) {
combindedAnnotations.add(existing);
}
}
combindedAnnotations.add(update);
newAxiom = modifyAnnotations(toModify, combindedAnnotations, model, metadata);
}
return newAxiom;
}
示例5: renderAnnotations
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
private Map<String,String> renderAnnotations(Set<OWLAnnotation> annotations) {
Map<String,String> result = null;
if (annotations != null && !annotations.isEmpty()) {
for (OWLAnnotation annotation : annotations) {
OWLAnnotationProperty prop = annotation.getProperty();
String literal = getLiteralValue(annotation.getValue());
if (literal != null) {
if (result == null) {
result = new HashMap<String, String>();
}
result.put(prop.toStringID(), literal);
}
}
}
return result;
}
示例6: removeDirectives
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
private void removeDirectives() {
// TODO decide: move the set of directives into a constant/static collection?
Set<IRI> directivesIRIs = new HashSet<IRI>();
directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_LogicalDefinitionViewRelation.getIRI());
directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsEquivalent.getIRI());
directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsGenusDifferentia.getIRI());
directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsHasSubClass.getIRI());
directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsIsA.getIRI());
directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsRelationship.getIRI());
directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsReverseGenusDifferentia.getIRI());
OWLOntology o = graph.getSourceOntology();
for(OWLAnnotation ann : o.getAnnotations()) {
final OWLAnnotationProperty property = ann.getProperty();
if (directivesIRIs.contains(property.getIRI())) {
manager.applyChange(new RemoveOntologyAnnotation(o, ann));
}
}
}
示例7: getAxiomAnnotationValues
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的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;
}
示例8: getOntologyAnnotationValue
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
private String getOntologyAnnotationValue(OWLOntology o, OboFormatTag tag) {
IRI dateTagIRI = Obo2Owl.trTagToIRI(tag.getTag());
Set<OWLAnnotation> annotations = o.getAnnotations();
for (OWLAnnotation annotation : annotations) {
OWLAnnotationProperty property = annotation.getProperty();
if(dateTagIRI.equals(property.getIRI())) {
OWLAnnotationValue value = annotation.getValue();
if (value != null) {
if (value instanceof IRI) {
return ((IRI) value).toString();
}
else if (value instanceof OWLLiteral) {
return ((OWLLiteral) value).getLiteral();
}
}
}
}
return null;
}
示例9: extractMetadata
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
private Metadata extractMetadata(Collection<OWLAnnotation> annotations, OWLGraphWrapper modelGraph, String modelId) {
Metadata metadata = new Metadata();
metadata.modelId = modelId;
if (annotations != null && !annotations.isEmpty()) {
for (OWLAnnotation owlAnnotation : annotations) {
OWLAnnotationProperty currentProperty = owlAnnotation.getProperty();
OWLAnnotationValue value = owlAnnotation.getValue();
extractMetadata(currentProperty, value, metadata);
}
}
return metadata;
}
示例10: getRdfsLabels
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
public void getRdfsLabels() {
rdfsLabels = new HashMap<String, String>();
prefAltLabels = new HashMap<String, String>();
Set<OWLClass> classes = getAllConcepts();
String prefLabelIri = "<http://www.w3.org/2004/02/skos/core#prefLabel>";
String altLabelIri = "<http://www.w3.org/2004/02/skos/core#altLabel>";
for (OWLClass cls : classes) {
for (OWLAnnotation a : EntitySearcher.getAnnotations(cls, ontology)) {
// properties are of several types: rdfs-label, altLabel or prefLabel
OWLAnnotationProperty prop = a.getProperty();
OWLAnnotationValue val = a.getValue();
if (val instanceof OWLLiteral) {
// RDFS-labels
if (prop.isLabel()) {
// System.out.println(cls + " labelled " + ((OWLLiteral) val).getLiteral());
// classes can have several rdfs labels
rdfsLabels.put(((OWLLiteral)val).getLiteral(), cls.toString());
}
// preferred or alternative labels
else if (prop.toString().equals(prefLabelIri) || prop.toString().equals(altLabelIri)) {
// System.out.println(cls + " labelled (pref or alt) " + ((OWLLiteral)
// val).getLiteral());
// classes can have several labels
prefAltLabels.put(((OWLLiteral)val).getLiteral(), cls.toString());
}
}
}
}
}
示例11: reduceAxiomAnnotationsToOboBasic
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的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;
}
示例12: validateBeforeSave
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
public List<String> validateBeforeSave(ModelContainer model) throws OWLOntologyCreationException {
// get model
List<String> errors = new ArrayList<String>(3);
// check that model has required meta data
OWLOntology aboxOntology = model.getAboxOntology();
boolean hasTitle = false;
boolean hasContributor = false;
// get ontology annotations
Set<OWLAnnotation> annotations = aboxOntology.getAnnotations();
for (OWLAnnotation annotation : annotations) {
OWLAnnotationProperty p = annotation.getProperty();
AnnotationShorthand legoType = AnnotationShorthand.getShorthand(p.getIRI());
if (legoType != null) {
// check for title
if (AnnotationShorthand.title.equals(legoType)) {
hasTitle = true;
}
// check for contributor
else if (AnnotationShorthand.contributor.equals(legoType)) {
hasContributor = true;
}
}
}
if (hasTitle == false) {
errors.add("The model has no title. All models must have a human readable title.");
}
if (hasContributor == false) {
errors.add("The model has no contributors. All models must have an association with their contributors.");
}
// require at least one declared instance
Set<OWLNamedIndividual> individuals = aboxOntology.getIndividualsInSignature();
if (individuals.isEmpty()) {
errors.add("The model has no individuals. Empty models should not be saved.");
}
// avoid returning empty list
if (errors.isEmpty()) {
errors = null;
}
return errors;
}
示例13: getIRIByIdentifier
import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
public IRI getIRIByIdentifier(String id, boolean isAutoResolve) {
if (isAutoResolve) {
OWLObject obj = this.getObjectByAltId(id);
if (obj != null) {
return ((OWLNamedObject) obj).getIRI();
}
}
// special magic for finding IRIs from a non-standard identifier
// This is the case for relations (OWLObject properties) with a short hand
// or for relations with a non identifiers with-out a colon, e.g. negative_regulation
if (!id.contains(":")) {
final OWLAnnotationProperty shortHand = getDataFactory().getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_OIO_shorthand.getIRI());
final OWLAnnotationProperty oboIdInOwl = getDataFactory().getOWLAnnotationProperty(Obo2Owl.trTagToIRI(OboFormatTag.TAG_ID.getTag()));
for (OWLOntology o : getAllOntologies()) {
for(OWLObjectProperty p : o.getObjectPropertiesInSignature()) {
// check for short hand or obo ID in owl
Set<OWLAnnotation> annotations = OwlHelper.getAnnotations(p, o);
if (annotations != null) {
for (OWLAnnotation owlAnnotation : annotations) {
OWLAnnotationProperty property = owlAnnotation.getProperty();
if ((shortHand != null && shortHand.equals(property))
|| (oboIdInOwl != null && oboIdInOwl.equals(property)))
{
OWLAnnotationValue value = owlAnnotation.getValue();
if (value != null && value instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral) value;
String shortHandLabel = literal.getLiteral();
if (id.equals(shortHandLabel)) {
return p.getIRI();
}
}
}
}
}
}
}
}
// otherwise use the obo2owl method
Obo2Owl b = new Obo2Owl(getManager()); // re-use manager, creating a new one can be expensive as this is a highly used code path
b.setObodoc(new OBODoc());
return b.oboIdToIRI(id);
}