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

项目: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);
}
项目: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;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<String> getAltLabels(OWLEntity cpt) {
    if(cpt == null)
        throw new IllegalArgumentException("cpt cannot be null");

    // The rdfs:label, if it exists
    Set<String> finalLabels = new HashSet<String>();
    Set<OWLAnnotation> annotations = cpt.getAnnotations(
            ontology,
            df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()));
    for(OWLAnnotation annot : annotations) {
        if(annot.getValue() instanceof OWLLiteral) {
            finalLabels.add(((OWLLiteral)annot.getValue()).getLiteral());
        }
    }
    return finalLabels;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public Set<String> getAltLabels(OWLEntity cpt, String lang) {
    if(cpt == null)
        throw new IllegalArgumentException("cpt cannot be null");

    // The rdfs:label, if it exists
    Set<String> finalLabels = new HashSet<String>();
    Set<OWLAnnotation> annotations = cpt.getAnnotations(
            ontology,
            df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()));
    for(OWLAnnotation annot : annotations) {
        if(annot.getValue() instanceof OWLLiteral) {
            OWLLiteral literal = (OWLLiteral)annot.getValue();
            // Si il y a une langue et que c'est celle en parametre
            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(""))) { 

                String label = literal.getLiteral();
                finalLabels.add(label);
            }
        }
    }
    return finalLabels;
}
项目:onagui    文件:OWLAPIContainer.java   
@Override
public SortedSet<String> getAllLanguageInLabels() {
    if(languages == null) {
        languages = new TreeSet<String>();
        OWLOntologyWalker walker = new OWLOntologyWalker(Collections.singleton(ontology));
        OWLOntologyWalkerVisitor<Object> visitor = new OWLOntologyWalkerVisitor<Object>(walker) { 
            @Override
            public Object visit(OWLLiteral literal) {
                if(literal.hasLang()) {
                    languages.add(literal.getLang());
                }
                return super.visit(literal);
            }
        };
        walker.walkStructure(visitor);
    }
    return languages;
}
项目: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;
    }
}
项目:sparql-dl-api    文件:QueryArgument.java   
public String getValueAsString() {
    if (value instanceof IRI) {
        return value.toString();
    }
    else if (value instanceof OWLLiteral) {
        return ((OWLLiteral) value).getLiteral();
    }
    else if (value instanceof OWLAnonymousIndividual) {
        return ((OWLAnonymousIndividual) value).getID().toString();
    }
    else if (value instanceof Var) {
        return ((Var) value).getName();
    }
    else {
        return value.toString();
    }
}
项目: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    文件: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;
}
项目:minerva    文件:JsonTools.java   
private static JsonAnnotation create(final String key, OWLAnnotationValue value, final CurieHandler curieHandler) {
    return value.accept(new OWLAnnotationValueVisitorEx<JsonAnnotation>() {

        @Override
        public JsonAnnotation visit(IRI iri) {
            String iriString = curieHandler.getCuri(iri);
            return JsonAnnotation.create(key, iriString, VALUE_TYPE_IRI);
        }

        @Override
        public JsonAnnotation visit(OWLAnonymousIndividual individual) {
            return null; // do nothing
        }

        @Override
        public JsonAnnotation visit(OWLLiteral literal) {
            return JsonAnnotation.create(key, literal.getLiteral(), getType(literal));
        }
    });
}
项目:owltools    文件:ModelAnnotationSolrDocumentLoader.java   
private OWLNamedIndividual findEvidenceIndividual(OWLAnnotationValue value) {
    return value.accept(new OWLAnnotationValueVisitorEx<OWLNamedIndividual>() {

        @Override
        public OWLNamedIndividual visit(final IRI iri) {
            OWLNamedIndividual i = null;
            for(OWLNamedIndividual current : model.getIndividualsInSignature()) {
                if (current.getIRI().equals(iri)) {
                    i = current;
                    break;
                }
            }
            return i;
        }

        @Override
        public OWLNamedIndividual visit(OWLAnonymousIndividual individual) {
            return null;
        }

        @Override
        public OWLNamedIndividual visit(OWLLiteral literal) {
            return null;
        }
    });
}
项目:minerva    文件:JsonTools.java   
private static OWLLiteral createLiteralInternal(JsonAnnotation ann, OWLDataFactory f) {
    OWLLiteral literal;
    OWL2Datatype datatype = null;
    for(OWL2Datatype current : OWL2Datatype.values()) {
        if (current.getPrefixedName().equalsIgnoreCase(ann.valueType)
                || current.getShortForm().equalsIgnoreCase(ann.valueType)) {
            datatype = current;
            break;
        }
    }
    if (datatype != null) {
        literal = f.getOWLLiteral(ann.value, datatype);
    }
    else {
        literal = f.getOWLLiteral(ann.value);
    }
    return literal;
}
项目: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   
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);
                }
            });
        }
    }
}
项目:darceo    文件:TechnicalDescriptorConstructorBean.java   
/**
 * Creates new technical descriptor from the given individual in the specified ontology.
 * 
 * @param technicalDesc
 *            individual from the ontology representing technical descriptor.
 * @param ontology
 *            currently browsed ontology.
 * @param propertyIri
 *            IRI of the property containing technical descriptor.
 * @param semantic
 *            constructed semantic descriptor tree root.
 * @return extracted and constructed technical descriptor.
 */
