Java 类org.semanticweb.owlapi.model.OWLAnnotationProperty 实例源码

项目:OntoBench    文件:RdfsCommentFeature.java   
@Override
public void addToOntology() {
  OWLObjectProperty property = featurePool.getExclusiveProperty(":propertyWithInfos");
  OWLClass range = featurePool.getExclusiveClass(":ClassWithInfos");

  OWLLiteral label = factory.getOWLLiteral("Comment of a property (undefined language)");
  OWLAnnotationProperty comment = factory.getRDFSComment();

  OWLAnnotation pA = factory.getOWLAnnotation(comment, label);
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), pA));

  OWLAnnotation cA = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Comment of a class (undefined language)"));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), cA));

  addToGenericDomainAndNewRange(property, range);
}
项目:OntoBench    文件:RdfsLabelMultiLanguageFeature.java   
@Override
public void addToOntology() {
  OWLObjectProperty property = featurePool.getExclusiveProperty(":propertyWithInfos");
  OWLClass range = featurePool.getExclusiveClass(":ClassWithInfos");
  OWLAnnotationProperty label = factory.getRDFSLabel();

  OWLAnnotation enAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("Label of a property", Locale.ENGLISH.getLanguage()));
  OWLAnnotation deAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("Bezeichnung einer Property", Locale.GERMAN.getLanguage()));
  OWLAnnotation jpAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("プロパティの指定", Locale.JAPANESE.getLanguage()));

  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), deAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), enAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), jpAnnotation));

  OWLAnnotation enClassAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("Label of a class", Locale.ENGLISH.getLanguage()));
  OWLAnnotation deClassAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("Bezeichnung einer Klasse", Locale.GERMAN.getLanguage()));
  OWLAnnotation jpClassAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("どうもありがとうミスターロボット", Locale.JAPANESE.getLanguage()));

  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), enClassAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), deClassAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), jpClassAnnotation));


  addToGenericDomainAndNewRange(property, range);
}
项目:OntoBench    文件:RdfsCommentMultiLanguageFeature.java   
@Override
public void addToOntology() {
  OWLObjectProperty property = featurePool.getExclusiveProperty(":propertyWithInfos");
  OWLClass range = featurePool.getExclusiveClass(":ClassWithInfos");
  OWLAnnotationProperty comment = factory.getRDFSComment();

  OWLAnnotation enAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Comment of a property", Locale.ENGLISH.getLanguage()));
  OWLAnnotation deAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Kommentar einer Property", Locale.GERMAN.getLanguage()));
  OWLAnnotation jpAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("プロパティのコメント", Locale.JAPANESE.getLanguage()));

  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), deAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), enAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), jpAnnotation));


  OWLAnnotation enClassAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Comment of a class", Locale.ENGLISH.getLanguage()));
  OWLAnnotation deClassAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Kommentar einer Klasse", Locale.GERMAN.getLanguage()));
  OWLAnnotation jpClassAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("どうもありがとうミスターロボット", Locale.JAPANESE.getLanguage()));

  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), enClassAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), deClassAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), jpClassAnnotation));

  addToGenericDomainAndNewRange(property, range);
}
项目:onagui    文件:DOEOWLContainer.java   
@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;
}
项目:onagui    文件:DOEOWLContainer.java   
@Override
public Set<String> getPrefLabels(OWLEntity cpt, String lang) {
    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();
                if((literal.hasLang() && literal.getLang().toLowerCase().equals(lang.toLowerCase()))
                        // ou si il n'y en a pas et que c'est voulu
                        || (!literal.hasLang() && lang.equals(""))) { 

                    finalLabels.add(literal.getLiteral());
                }
            }
        }
    }
    return finalLabels;
}
项目:onagui    文件:DOEOWLContainer.java   
@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;
}
项目:onagui    文件:DOEOWLContainer.java   
@Override
public Set<String> getAltLabels(OWLEntity cpt, String lang) {
    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();
                if((literal.hasLang() && literal.getLang().toLowerCase().equals(lang.toLowerCase()))
                        // ou si il n'y en a pas et que c'est voulu
                        || (!literal.hasLang() && lang.equals(""))) { 

                    finalLabels.add(literal.getLiteral());
                }
            }
        }
    }
    return finalLabels;
}
项目:owltools    文件:GetLabelsTest.java   
private String getLabel(OWLEntity obj) throws MultiLabelException {
    String label = null;
    OWLAnnotationProperty labelProperty = ont.getOWLOntologyManager().getOWLDataFactory().getRDFSLabel();
    for (OWLAnnotation ann : OwlHelper.getAnnotations(obj, labelProperty, ont)) {
        if (ann.getProperty().isLabel()) {
            OWLAnnotationValue v = ann.getValue();
            if (v instanceof OWLLiteral) {
                if (label != null) {
                    throw new MultiLabelException(obj);
                }
                label = ((OWLLiteral)v).getLiteral();
            }
        }
    }
    return label;
}
项目:owltools    文件:OGWSubAnnotationTest.java   
/**
 * Test {@link 
 * OWLGraphWrapperEdgesExtended#getSubAnnotationPropertiesOf(OWLAnnotationProperty)}.
 */
