-
Notifications
You must be signed in to change notification settings - Fork 4
/
xr2rml_geonames_annot.tpl.ttl
168 lines (149 loc) · 6.14 KB
/
xr2rml_geonames_annot.tpl.ttl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Mapping file generating the annotations for the geographical named entities found by entity-fishing.
#
# Author: Franck MICHEL, University Cote d'Azur, CNRS, Inria
#
# Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
@prefix xrr: <http://i3s.unice.fr/xr2rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix bibo: <http://purl.org/ontology/bibo/> .
@prefix dce: <http://purl.org/dc/elements/1.1/>.
@prefix dct: <http://purl.org/dc/terms/>.
@prefix fabio: <http://purl.org/spar/fabio/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix frbr: <http://purl.org/vocab/frbr/core#>.
@prefix oa: <http://www.w3.org/ns/oa#>.
@prefix prov: <http://www.w3.org/ns/prov#>.
@prefix schema: <http://schema.org/>.
@prefix wd: <http://www.wikidata.org/entity/>.
@prefix gn: <https://sws.geonames.org/>.
# Template file: replace placeholders
# - {{dataset}}: RDF dataset name e.g. "dataset-1-0"
# - {{collection}}: the MongoDB collection to query, e.g. entityfishing
# - {{documentpart}}: document part about which to produce annotations. One of title, abstract, body_text
# - {{namespace}}: The ISSA instance specific namespace, e.g http://data-issa.dhm.euromov.fr/
@prefix issa: <{{namespace}}>.
@prefix issapr: <{{namespace}}property/>.
@prefix issa-doc: <{{namespace}}document/>.
@prefix issa-ann: <{{namespace}}ann/>.
<#LS_entities>
a xrr:LogicalSource;
xrr:query """db.{{collection}}.find( {} )""";
#xrr:query """db.{{collection}}.find( { paper_id: "543654" } )""";
rml:iterator "$.{{documentpart}}.entities.*";
xrr:pushDown [ xrr:reference "$.paper_id"; xrr:as "paper_id" ].
<#TM_annotation>
a rr:TriplesMap;
xrr:logicalSource <#LS_entities>;
rr:subjectMap [
rr:template "{{namespace}}ann/sha1(gn_{$.paper_id}_{{documentpart}}_{$.rawName}_{$.offsetStart}_{$.offsetEnd})";
rr:class issa:GeographicAnnotation, prov:Entity;
];
rr:predicateObjectMap [
rr:predicate rdfs:isDefinedBy;
rr:objectMap [ rr:constant issa:{{dataset}}; rr:termType rr:IRI ];
];
rr:predicateObjectMap [
rr:predicate rdfs:label;
rr:objectMap [ rr:template "named entity '{$.rawName}'"; rr:termType rr:Literal ];
];
# rr:predicateObjectMap [
# rr:predicate dct:creator;
# rr:objectMap [ rr:constant "https://team.inria.fr/wimmics/"; rr:termType rr:IRI ];
# ];
rr:predicateObjectMap [
rr:predicate schema:about;
rr:objectMap [ rr:template "{{namespace}}document/{$.paper_id}" ];
];
# Annotation target
rr:predicateObjectMap [
rr:predicate oa:hasTarget;
rr:objectMap [
rr:template "{{namespace}}ann/target/sha1(gn_{$.paper_id}_{{documentpart}}_{$.rawName}_{$.offsetStart}_{$.offsetEnd})";
rr:termType rr:IRI;
];
];
# Annotation body
rr:predicateObjectMap [
rr:predicate oa:hasBody;
rr:objectMap [ rr:template "https://sws.geonames.org/{$.GeoNamesID}/" ];
];
# Annotation confidence
rr:predicateObjectMap [
rr:predicate issapr:confidence;
rr:objectMap [ xrr:reference "$.confidence_score"; rr:datatype xsd:decimal ];
];
# Provenance
rr:predicateObjectMap [
rr:predicate rdfs:isDefinedBy;
rr:objectMap [ rr:constant issa:{{dataset}}; rr:termType rr:IRI ];
];
rr:predicateObjectMap [
rr:predicate prov:wasAttributedTo;
rr:objectMap [ rr:constant issa:GeographicEntityExtractor; rr:termType rr:IRI ];
];
.
# Annotation target
<#TM_target>
a rr:TriplesMap;
xrr:logicalSource <#LS_entities>;
rr:subjectMap [
rr:template "{{namespace}}ann/target/sha1(gn_{$.paper_id}_{{documentpart}}_{$.rawName}_{$.offsetStart}_{$.offsetEnd})"
];
rr:predicateObjectMap [
rr:predicate oa:hasSource;
rr:objectMap [ rr:template "{{namespace}}document/{$.paper_id}#{{documentpart}}" ];
];
rr:predicateObjectMap [
rr:predicate oa:hasSelector;
rr:objectMap [
rr:template "{{namespace}}ann/selector/sha1(gn_{$.paper_id}_{{documentpart}}_{$.rawName}_{$.offsetStart}_{$.offsetEnd})";
rr:termType rr:IRI;
];
].
# Annotation target selector
<#TM_selector>
a rr:TriplesMap;
xrr:logicalSource <#LS_entities>;
rr:subjectMap [
rr:template "{{namespace}}ann/selector/sha1(gn_{$.paper_id}_{{documentpart}}_{$.rawName}_{$.offsetStart}_{$.offsetEnd})";
rr:class oa:TextPositionSelector, oa:TextQuoteSelector;
];
rr:predicateObjectMap [
rr:predicate oa:start;
rr:objectMap [ xrr:reference "$.offsetStart"; rr:datatype xsd:integer ];
];
rr:predicateObjectMap [
rr:predicate oa:end;
rr:objectMap [ xrr:reference "$.offsetEnd"; rr:datatype xsd:integer ];
];
rr:predicateObjectMap [
rr:predicate oa:exact;
rr:objectMap [ xrr:reference "$.rawName" ];
];
.
# Expected output:
#<http://data-issa.cirad.fr/ann/sha1_hash>
# a prov:Entity , oa:Annotation ;
# rdfs:label "named entity 'Paris'" ;
# issapr:confidence 0.7973 ;
# dct:subject "Sociology" , "Geology" , "Chemistry" ;
# schema:about <http://data-issa.cirad.fr/document/444682> ;
# oa:hasBody wd:Q90 ;
# oa:hasTarget <http://data-issa.cirad.fr/ann/target/sha1_hash> ;
# rdfs:isDefinedBy issa:issa-agritrop ;
# prov:wasAttributedTo issa:EntityFishing .
#
#<http://data-issa.cirad.fr/ann/target/sha1_hash>
# oa:hasSelector <http://data-issa.cirad.fr/ann/selector/sha1_hash> ;
# oa:hasSource <http://data-issa.cirad.fr/document/444682#title> .
#
#<http://data-issa.cirad.fr/ann/selector/sha1_hash>
# a oa:TextPositionSelector , oa:TextQuoteSelector ;
# oa:start 95 ;
# oa:end 100 ;
# oa:exact "Paris".