private TechnicalDescriptor createDescriptor(OWLIndividual technicalDesc, OWLOntology ontology, IRI propertyIri,
        SemanticDescriptor semantic) {
    Set<OWLLiteral> locations = technicalDesc.getDataPropertyValues(ontologyManager.getOWLDataFactory()
            .getOWLDataProperty(propertyIri), ontology);
    TechnicalDescriptor result = new TechnicalDescriptor();
    if (locations.size() != 1) {
        throw new RuntimeException("Bad property specified or unsupported descriptor type.");
    }
    for (OWLLiteral location : locations) {
        result.setLocationUrl(location.getLiteral().trim());
        List<TechnicalDescriptor> technicalDescriptors = semantic.getTechnicalDescriptors();
        for (TechnicalDescriptor technicalDescriptor : technicalDescriptors) {
            if (technicalDescriptor.getLocationUrl().equals(location.getLiteral().trim())) {
                return technicalDescriptor;
            }
        }
        result.setSemanticDescriptor(semantic);
    }
    semantic.getTechnicalDescriptors().add(result);
    return result;
}
项目:darceo    文件:TechnicalDescriptorConstructorBean.java   
/**
 * Finds the service address in the given WADL using the information contained in semantic descriptor.
 * 
 * @param ontology
 *            currently browsed ontology.
 * @param technicalDesc
 *            individual from the ontology representing technical descriptor.
 * @param techDescriptorUrl
 *            location of technical descriptor.
 * @return URL specifying the service address (location).
 * @throws EntryCreationException
 *             should any problems with parsing WADL document occur.
 */