@Test
public void shouldGetSubAnnotationPropertiesOf() {
    Set<OWLAnnotationProperty> expectedSubprops = new HashSet<OWLAnnotationProperty>();
    expectedSubprops.add(groupProp);
    assertEquals("Incorrect sub-properties returned", expectedSubprops,  
            wrapper.getSubAnnotationPropertiesOf(subsetProp));

    expectedSubprops = new HashSet<OWLAnnotationProperty>();
    expectedSubprops.add(fake1Prop);
    expectedSubprops.add(fake2Prop);
    assertEquals("Incorrect sub-properties returned", expectedSubprops,  
            wrapper.getSubAnnotationPropertiesOf(groupProp));

    assertEquals("Incorrect sub-properties returned", new HashSet<OWLAnnotationProperty>(),  
            wrapper.getSubAnnotationPropertiesOf(lonelyProp));

}
项目:minerva    文件:CoreMolecularModelManager.java   
private void initializeLegacyRelationIndex() {
    synchronized(legacyRelationIndex) {
        OWLAnnotationProperty rdfsLabel = OWLManager.getOWLDataFactory().getRDFSLabel();
        for (OWLOntology ont : this.getOntology().getImportsClosure()) {
            for (OWLObjectProperty prop : ont.getObjectPropertiesInSignature()) {
                for (OWLAnnotationAssertionAxiom axiom : ont.getAnnotationAssertionAxioms(prop.getIRI())) {
                    if (axiom.getProperty().equals(rdfsLabel)) {
                        Optional<OWLLiteral> literalOpt = axiom.getValue().asLiteral();
                        if (literalOpt.isPresent()) {
                            String label = literalOpt.get().getLiteral();
                            legacyRelationIndex.put(prop.getIRI(), label.replaceAll(" ", "_"));
                        }
                    }
                }
            }
        }
    }
}
项目:minerva    文件:CoreMolecularModelManager.java   
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;
}
项目:pronto    文件:PKBXMLSerializer.java   
protected void addPTBoxConstraints(OWLOntology ontology, PTBox ptbox,
                                        OWLOntologyManager manager, OWLDataFactory  factory) {

    ConceptConverter converter = new ConceptConverter(ptbox.getClassicalKnowledgeBase(), factory); 

    for (ConditionalConstraint cc : ptbox.getDefaultConstraints()) {

        OWLAnnotationProperty annProp = factory.getOWLAnnotationProperty( IRI.create(Constants.CERTAINTY_ANNOTATION_URI ));
        OWLAnnotationValue annValue = factory.getOWLStringLiteral( cc.getLowerBound() + ";" + cc.getUpperBound() );
        OWLAnnotation annotation = factory.getOWLAnnotation( annProp, annValue );   
        OWLClassExpression clsEv = (OWLClassExpression)converter.convert( cc.getEvidence() );
        OWLClassExpression clsCn = (OWLClassExpression)converter.convert( cc.getConclusion() );
        OWLAxiom axiom = factory.getOWLSubClassOfAxiom( clsEv, clsCn, Collections.singleton( annotation ) );

        try {

            manager.applyChange( new AddAxiom(ontology, axiom) );

        } catch( OWLOntologyChangeException e ) {

            e.printStackTrace();
        }
    }
}
项目:owltools    文件:OWLGraphWrapperEdgesExtended.java   
/**
 * Returns the direct child properties of <code>prop</code> in all ontologies.
 * @param prop      The <code>OWLAnnotationProperty</code> for which 
 *                  we want the direct sub-properties.
 * @return          A <code>Set</code> of <code>OWLAnnotationProperty</code>s 
 *                  that are the direct sub-properties of <code>prop</code>.
 * 
 * @see #getSubPropertyClosureOf(OWLObjectPropertyExpression)
 * @see #getSubPropertyReflexiveClosureOf(OWLObjectPropertyExpression)
 */
