Skip to content

Commit

Permalink
improve annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Sep 1, 2024
1 parent 0bc3324 commit 6929f7b
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 24 deletions.
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pipelines/import.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ _:ProcessDocumentFinal
[
sparql:in-memory\/query ( "../queries/transform-cas.rq"^^p:FileContents )
]
[
sparql:in-memory\/update ( "../queries/expand-property-values.ru"^^p:FileContents )
]
[
sparql:in-memory\/update ( "../queries/collapse-nested-quantitative-values.ru"^^p:FileContents )
]
[
base:flatten ()
]
Expand Down
27 changes: 27 additions & 0 deletions queries/collapse-nested-quantitative-values.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
PREFIX schema: <http://schema.org/>

DELETE {
?quantitativeValue ?p ?nested .
?nested
a schema:QuantitativeValue ;
schema:value ?value ;
schema:unitCode ?unit .
}
INSERT {
?quantitativeValue ?p ?value .
?quantitativeValue schema:unitCode ?unit .
}
WHERE {
?quantitativeValue
a schema:QuantitativeValue ;
?p ?nested .

?nested
a schema:QuantitativeValue ;
schema:value ?value ;
.

OPTIONAL {
?nested schema:unitCode ?unit .
}
}
16 changes: 16 additions & 0 deletions queries/expand-property-values.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PREFIX schema: <http://schema.org/>