private String getServiceUrlFromWadl(OWLOntology ontology, OWLIndividual technicalDesc, String techDescriptorUrl)
        throws EntryCreationException {
    Set<OWLIndividual> resourceMethods = technicalDesc.getObjectPropertyValues(ontologyManager.getOWLDataFactory()
            .getOWLObjectProperty(IRI.create(WADL_GROUNDING_PREFIX + "wadlResourceMethod")), ontology);
    for (OWLIndividual resourceMethod : resourceMethods) {
        Set<OWLLiteral> resources = resourceMethod.getDataPropertyValues(ontologyManager.getOWLDataFactory()
                .getOWLDataProperty(IRI.create(WADL_GROUNDING_PREFIX + "resource")), ontology);
        for (OWLLiteral resource : resources) {
            String[] split = resource.getLiteral().split("#");
            String id = split[split.length - 1].trim();
            String xpath = "//" + TechnicalNamespaceContext.WADL_PREFIX + ":resource[@id='" + id + "']";
            NodeList nodes = getNode(techDescriptorUrl, xpath);
            String path = constructUrl(nodes.item(0));
            return path;
        }
    }
    throw new EntryCreationException("Could not find location of the service specified in grounding.");
}
项目:owltools    文件:OntologyMetadataMarkdownWriter.java   
private static Set<String> getVals(String p, Set<OWLAnnotation> oAnns) {
    Set<OWLAnnotation> rmAnns = new HashSet<OWLAnnotation>();
    Set<String> vs = new HashSet<String>();
    System.err.println(" L: "+p);
    for (OWLAnnotation ann : oAnns) {
        String ps = ann.getProperty().getIRI().toString();
        ps = ps.replaceAll(".*/", "");
        if (ps.equals(p)) {
            String v = (ann.getValue() instanceof OWLLiteral) ? ((OWLLiteral)ann.getValue()).getLiteral() : ann.getValue().toString();
            //String v = ann.getValue().toString();
            vs.add(v);
            System.err.println("  P: "+ps+"="+v);
            rmAnns.add(ann);
        }
    }
    oAnns.removeAll(rmAnns);
    return vs;
}
项目:logmap-matcher    文件:ExtractStringFromAnnotationAssertionAxiom.java   
private String asDirectValue(OWLAnnotationAssertionAxiom entityAnnAx){
    try {
        //LogOutput.print(((OWLLiteral)annAx.getAnnotation().getValue()).getLiteral());

        String label = ((OWLLiteral)entityAnnAx.getAnnotation().getValue()).getLiteral().toLowerCase();

        //System.err.println(entityAnnAx + " " + label);

        if (label==null || label.equals("null") || label.equals("")){
            //System.err.println("NULL LABEL: " + entityAnnAx);
            return "";
        }


        return label;


    }
    catch (Exception e){
        //In case of error. Accessing an object in an expected way              
        return "";
    }
}
项目: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()]);
}
项目:jopa    文件:OwlapiUtils.java   
/**
 * Creates OWLLiteral from the specified Java instance.
 *
 * @param value       The value to transform
 * @param dataFactory Data factory
 * @param lang        Ontology language
 * @return OWLLiteral representing the value
 * @throws IllegalArgumentException If {@code value} is of unsupported type
 */
