snikproject / ontology

Public SNIK Ontology. An ontology of information management in hospitals.
https://snikproject.github.io/ontology/
Other
10 stars 1 forks source link

Split page literals #311

Closed ThomasPause closed 4 years ago

ThomasPause commented 5 years ago

Pages should be integers, comma separated literals such as "123, 345" are thus invalid. Split those up into two triples.

KonradHoeffner commented 4 years ago

See also https://github.com/IMISE/snik-ontology/issues/332.

KonradHoeffner commented 4 years ago

Happens in ob and bb:

select distinct ?g
{
 graph ?g
{ ?s ?p ?page.}
 filter(regex(str(?p),"page","i"))
 filter(regex(str(?page),","))
}
KonradHoeffner commented 4 years ago

First, delete empty pages:

sparql
with <http://www.snik.eu/ontology/ob>
delete 
{
 ?s ?p ?page.
}
{
 ?s ?p ?page.
 filter(regex(str(?p),"page","i"))
 filter(str(?page)="")
}
sparql
with <http://www.snik.eu/ontology/bb>
delete 
{
 ?s ?p ?page.
}
{
 ?s ?p ?page.
 filter(regex(str(?p),"page","i"))
 filter(str(?page)="")
}
KonradHoeffner commented 4 years ago

Fix datatype

sparql
with <http://www.snik.eu/ontology/he-unconsolidated>
delete 
{
 ?s ?p ?page.
}
insert
{
 ?s ?p ?pagep.
}
where
{
 ?s ?p ?page.
 filter(regex(str(?p),"page","i"))
 bind(STRDT(str(?page),xsd:positiveInteger) as ?pagep)
}

Other graphs analogously.

KonradHoeffner commented 4 years ago

Split ob

Test

construct
{
 ?s ?p ?before.
 ?s ?p ?after.

}
from sniko:ob
where
{
 ?s ?p ?page.
 filter(regex(str(?p),"page","i"))
 filter(regex(str(?page),","))

 BIND(strdt(strbefore(replace(?page," ",""),","),xsd:positiveInteger) as ?before)
 BIND(strdt(strafter(replace(?page," ",""),","),xsd:positiveInteger) as ?after)
}
sparql
with <http://www.snik.eu/ontology/ob>
delete
{
 ?s ?p ?page.
}
insert
{
 ?s ?p ?before.
 ?s ?p ?after.
}
where
{
 ?s ?p ?page.
 filter(regex(str(?p),"page","i"))
 filter(regex(str(?page),","))

 BIND(strdt(strbefore(replace(?page," ",""),","),xsd:positiveInteger) as ?before)
 BIND(strdt(strafter(replace(?page," ",""),","),xsd:positiveInteger) as ?after)
}
KonradHoeffner commented 4 years ago

Split bb

sparql
with <http://www.snik.eu/ontology/bb>
delete
{
 ?s ?p ?page.
}
insert
{
 ?s ?p ?before.
 ?s ?p ?after.
}
where
{
 ?s ?p ?page.
 filter(regex(str(?p),"page","i"))
 filter(regex(str(?page),","))

 BIND(strdt(strbefore(replace(?page," ",""),","),xsd:positiveInteger) as ?before)
 BIND(strdt(strafter(replace(?page," ",""),","),xsd:positiveInteger) as ?after)
}
KonradHoeffner commented 4 years ago

Now we have some page triples that don't match the datatype:

select distinct ?p ?page
{
 ?s ?p ?page.
 filter(regex(str(?p),"page","i"))
 filter(xsd:int(?page)!=?page)
}
p page
http://www.snik.eu/ontology/bb/tripelPage "manuell hinzugefügt"^^http://www.w3.org/2001/XMLSchema#positiveInteger
http://www.snik.eu/ontology/bb/tripelPage "manuell ergänzt"^^http://www.w3.org/2001/XMLSchema#positiveInteger
http://xmlns.com/foaf/0.1/homepage "http://www.snik.eu"^^http://www.w3.org/2001/XMLSchema#positiveInteger
http://xmlns.com/foaf/0.1/homepage "http://www.snik.eu/"^^http://www.w3.org/2001/XMLSchema#positiveInteger
http://www.snik.eu/ontology/bb/page "manuell hinzugefügt"^^http://www.w3.org/2001/XMLSchema#positiveInteger
http://www.snik.eu/ontology/meta/DefinitionDEPage "manuell hinzugefügt"^^http://www.w3.org/2001/XMLSchema#positiveInteger
http://www.snik.eu/ontology/ob/tripelPage "manuell hinzugefügt"^^http://www.w3.org/2001/XMLSchema#positiveInteger
KonradHoeffner commented 4 years ago

Fix foaf:homepage

sparql
with <http://www.snik.eu/ontology/bb>
delete
{
?s ?p "http://www.snik.eu"^^<http://www.w3.org/2001/XMLSchema#positiveInteger>.
}
insert
{
 ?s ?p <http://www.snik.eu>.
}
where
{
?s ?p "http://www.snik.eu"^^<http://www.w3.org/2001/XMLSchema#positiveInteger>.
}

Analogously for the other graphs.

KonradHoeffner commented 4 years ago

For unknown reasons, the conductor does not execute the following query without an error message, so the "manuell hinzugefügt" triples stay with the incorrect datatype for now:

sparql
with <http://www.snik.eu/ontology/bb>
delete
{
?s ?p "manuell hinzugefügt"^^<http://www.w3.org/2001/XMLSchema#positiveInteger>.
}
insert
{
 ?s ?p "manuell hinzugefügt".
}
where
{
?s ?p "manuell hinzugefügt"^^<http://www.w3.org/2001/XMLSchema#positiveInteger>.
}