DELETE {
?s schema:additionalProperty ?o .
}
INSERT {
?s schema:additionalProperty
[
a schema:PropertyValue ;
schema:value ?o ;
] .
}
WHERE {
?s schema:additionalProperty ?o .
FILTER (isLiteral(?o))
}
67 changes: 46 additions & 21 deletions queries/transform-cas.rq
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CONSTRUCT {

?dataSheetId
a wikibus:DataSheet ;
schema:name ?vehicleSofaText ;
schema:name ?vehicleText ;
dcterms:subject ?wikibusVehicleId ;
mads:hasSource ?dataSheetSourceId .

Expand All @@ -34,8 +34,9 @@ CONSTRUCT {
.

?quantitativeId
a schema:QuantitativeValue ;
schema:position ?quantitativePosition
a ?quantitativeType ;
schema:position ?quantitativePosition ;
schema:name ?quantitativeSofaText ;
.

?entityId
Expand All @@ -53,6 +54,12 @@ where {
tcas:Annotation-end ?measureEnd .
?sofa cas:Sofa-sofaString ?sofaString .

FILTER EXISTS {
[] a <uima:webanno.custom.Link> ;
<uima:webanno.custom.Link-Dependent> ?measure ;
<uima:webanno.custom.Link-property> [] .
}

OPTIONAL {
?measure <uima:webanno.custom.Measure-Unit> ?unit .
}
Expand All @@ -76,15 +83,22 @@ where {
# vehicles
?vehicle a <uima:webanno.custom.BusorCoach> ;
tcas:Annotation-begin ?vehicleBegin ;
tcas:Annotation-end ?vehicleEnd ;
<uima:webanno.custom.BusorCoach-id> ?wikibusVehicleId .
tcas:Annotation-end ?vehicleEnd .
?sofa cas:Sofa-sofaString ?sofaString .

OPTIONAL {
?vehicle <uima:webanno.custom.BusorCoach-id> ?wikibusVehicleId
}
OPTIONAL {
?measure <uima:webanno.custom.BusorCoach-Textfix> ?vehicleTextfix .
}

?meta a <uima:webanno.custom.Brochure> ;
<uima:webanno.custom.Brochure-id> ?brochureId .

BIND(iri(concat("https://new.wikibus.org/brochure/", str(?brochureId))) as ?brochureUri)
BIND(SUBSTR(?sofaString, ?vehicleBegin + 1, ?vehicleEnd - ?vehicleBegin) as ?vehicleSofaText)
BIND(COALESCE(?vehicleTextfix, ?vehicleSofaText) as ?vehicleText)
BIND(
iri(concat("https://new.wikibus.org/data-sheet/", str(?brochureId), "/", str(?vehicleBegin), "-", str(?vehicleEnd)))
as ?dataSheetId
Expand All @@ -101,7 +115,7 @@ where {
?engine <uima:webanno.custom.Engine-Textfix> ?textfix .
}

BIND(SUBSTR(?sofaString, ?engineBegin - 1, ?engineEnd - ?engineBegin) as ?engineSofaText)
BIND(SUBSTR(?sofaString, ?engineBegin + 1, ?engineEnd - ?engineBegin) as ?engineSofaText)
BIND(COALESCE(?textfix, ?engineSofaText) AS ?engineText)
BIND(iri(concat("urn:bnode:", str(?engineBegin), "-", str(?engineEnd))) as ?engineId)
} UNION {
Expand Down Expand Up @@ -160,7 +174,8 @@ where {
?dependent a <uima:webanno.custom.Textfragment> .
}
FILTER NOT EXISTS {
?dependent a <uima:webanno.custom.Entity> ; <uima:webanno.custom.Entity-ID> [] .
?dependent a <uima:webanno.custom.Entity> ;
<uima:webanno.custom.Entity-ID> [] .
}

BIND(iri(concat("urn:bnode:", str(?dependentBegin), "-", str(?dependentEnd))) as ?to)
Expand Down Expand Up @@ -198,24 +213,34 @@ where {
FILTER (?quantitativePosition > 0)
}

OPTIONAL {
BIND(schema:PropertyValue as ?quantitativeIsPropertyValue)
FILTER EXISTS {
?link a <uima:webanno.custom.Link> ;
<uima:webanno.custom.Link-Dependent> ?quantitative ;
<uima:webanno.custom.Link-property> schema:additionalProperty .
}
}

BIND(COALESCE(?quantitativeIsPropertyValue, schema:QuantitativeValue) as ?quantitativeType)
BIND(SUBSTR(?sofaString, ?quantitativeBegin + 1, ?quantitativeEnd - ?quantitativeBegin) as ?quantitativeSofaText)
BIND(iri(concat("urn:bnode:", str(?quantitativeBegin), "-", str(?quantitativeEnd))) as ?quantitativeId)
} UNION {
# enties
?entity a <uima:webanno.custom.Entity> ;
tcas:Annotation-begin ?entityBegin ;
tcas:Annotation-end ?entityEnd .
?sofa cas:Sofa-sofaString ?sofaString .
# enties
?entity a <uima:webanno.custom.Entity> ;
tcas:Annotation-begin ?entityBegin ;
tcas:Annotation-end ?entityEnd .
?sofa cas:Sofa-sofaString ?sofaString .

FILTER NOT EXISTS {
?entity <uima:webanno.custom.Entity-ID> [] .
}
OPTIONAL {
?entity <uima:webanno.custom.Entity-Textfix> ?textfix .
}
FILTER NOT EXISTS {
?entity <uima:webanno.custom.Entity-ID> [] .
}
OPTIONAL {
?entity <uima:webanno.custom.Entity-Textfix> ?textfix .
}

BIND(SUBSTR(?sofaString, ?entityBegin + 1, ?entityEnd - ?entityBegin) as ?entitySofaText)
BIND(COALESCE(?textfix, ?entitySofaText) as ?entityText)
BIND(iri(concat("urn:bnode:", str(?entityBegin), "-", str(?entityEnd))) as ?entityId)
BIND(SUBSTR(?sofaString, ?entityBegin + 1, ?entityEnd - ?entityBegin) as ?entitySofaText)
BIND(COALESCE(?textfix, ?entitySofaText) as ?entityText)
BIND(iri(concat("urn:bnode:", str(?entityBegin), "-", str(?entityEnd))) as ?entityId)
}
}
52 changes: 52 additions & 0 deletions schemas/wikibus.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,45 @@ wikibus:angleOfDeparture
dcterms:relation wd:Q63258867 ;
.

wikibus:adBlueTankCapacity
a rdf:Property ;
rdfs:label
"AdBlue tank capacity"@en,
"AdBlue-Tankkapazität"@de,
"capacité du réservoir AdBlue"@fr,
"capacidad del depósito AdBlue"@es,
"capacidade do tanque AdBlue"@pt,
"capacità del serbatoio AdBlue"@it,
"AdBlue tank kapasitesi"@tr,
"pojemność zbiornika AdBlue"@pl ;
.

wikibus:floorHeight
a rdf:Property ;
rdfs:label
"floor height"@en,
"Einstiegshöhe"@de,
"hauteur du plancher"@fr,
"altura del suelo"@es,
"altura do piso"@pt,
"altezza del pavimento"@it,
"Zemin yüksekliği"@tr,
"wysokość podłogi"@pl ;
.

wikibus:seatPitch
a rdf:Property ;
rdfs:label
"seat pitch"@en,
"Sitzabstand"@de,
"espacement des sièges"@fr,
"distancia entre asientos"@es,
"distância entre assentos"@pt,
"passo del sedile"@it,
"Koltuk aralığı"@tr,
"rozstaw siedzeń"@pl ;
.

wikibus:turningCircle
a rdf:Property ;
rdfs:label
Expand Down Expand Up @@ -389,6 +428,19 @@ wikibus:additionalCapacity
"liczba miejsc dodatkowych"@pl ;
.

wikibus:totalCapacity
a rdf:Property ;
rdfs:label
"total capacity"@en,
"Gesamtkapazität"@de,
"capacité totale"@fr,
"capacidad total"@es,
"capacidade total"@pt,
"capacità totale"@it,
"Toplam kapasite"@tr,
"łączna liczba miejsc"@pl ;
.

wikibus:length
a rdf:Property ;
rdfs:label
Expand Down

0 comments on commit 6929f7b

Please sign in to comment.