public Set<OWLAnnotationProperty> getSubAnnotationPropertiesOf(
        OWLAnnotationProperty prop) {
    Set<OWLAnnotationProperty> subProps = new HashSet<OWLAnnotationProperty>();
    for (OWLOntology ont : this.getAllOntologies()) {
        //we need to iterate each annotation property, to get 
        //its getSubAnnotationPropertyOfAxioms and see if prop is its parent 
        //(there is no method "getSuperAnnotationPropertyOfAxioms").
        for (OWLAnnotationProperty subProp : ont.getAnnotationPropertiesInSignature()) {
            for (OWLSubAnnotationPropertyOfAxiom ax: 
                    ont.getSubAnnotationPropertyOfAxioms(subProp)) {
                if (ax.getSuperProperty().equals(prop)) {
                    subProps.add(subProp);
                }
            }
        }
    }
    return subProps;
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * 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;
}
项目:owltools    文件:ModelAnnotationSolrDocumentLoader.java   
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;
}
项目:owltools    文件:DescriptionTreeSimilarity.java   
/**
 * adds additional axioms specific to this method.
 * Creates a named LCS class equivalent to the generated expression
 * 
 * @param id
 * @param result
 * @param axioms
 */
@Override
protected void translateResultsToOWLAxioms(String id, OWLNamedIndividual result, Set<OWLAxiom> axioms) {
    OWLDataFactory df = graph.getDataFactory();

    // declare a named class for the LCS and make this equivalent to the anonymous expression
    OWLClass namedLCS = df.getOWLClass(IRI.create(id+"_LCS"));
    axioms.add(df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()),
            namedLCS.getIRI(), 
            df.getOWLLiteral("LCS of "+simEngine.label(a)+" and "+simEngine.label(b))));
    axioms.add(df.getOWLEquivalentClassesAxiom(namedLCS, lcs));

    // link the similarity object to the named LCS
    OWLAnnotationProperty lcsp = df.getOWLAnnotationProperty(annotationIRI("has_least_common_subsumer"));
    axioms.add(df.getOWLAnnotationAssertionAxiom(lcsp, result.getIRI(), namedLCS.getIRI()));
}
项目:owltools    文件:AbstractOwlSim.java   
@Override
public OWLOntology cacheInformationContentInOntology() throws OWLOntologyCreationException, UnknownOWLClassException {
    OWLOntologyManager mgr = getSourceOntology().getOWLOntologyManager();
    OWLDataFactory df = mgr.getOWLDataFactory();
    OWLOntology o = mgr.createOntology();
    OWLAnnotationProperty p = df.getOWLAnnotationProperty(IRI.create(icIRIString));
    for (OWLClass c : getSourceOntology().getClassesInSignature()) {
        Double ic = getInformationContentForAttribute(c);
        if (ic != null) {
            mgr.addAxiom(o,
                    df.getOWLAnnotationAssertionAxiom(p, 
                            c.getIRI(), 
                            df.getOWLLiteral(ic)));
        }

    }
    return o;
}
项目:owltools    文件:Mooncat.java   
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));
        }
    }
}
项目:owltools    文件:OWLGraphWrapper.java   
/**
 * It returns array of synonyms (is encoded as synonym in obo format and IAO_0000118 annotation property in OWL format) of a class
 * @param c
 * @return array of strings or null
 */
