@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); }
@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; }
@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; }
@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; }
@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; }
@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; }
@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; }
@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; }
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; } }
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(); } }
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; }
/** * 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; }
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)); } }); }
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; } }); }
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; }
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(" ", "_")); } } } } } } }
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); } }); } } }
/** * 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; }
/** * 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."); }
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; }
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 ""; } }
/** * 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()]); }
/** * 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()); } }
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; }
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; } }
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; } }
/** * 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; }
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; }
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) }); }
@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)); }
@Override public void addToOntology() { OWLLiteral titleLiteral = factory.getOWLLiteral(ontologyConstants.getTitle()); OWLAnnotation title = factory.getOWLAnnotation(factory.getRDFSLabel(), titleLiteral); addChangeToOntology(new AddOntologyAnnotation(ontology, title)); }
@Override public void addToOntology() { OWLLiteral descriptionLiteral = factory.getOWLLiteral(ontologyConstants.getDescription()); OWLAnnotation comment = factory.getOWLAnnotation(factory.getRDFSComment(), descriptionLiteral); addChangeToOntology(new AddOntologyAnnotation(ontology, comment)); }
@Override public void addToOntology() { OWLLiteral version = factory.getOWLLiteral(ontologyConstants.getVersion()); OWLAnnotation owlVersionInfo = factory.getOWLAnnotation(factory.getOWLVersionInfo(), version); addChangeToOntology(new AddOntologyAnnotation(ontology, owlVersionInfo)); }
@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)); }
@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); }
@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)); }
@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)); }
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; }
/** * 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; }