@Override public void visit(OWLDataPropertyAssertionAxiom axiom) { axiom.getSubject().accept(this); axiom.annotations().forEach(a1 -> a1.accept(this)); }
/** * @param i individual * @param ontology ontology to search * @return property values */ public static Multimap<OWLDataPropertyExpression, OWLLiteral> getDataPropertyValues( OWLIndividual i, OWLOntology ontology) { Multimap<OWLDataPropertyExpression, OWLLiteral> map = LinkedListMultimap.create(); ontology.dataPropertyAssertionAxioms(i) .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); return map; }
@Override public OWLClassExpression visit(OWLDataPropertyAssertionAxiom ax) { return df.getOWLDataHasValue(ax.getProperty(), ax.getObject()); }
@Override public OWLDataPropertyAssertionAxiom visit(OWLDataPropertyAssertionAxiom axiom) { return df.getOWLDataPropertyAssertionAxiom(axiom.getProperty(), axiom.getSubject(), process(axiom .getProperty(), axiom.getObject())); }
@Override public void visit(OWLDataPropertyAssertionAxiom axiom) { process(axiom); axiom.getSubject().accept(this); axiom.getProperty().accept(this); axiom.getObject().accept(this); }
@Override protected Set<OWLEntity> getEntitiesThatRequireNamespaces() { return asUnorderedSet( Stream.of( getOntology().axioms(AxiomType.OBJECT_PROPERTY_ASSERTION).flatMap( ax -> ax.getProperty().objectPropertiesInSignature()), getOntology().axioms(AxiomType.DATA_PROPERTY_ASSERTION) .map(ax -> ax.getProperty().asOWLDataProperty()), getOntology().annotationPropertiesInSignature(Imports.INCLUDED)).flatMap(x -> x)); }
protected void addAnnotations(OWLNamedIndividual ind, OWLOntology ont) { ont.dataPropertyAssertionAxioms(ind).filter(ax -> !ax.getProperty().isAnonymous()) .forEach(ax -> addAnnotation( ind, ont, ax)); }
man.addAxioms(sample, schema.getLogicalAxioms()); "http://dbpedia.org/ontology/wikiPageRevisionID", "http://dbpedia.org/ontology/wikiPageID"); OWLOntology ont = man.createOntology(schema.getAxioms()); man.addAxioms(ont, sample.getLogicalAxioms().stream().filter(ax -> { if(ax.getAxiomType() == AxiomType.OBJECT_PROPERTY_ASSERTION) { return true; } else if(ax.getAxiomType() == AxiomType.DATA_PROPERTY_ASSERTION) { return !ignoredProperties.contains(((OWLDataPropertyAssertionAxiom)ax).getProperty().asOWLDataProperty().toStringID()); }).collect(Collectors.toSet()));
@Override public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind, OWLDataProperty pe) { ensurePrepared(); Set<OWLLiteral> literals = new HashSet<>(); Set<OWLDataProperty> superProperties = asUnorderedSet( Stream.concat(getSuperDataProperties(pe, false) .entities(), getEquivalentDataProperties(pe).entities())); getRootOntology().importsClosure().flatMap(o -> o.dataPropertyAssertionAxioms(ind)) .forEach(ax -> { if (superProperties.contains(ax.getProperty().asOWLDataProperty())) { literals.add(ax.getObject()); } }); return literals; }
inds.addAll(ont.getIndividualsInSignature()); OWLNamedIndividual pun = ind.asOWLNamedIndividual(); for (OWLOntology ont : onts) { for (OWLDataPropertyAssertionAxiom ax : ont.getDataPropertyAssertionAxioms(pun)) { if (!ax.getProperty().isAnonymous()) { changes.add(new RemoveAxiom(ont, ax)); OWLAnnotationProperty aProp = df.getOWLAnnotationProperty(ax.getProperty().asOWLDataProperty().getIRI()); OWLAnnotation anno = df.getOWLAnnotation(aProp, ax.getObject()); OWLAnnotationAssertionAxiom annoAx = df.getOWLAnnotationAssertionAxiom(pun.getIRI(), anno); changes.add(new AddAxiom(ont, annoAx)); props.add((OWLDataProperty) ax.getProperty()); for (OWLAxiom ax : ont.getDeclarationAxioms(pun)) { changes.add(new RemoveAxiom(ont, ax));
individuals.addAll(ont.getIndividualsInSignature()); boolean punned = false; for (OWLOntology ont : ontologies) { if (ont.containsClassInSignature(ind.getIRI())) { punned = true; break; for (OWLDataPropertyAssertionAxiom ax : ont.getDataPropertyAssertionAxioms(ind)) { if (!ax.getProperty().isAnonymous()) { changes.add(new RemoveAxiom(ont, ax)); OWLDataFactory df = getDataFactory(); OWLAnnotation anno = df.getOWLAnnotation(df.getOWLAnnotationProperty(ax.getProperty().asOWLDataProperty().getIRI()), ax.getObject()); OWLAnnotationAssertionAxiom annoAx = df.getOWLAnnotationAssertionAxiom(ind.getIRI(), anno); changes.add(new AddAxiom(ont, annoAx)); convertedDataProperties.add((OWLDataProperty) ax.getProperty());
@Override public OWLClassExpression visit(OWLDataPropertyAssertionAxiom axiom) { OWLClassExpression sub = oneOf(axiom.getSubject()); OWLClassExpression sup = factory.getOWLDataHasValue(axiom.getProperty(), axiom.getObject()); OWLSubClassOfAxiom ax = factory.getOWLSubClassOfAxiom(sub, sup); return ax.accept(this); }
private OWLAnnotationAssertionAxiom convertToAnnotation(OWLNamedIndividual ind, OWLDataPropertyAssertionAxiom ax) { OWLDataProperty hasIRI = ax.getProperty().asOWLDataProperty(); OWLAnnotation anno = df .getOWLAnnotation(df.getOWLAnnotationProperty(hasIRI), ax.getObject()); return df.getOWLAnnotationAssertionAxiom(ind.getIRI(), anno); } }
@Override public OWLClassExpression visit(OWLDataPropertyAssertionAxiom ax) { OWLClassExpression nom = df.getOWLObjectOneOf(ax.getSubject()); OWLClassExpression hasVal = df.getOWLDataHasValue(ax.getProperty(), ax.getObject()); return df.getOWLObjectIntersectionOf(nom, df.getOWLObjectComplementOf(hasVal)); }
@Nonnull @Override public Set<OWLLiteral> getDataPropertyValues(@Nonnull OWLNamedIndividual ind, @Nonnull OWLDataProperty pe) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { ensurePrepared(); Set<OWLLiteral> literals = new HashSet<>(); Set<OWLDataProperty> superProperties = getSuperDataProperties(pe, false).getFlattened(); superProperties.addAll(getEquivalentDataProperties(pe).getEntities()); for (OWLOntology ontology : getRootOntology().getImportsClosure()) { for (OWLDataPropertyAssertionAxiom axiom : ontology.getDataPropertyAssertionAxioms(ind)) { if (superProperties.contains(axiom.getProperty().asOWLDataProperty())) { literals.add(axiom.getObject()); } } } return literals; }
/** * @param args * @throws OWLOntologyCreationException * @throws OWLOntologyStorageException */ public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException { File metaprojectLocation = new File(args[0]); int port = Integer.parseInt(args[1]); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); MetaprojectVocabulary.addIRIMapper(manager); OWLOntology ontology = manager.loadOntologyFromOntologyDocument(metaprojectLocation); List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); for (OWLDataPropertyAssertionAxiom axiom : ontology.getAxioms(AxiomType.DATA_PROPERTY_ASSERTION)) { if (axiom.getProperty().equals(HAS_REGISTRY_PORT) || axiom.getProperty().equals(HAS_SERVER_PORT)) { OWLIndividual server = axiom.getSubject(); changes.add(new RemoveAxiom(ontology, axiom)); changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(axiom.getProperty(), server, port))); } } for (OWLIndividual server : STANDARD_SERVER.getIndividuals(ontology)) { changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(HAS_SERVER_PORT, server, port))); changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(HAS_REGISTRY_PORT, server, port))); } manager.applyChanges(changes); manager.saveOntology(ontology); LOGGER.info("Port set to " + port); }
@Override public Boolean visit(OWLDataPropertyAssertionAxiom axiom) { OWLIndividual sub=axiom.getSubject(); if (sub.isAnonymous()) { anonymousIndividualAxioms.add(axiom); return Boolean.TRUE; // will be checked afterwards by rolling-up } OWLClassExpression hasValue=factory.getOWLDataHasValue(axiom.getProperty(),axiom.getObject()); return Boolean.valueOf(reasoner.hasType(axiom.getSubject().asOWLNamedIndividual(),hasValue,false)); } @Override
.getAxioms(AxiomType.DATA_PROPERTY_ASSERTION, Imports.INCLUDED); OWLNamedIndividual candidateValue1 = axiom.getSubject().asOWLNamedIndividual(); OWLDataPropertyExpression candidateValue2 = axiom.getProperty(); OWLLiteral candidateValue3 = axiom.getObject();
@Override protected Set<OWLEntity> getEntitiesThatRequireNamespaces() { Set<OWLEntity> entities = new HashSet<OWLEntity>(); for(OWLObjectPropertyAssertionAxiom ax : getOntology().getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)) { entities.addAll(ax.getProperty().getSignature()); } for(OWLDataPropertyAssertionAxiom ax : getOntology().getAxioms(AxiomType.DATA_PROPERTY_ASSERTION)) { entities.add(ax.getProperty().asOWLDataProperty()); } entities.addAll(getOntology().getAnnotationPropertiesInSignature()); return entities; }
for (OWLOntology ontology : asList(ontologySetProvider.ontologies())) { for (OWLObjectPropertyAssertionAxiom ax : asList( ontology.objectPropertyAssertionAxioms(individual))) { int index = properties.indexOf(ax.getProperty()); if (index == -1) { ontology.dataPropertyAssertionAxioms(individual))) { int index = properties.indexOf(ax.getProperty()); if (index == -1) { continue; OWLObject obj = ax.getObject(); if (obj instanceof OWLLiteral) { List<String> langList = preferredLanguageMap.get(ax.getProperty()); if (langList != null) { int langIndex = langList.indexOf(lit.getLang()); if (langIndex != -1 && langIndex < lastLangMatchIndex) { lastLangMatchIndex = langIndex; candidateValue = ax.getObject(); candidateValue = ax.getObject();