@Deprecated
public String[] getSynonymStrings(OWLObject c) {
    OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(IRI.create(DEFAULT_IRI_PREFIX + "IAO_0000118")); 
    Set<OWLAnnotation>anns = null;
    if (c instanceof OWLEntity) {
        anns = OwlHelper.getAnnotations((OWLEntity) c, lap, sourceOntology);
    }
    else {
        return null;
    }

    List<String> list = new ArrayList<String>();
    for (OWLAnnotation a : anns) {
        if (a.getValue() instanceof OWLLiteral) {
            OWLLiteral val = (OWLLiteral) a.getValue();
            list.add(val.getLiteral()); // return first - todo - check zero or one
        }
    }
    return list.toArray(new String[list.size()]);
}
项目:owltools    文件:SpeciesMergeUtil.java   
private OWLAxiom tr(OWLClass c, OWLAnnotationAssertionAxiom ax) {
    OWLAnnotationProperty p = ax.getProperty();
    if (!ecmap.containsKey(c)) {
        // preserve as-is, exception for labels
        if (p.isLabel()) {
            OWLLiteral lit = (OWLLiteral) ax.getValue();
            String newVal = lit.getLiteral() + " (" + suffix + ")";
            return fac.getOWLAnnotationAssertionAxiom(ax.getProperty(),
                    ax.getSubject(), fac.getOWLLiteral(newVal));
        }
        return ax;

    } else {
        // the class is merged - ditch its axioms
        // (in future some may be preserved - syns?)
        // fac.getOWLAnnotationAssertionAxiom(ax.getProperty(), ecmap,
        // ax.getValue());
        return null;
    }
}
项目:owltools    文件:OWLConverter.java   
/**
 * Add an synonym annotation, plus an annotation on that annotation
 * that specified the type of synonym. The second annotation has the
 * property oio:hasSynonymType.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param type the IRI of the type of synonym
 * @param property the IRI of the annotation property.
 * @param value the literal value of the synonym
 * @return the synonym annotation axiom
 */
protected static OWLAnnotationAssertionAxiom synonym(
        OWLOntology ontology, OWLEntity subject, 
        OWLAnnotationValue type,
        OWLAnnotationProperty property, 
        OWLAnnotationValue value) {
    OWLOntologyManager manager = ontology.getOWLOntologyManager();
    OWLDataFactory dataFactory = manager.getOWLDataFactory();
    OWLAnnotationProperty hasSynonymType =
        dataFactory.getOWLAnnotationProperty(
            format.getIRI("oio:hasSynonymType"));
    OWLAnnotation annotation = 
        dataFactory.getOWLAnnotation(hasSynonymType, type);
    Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>();
    annotations.add(annotation);
    OWLAnnotationAssertionAxiom axiom =
        dataFactory.getOWLAnnotationAssertionAxiom(
            property, subject.getIRI(), value,
            annotations);
    manager.addAxiom(ontology, axiom);
    return axiom;
}
项目:owltools    文件:AxiomAnnotationTools.java   
/**
 * 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;
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
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;
}
项目:owltools    文件:OWLGraphWrapperEdgesExtended.java   
/**
 * Returns all child properties of <code>prop</code> in all ontologies,  
 * ordered from the more general (closer from <code>prop</code>) to the more precise. 
 * 
 * @param prop  the <code>OWLAnnotationProperty</code> for which we want 
 *              the ordered sub-properties. 
 * @return      A <code>LinkedHashSet</code> of <code>OWLAnnotationProperty</code>s 
 *              ordered from the more general to the more precise.
 * 
 * @see #getSubAnnotationPropertiesOf(OWLAnnotationProperty)
 * @see #getSubAnnotationPropertyReflexiveClosureOf(OWLAnnotationProperty)
 */