public static OWLLiteral createOWLLiteralFromValue(Object value, OWLDataFactory dataFactory, String lang) {
    Objects.requireNonNull(value);
    if (value instanceof Integer) {
        // Java implementations map int/Integer to xsd:int, because xsd:integer is unbounded, whereas xsd:int is 32-bit signed, same as Java
        return dataFactory.getOWLLiteral(value.toString(), OWL2Datatype.XSD_INT);
    } else if (value instanceof Long) {
        return dataFactory.getOWLLiteral(value.toString(), OWL2Datatype.XSD_LONG);
    } else if (value instanceof Boolean) {
        return dataFactory.getOWLLiteral((Boolean) value);
    } else if (value instanceof Double) {
        return dataFactory.getOWLLiteral((Double) value);
    } else if (value instanceof String) {
        return dataFactory.getOWLLiteral((String) value, lang);
    } else if (value instanceof Date) {
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
        return dataFactory.getOWLLiteral(sdf.format(((Date) value)),
                dataFactory.getOWLDatatype(OWL2Datatype.XSD_DATE_TIME.getIRI()));
    } else if (value.getClass().isEnum()) {
        return dataFactory.getOWLLiteral(value.toString());
    } else {
        throw new IllegalArgumentException("Unsupported value " + value + " of type " + value.getClass());
    }
}
项目:HermiT-android    文件:Reasoner.java   
public boolean hasDataPropertyRelationship(OWLNamedIndividual subject,
        OWLDataProperty property, OWLLiteral object) {
    checkPreConditions(subject, property);
    if (!m_isConsistent)
        return true;
    OWLDataFactory factory = getDataFactory();
    OWLAxiom notAssertion = factory
            .getOWLNegativeDataPropertyAssertionAxiom(property, subject,
                    object);
    Tableau tableau = getTableau(notAssertion);
    boolean result = tableau.isSatisfiable(true, true, null, null, null,
            null, null, new ReasoningTaskDescription(true,
                    "is {0} connected to {1} via {2}", H(subject), object,
                    H(property)));
    tableau.clearAdditionalDLOntology();
    return !result;
}
项目:Hermit_1.3.8_android    文件:ReducedABoxOnlyClausification.java   
protected Constant getConstant(OWLLiteral literal) {
    try {
        if (literal.isRDFPlainLiteral()) {
            if (literal.hasLang())
                return Constant.create(literal.getLiteral()+"@"+literal.getLang(),Prefixes.s_semanticWebPrefixes.get("rdf:")+"PlainLiteral");
            else
                return Constant.create(literal.getLiteral()+"@",Prefixes.s_semanticWebPrefixes.get("rdf:")+"PlainLiteral");
        }
        else
            return Constant.create(literal.getLiteral(),literal.getDatatype().getIRI().toString());
    }
    catch (UnsupportedDatatypeException e) {
        if (m_ignoreUnsupportedDatatypes) {
            if (m_warningMonitor!=null)
                m_warningMonitor.warning("Ignoring unsupported datatype '"+literal.toString()+"'.");
            return Constant.createAnonymous(literal.getLiteral());
        }
        else
            throw e;
    }
}
项目:HermiT-android    文件:OWLClausification.java   
public Object visit(OWLLiteral object) {
    try {
        if (object.isRDFPlainLiteral()) {
            if (object.hasLang())
                return Constant.create(object.getLiteral()+"@"+object.getLang(),Prefixes.s_semanticWebPrefixes.get("rdf:")+"PlainLiteral");
            else
                return Constant.create(object.getLiteral()+"@",Prefixes.s_semanticWebPrefixes.get("rdf:")+"PlainLiteral");
        }
        else
            return Constant.create(object.getLiteral(),object.getDatatype().getIRI().toString());
    }
    catch (UnsupportedDatatypeException e) {
        if (m_ignoreUnsupportedDatatypes) {
            if (m_warningMonitor!=null)
                m_warningMonitor.warning("Ignoring unsupported datatype '"+object.toString()+"'.");
            return Constant.createAnonymous(object.getLiteral());
        }
        else
            throw e;
    }
}
项目: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;
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
public boolean hasDataPropertyRelationship(OWLNamedIndividual subject,
        OWLDataProperty property, OWLLiteral object) {
    checkPreConditions(subject, property);
    if (!m_isConsistent)
        return true;
    OWLDataFactory factory = getDataFactory();
    OWLAxiom notAssertion = factory
            .getOWLNegativeDataPropertyAssertionAxiom(property, subject,
                    object);
    Tableau tableau = getTableau(notAssertion);
    boolean result = tableau.isSatisfiable(true, true, null, null, null,
            null, null, new ReasoningTaskDescription(true,
                    "is {0} connected to {1} via {2}", H(subject), object,
                    H(property)));
    tableau.clearAdditionalDLOntology();
    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;
}
项目:Hermit_1.3.8_android    文件:OWLNormalization.java   
public void visit(SWRLDataRangeAtom atom) {
    if (atom.getArgument() instanceof SWRLVariable)
        throwVarError(atom);
    // dr(literal) :-
    // convert to: ClassAssertion(DataSomeValuesFrom(freshDP DataOneOf(literal)) freshIndividual)
    // and top -> \forall freshDP.dr
    OWLLiteral lit=((SWRLLiteralArgument)atom.getArgument()).getLiteral();
    OWLDataRange dr=atom.getPredicate();
    OWLNamedIndividual freshIndividual=getFreshIndividual();
    OWLDataProperty freshDP=getFreshDataProperty();
    OWLDataSomeValuesFrom some=m_factory.getOWLDataSomeValuesFrom(freshDP,m_factory.getOWLDataOneOf(lit));
    OWLClassExpression definition=getDefinitionFor(some,m_alreadyExists);
    if (!m_alreadyExists[0])
        m_newInclusions.add(new OWLClassExpression[] { negative(definition),some });
    addFact(m_factory.getOWLClassAssertionAxiom(definition,freshIndividual));
    m_newInclusions.add(new OWLClassExpression[] { m_factory.getOWLDataAllValuesFrom(freshDP,dr) });
}
项目:OntoBench    文件:OwlNegativeDataPropertyAssertionFeature.java   
@Override
public void addToOntology() {
  OWLNamedIndividual source = factory.getOWLNamedIndividual(":NegativeDataPropertyAssertion_SourceIndividual", pm);
  OWLLiteral target = factory.getOWLLiteral("NegativeDataPropertyAssertion_TargetValue");
  OWLDataProperty property = factory.getOWLDataProperty(":negativeDataPropertyAssertionProperty", pm);

  addAxiomToOntology(factory.getOWLNegativeDataPropertyAssertionAxiom(property, source, target));
}
项目:OntoBench    文件:RdfsLabelOnOntologyFeature.java   
@Override
public void addToOntology() {
  OWLLiteral titleLiteral = factory.getOWLLiteral(ontologyConstants.getTitle());
  OWLAnnotation title = factory.getOWLAnnotation(factory.getRDFSLabel(), titleLiteral);

  addChangeToOntology(new AddOntologyAnnotation(ontology, title));
}
项目:OntoBench    文件:RdfsCommentOnOntologyFeature.java   
@Override
public void addToOntology() {
  OWLLiteral descriptionLiteral = factory.getOWLLiteral(ontologyConstants.getDescription());
  OWLAnnotation comment = factory.getOWLAnnotation(factory.getRDFSComment(), descriptionLiteral);

  addChangeToOntology(new AddOntologyAnnotation(ontology, comment));
}
项目:OntoBench    文件:OwlVersionInfoFeature.java   
@Override
public void addToOntology() {
  OWLLiteral version = factory.getOWLLiteral(ontologyConstants.getVersion());
  OWLAnnotation owlVersionInfo = factory.getOWLAnnotation(factory.getOWLVersionInfo(), version);

  addChangeToOntology(new AddOntologyAnnotation(ontology, owlVersionInfo));
}
项目:OntoBench    文件:OwlAnnotationPropertyFeature.java   
@Override
public void addToOntology() {
  String ontologyIri = ontology.getOntologyID().getOntologyIRI().get().toString();
  OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(IRI.create(ontologyIri + "customAnnotationProperty"));
  addAxiomToOntology(factory.getOWLDeclarationAxiom(annotationProperty));

  OWLLiteral annotationValue = factory.getOWLLiteral("Custom Annotation Value");
  OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, annotationValue);

  OWLClass owlClass = featurePool.getReusableClass();
  addAxiomToOntology(factory.getOWLDeclarationAxiom(owlClass));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(owlClass.getIRI(), annotation));
}
项目:OntoBench    文件:OwlDatatypeRestrictionFeature.java   
@Override
public void addToOntology() {
  OWLDatatype datatype = factory.getOWLDatatype(":DatatypeRestrictionDatatype", pm);

  OWLFacetRestriction fr1 = factory.getOWLFacetRestriction(OWLFacet.MIN_LENGTH, 10);
  OWLLiteral patternLiteral = factory.getOWLLiteral("DatatypeRestrictionLiteral");
  OWLFacetRestriction fr2 = factory.getOWLFacetRestriction(OWLFacet.PATTERN, patternLiteral);

  OWLDatatypeRestriction restriction = factory.getOWLDatatypeRestriction(datatype, fr1, fr2);

  OWLDataProperty property = factory.getOWLDataProperty(":datatypeRestrictionProperty", pm);
  addToGenericDomainAndNewRange(property, restriction);
}
项目:OntoBench    文件:OwlDataOneOfFeature.java   
@Override
public void addToOntology() {
  OWLDatatype datatype = factory.getOWLDatatype(":DataOneOf", pm);

  OWLLiteral l1 = factory.getOWLLiteral("DataOneOf_Literal1");
  OWLLiteral l2 = factory.getOWLLiteral("DataOneOf_Literal2");
  OWLLiteral l3 = factory.getOWLLiteral("DataOneOf_Literal3");

  OWLDataOneOf owlDataOneOf = factory.getOWLDataOneOf(l1, l2, l3);
  addAxiomToOntology(factory.getOWLDatatypeDefinitionAxiom(datatype, owlDataOneOf));
}
项目:OntoBench    文件:OwlDataOneOfOwl2ELFeature.java   
@Override
public void addToOntology() {
  OWLDatatype datatype = factory.getOWLDatatype(":DataOneOf_EL", pm);
  OWLLiteral singleLiteral = factory.getOWLLiteral("DataOneOf_EL_Literal1");
  OWLDataOneOf owlDataOneOf = factory.getOWLDataOneOf(singleLiteral);

  addAxiomToOntology(factory.getOWLDatatypeDefinitionAxiom(datatype, owlDataOneOf));
}
项目:BENGAL    文件:StatisticalFunctionalityDetector.java   
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;
}
项目:OWLAx    文件:IntegrateOntologyWithProtege.java   
/**
 * create axioms for class--dataproperty----literal relation.
 * 
 * @param src
 * @param dataprop
 * @param dest
 * @return
 */