//TODO: DRY, it is almost the same code as getSubPropertyClosureOf
public LinkedHashSet<OWLAnnotationProperty> getSubAnnotationPropertyClosureOf(
        OWLAnnotationProperty prop) {
    //try to get the sub-properties from the cache
    LinkedHashSet<OWLAnnotationProperty> subProps = 
            this.subAnnotationPropertyCache.get(prop);
    if (subProps != null) {
        return subProps;
    }
    subProps = new LinkedHashSet<OWLAnnotationProperty>();
    Stack<OWLAnnotationProperty> stack = new Stack<OWLAnnotationProperty>();
    stack.add(prop);
    while (!stack.isEmpty()) {
        OWLAnnotationProperty nextProp = stack.pop();
        Set<OWLAnnotationProperty> directSubs = this.getSubAnnotationPropertiesOf(nextProp);
        directSubs.removeAll(subProps);
        stack.addAll(directSubs);
        subProps.addAll(directSubs);
    }
    //put the sub-properties in cache
    this.subAnnotationPropertyCache.put(prop, subProps);

    return subProps;
}
项目:owltools    文件:NCBI2OWLTest.java   
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);
}
项目:OntoBench    文件:DcIdentifierFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "identifier"));

  Optional<IRI> optionalIri = ontology.getOntologyID().getOntologyIRI();
  if (optionalIri.isPresent()) {
    String iri = optionalIri.get().toString();
    OWLAnnotation identifier = factory.getOWLAnnotation(property, factory.getOWLLiteral(iri));

    addChangeToOntology(new AddOntologyAnnotation(ontology, identifier));
  }
}
项目:OntoBench    文件:DcContributorFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "contributor"));
  OWLAnnotation contributor = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getContributor()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, contributor));
}
项目:OntoBench    文件:DcDescriptionFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "description"));
  OWLAnnotation description = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getDescription()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, description));
}
项目:OntoBench    文件:DcDateFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "date"));
  OWLAnnotation date = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getGenerationDate()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, date));
}
项目:OntoBench    文件:DcTitleFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "title"));
  OWLAnnotation title = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getTitle()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, title));
}
项目:OntoBench    文件:DcPublisherFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "publisher"));
  OWLAnnotation publisher = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getCreator()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, publisher));
}
项目:OntoBench    文件:DcCreatorFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "creator"));
  OWLAnnotation creator = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getCreator()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, creator));
}
项目:OntoBench    文件:RdfsLabelFeature.java   
@Override
public void addToOntology() {
  OWLObjectProperty property = featurePool.getExclusiveProperty(":propertyWithInfos");
  OWLClass range = featurePool.getExclusiveClass(":ClassWithInfos");
  OWLAnnotationProperty label = factory.getRDFSLabel();

  OWLAnnotation pA = factory.getOWLAnnotation(label, factory.getOWLLiteral("Label of a property (undefined language)"));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), pA));

  OWLAnnotation cA = factory.getOWLAnnotation(label, factory.getOWLLiteral("Label of a class (undefined language)"));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), cA));

  addToGenericDomainAndNewRange(property, range);
}
项目:OntoBench    文件:RdfsSeeAlsoFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(RDFS_SEE_ALSO, pm);
  OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, IRI.create(requestInformation.getGeneratorIri()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
}
项目:OntoBench    文件:RdfsIsDefinedByFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(RDFS_IS_DEFINED_BY, pm);
  OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, IRI.create(requestInformation.getGeneratorIri()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
}
项目:OntoBench    文件:OwlIncompatibleWithFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_INCOMPATIBLE_WITH, pm);
  IRI value = OntologyConstants.ONTOVIBE_CORE_IRI;
  OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);

  addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
}
项目:OntoBench    文件:OwlBackwardCompatibleWithFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_BACKWARD_COMPATIBLE_WITH, pm);
  IRI value = OntologyConstants.ONTOVIBE_MINIMAL_IRI;
  OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);

  addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
}
项目:OntoBench    文件:OwlPriorVersionFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_PRIOR_VERSION, pm);
  IRI value = OntologyConstants.ONTOVIBE_CORE_IRI;
  OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);

  addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
}
项目:OntoBench    文件:OwlImportsFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_IMPORTS, pm);
  IRI value = OntologyConstants.ONTOVIBE_MINIMAL_IRI;
  OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);

  addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
}
项目:OntoBench    文件:DcTermsContributorFeature.java   
@Override
public void addToOntology() {
  OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DCTERMS + "contributor"));
  OWLAnnotation contributor = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getContributor()));

  addChangeToOntology(new AddOntologyAnnotation(ontology, contributor));
}