private void getClass2DataProperty2LiteralAxioms(OWLClass src, OWLDataProperty dataprop, OWLLiteral dest) {
    // Set<OWLAxiom> tmpaxioms = new HashSet<OWLAxiom>();
    OWLAxiom axiom;
    OWLDataSomeValuesFrom owlDataSomeValuesFrom;
    OWLDataHasValue owlLDataHasValue;
    OWLDataMaxCardinality owlDataMaxCardinality;
    OWLDataOneOf owldataOneOf;

    // set domain and range
    // scoped domain
    if (editor.isGenerateDomainAxiom()) {
        owlLDataHasValue = owlDataFactory.getOWLDataHasValue(dataprop, dest);
        axiom = owlDataFactory.getOWLSubClassOfAxiom(owlLDataHasValue, src);
        domainAndRangeAxioms.add(axiom);

        owlDataSomeValuesFrom = owlDataFactory.getOWLDataSomeValuesFrom(dataprop, owlDataFactory.getTopDatatype());
        axiom = owlDataFactory.getOWLSubClassOfAxiom(owlDataSomeValuesFrom, src);
        domainAndRangeAxioms.add(axiom);
    }

    if (editor.isGenerateCardinalityAxiom()) {
        owlDataMaxCardinality = owlDataFactory.getOWLDataMaxCardinality(1, dataprop,
                owlDataFactory.getTopDatatype());
        axiom = owlDataFactory.getOWLSubClassOfAxiom(owlDataFactory.getOWLThing(), owlDataMaxCardinality);
        cardinalityAxioms.add(axiom);

        // need to verify with Adila
        owlDataMaxCardinality = owlDataFactory.getOWLDataMaxCardinality(1, dataprop,
                owlDataFactory.getTopDatatype());
        axiom = owlDataFactory.getOWLSubClassOfAxiom(src, owlDataMaxCardinality);
        cardinalityAxioms.add(axiom);
    }
    // return tmpaxioms;
}