Skip to content

Commit 2bc8bdc

Browse files
committed
Zwischenstand
1 parent e14efcd commit 2bc8bdc

File tree

3 files changed

+55
-17
lines changed

3 files changed

+55
-17
lines changed

LidoRDFConverter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def add_triples(graph, mapping: x3ml.Mapping, recID: str, **kw):
127127
S = make_n4o_id(id_S, tag='S')
128128
all_triples = []
129129
all_triples.append((S, RF.RDF.type, make_short_uri(mapping.S.entity, tag='S')))
130-
# all_triples.append((S,make_short_uri('crm:P999'), RF.Literal(id_S)))
130+
#all_triples.append((S,make_short_uri('crm:P999'), RF.Literal(id_S)))
131131
num_S_triples = len(all_triples)
132132
for po in mapping.POs:
133133
all_triples.extend(get_po_triples(S, recID, po, **kw))
@@ -142,7 +142,7 @@ def get_po_triples(S, recID, po: x3ml.PO, **kw) -> list:
142142
if po.valid:
143143
P = make_short_uri(po.P.entity, tag='P')
144144
for info in po.infos:
145-
if info.mode == 'lidoID':
145+
if info.mode == 'lidoID' or info.mode == 'path':
146146
id_O = recID + '-' + info.id.strip()
147147
O = make_n4o_id(id_O, tag='O')
148148
if (O != S):

defaultMapping.x3ml

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<namespace prefix="geosparql" uri="http://www.ontotext.com/plugins/geosparql#"/>
4444
</namespaces>
4545
<mappings>
46-
<mapping skip='false'>
46+
<mapping skip="false">
4747
<domain>
4848
<source_node>//lido:lido</source_node>
4949
<target_node>
@@ -3056,6 +3056,42 @@
30563056
</entity>
30573057
</target_node>
30583058
</domain>
3059+
<link>
3060+
<path>
3061+
<source_relation>
3062+
<relation>lido:eventMaterialsTech/lido:materialsTech/lido:termMaterialsTech/skos:Concept/skos:prefLabel</relation>
3063+
</source_relation>
3064+
<target_relation>
3065+
<relationship>crm:P45_consists_of</relationship>
3066+
</target_relation>
3067+
</path>
3068+
<range>
3069+
<source_node>lido:eventMaterialsTech/lido:materialsTech/lido:termMaterialsTech/skos:Concept/skos:prefLabel</source_node>
3070+
<target_node>
3071+
<entity>
3072+
<type>http://www.w3.org/2000/01/rdf-schema#Literal</type>
3073+
</entity>
3074+
</target_node>
3075+
</range>
3076+
</link>
3077+
<link>
3078+
<path>
3079+
<source_relation>
3080+
<relation>lido:eventMaterialsTech/lido:materialsTech/lido:termMaterialsTech/skos:Concept[@rdf:about]</relation>
3081+
</source_relation>
3082+
<target_relation>
3083+
<relationship>crm:P45_consists_of</relationship>
3084+
</target_relation>
3085+
</path>
3086+
<range>
3087+
<source_node>lido:eventMaterialsTech/lido:materialsTech/lido:termMaterialsTech/skos:Concept[@rdf:about]</source_node>
3088+
<target_node>
3089+
<entity>
3090+
<type>http://www.w3.org/2000/01/rdf-schema#Literal</type>
3091+
</entity>
3092+
</target_node>
3093+
</range>
3094+
</link>
30593095
<link>
30603096
<path>
30613097
<source_relation>
@@ -4220,14 +4256,14 @@
42204256
<link>
42214257
<path>
42224258
<source_relation>
4223-
<relation>lido:measurementUnit</relation>
4259+
<relation>lido:measurementUnit/skos:Concept/skos:prefLabel</relation>
42244260
</source_relation>
42254261
<target_relation>
42264262
<relationship>crm:P91_has_unit</relationship>
42274263
</target_relation>
42284264
</path>
42294265
<range>
4230-
<source_node>lido:measurementUnit</source_node>
4266+
<source_node>lido:measurementUnit/skos:Concept/skos:prefLabel</source_node>
42314267
<target_node>
42324268
<entity>
42334269
<type>crm:E58_Measurement_Unit</type>
@@ -6651,14 +6687,14 @@
66516687
<link>
66526688
<path>
66536689
<source_relation>
6654-
<relation>lido:descriptiveMetadata/lido:objectClassificationWrap/lido:objectWorkTypeWrap/lido:objectWorkType</relation>
6690+
<relation>lido:descriptiveMetadata/lido:objectClassificationWrap/lido:objectWorkTypeWrap/lido:objectWorkType/skos:Concept/skos:prefLabel</relation>
66556691
</source_relation>
66566692
<target_relation>
66576693
<relationship>crm:P2_has_type</relationship>
66586694
</target_relation>
66596695
</path>
66606696
<range>
6661-
<source_node>lido:descriptiveMetadata/lido:objectClassificationWrap/lido:objectWorkTypeWrap/lido:objectWorkType</source_node>
6697+
<source_node>lido:descriptiveMetadata/lido:objectClassificationWrap/lido:objectWorkTypeWrap/lido:objectWorkType/skos:Concept/skos:prefLabel</source_node>
66626698
<target_node>
66636699
<entity>
66646700
<type>crm:E55_Type</type>
@@ -6669,14 +6705,14 @@
66696705
<link>
66706706
<path>
66716707
<source_relation>
6672-
<relation>lido:descriptiveMetadata/lido:objectClassificationWrap/lido:classificationWrap/lido:classification</relation>
6708+
<relation>lido:descriptiveMetadata/lido:objectClassificationWrap/lido:classificationWrap/lido:classification/skos:Concept/skos:prefLabel</relation>
66736709
</source_relation>
66746710
<target_relation>
66756711
<relationship>crm:P2_has_type</relationship>
66766712
</target_relation>
66776713
</path>
66786714
<range>
6679-
<source_node>lido:descriptiveMetadata/lido:objectClassificationWrap/lido:classificationWrap/lido:classification</source_node>
6715+
<source_node>lido:descriptiveMetadata/lido:objectClassificationWrap/lido:classificationWrap/lido:classification/skos:Concept/skos:prefLabel</source_node>
66806716
<target_node>
66816717
<entity>
66826718
<type>crm:E55_Type</type>
@@ -7150,10 +7186,10 @@
71507186
<link>
71517187
<path>
71527188
<source_relation>
7153-
<relation>lido:measurementUnit</relation>
7189+
<relation>lido:measurementUnit/skos:Concept/skos:prefLabel</relation>
71547190
</source_relation>
71557191
<target_relation>
7156-
<relationship>crm:P91_has_unit</relationship>
7192+
<relationship>crm:P91_has_unit/skos:Concept/skos:prefLabel</relationship>
71577193
</target_relation>
71587194
</path>
71597195
<range>
@@ -9434,7 +9470,7 @@
94349470
</range>
94359471
</link>
94369472
</mapping>
9437-
<mapping skip = 'true'>
9473+
<mapping skip = 'false'>
94389474
<domain>
94399475
<source_node>lido:event</source_node>
94409476
<target_node>
@@ -9446,7 +9482,7 @@
94469482
</entity>
94479483
</target_node>
94489484
</domain>
9449-
<link>
9485+
<link>
94509486
<path>
94519487
<source_relation>
94529488
<relation>lido:eventID</relation>
@@ -10501,7 +10537,7 @@
1050110537
</target_node>
1050210538
</range>
1050310539
</link>
10504-
<link skip="false">
10540+
<link>
1050510541
<path>
1050610542
<source_relation>
1050710543
<relation>lido:eventType/lido:term</relation>

x3ml.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,14 @@ def getLidoInfo(elem, i):
166166
text = elem.text.strip() if elem.text else ''
167167
lang = elem.get(expand_with_namespaces('xml:lang'), '')
168168
info = Info(text=text, attrib=elem.attrib, index=i, lang=lang)
169-
if rpl := getIDs(elem):
169+
if rpl := getIDs(elem): # Has an explicit ID
170170
info.mode = 'lidoID'
171171
info.id = rpl[0]
172-
else:
172+
elif len(elem) > 0 and not text: # Has subelements, use path
173173
info.mode = 'path'
174174
info.id = root_path_as_list(elem) + '/'+str(i)
175+
else: # Just text
176+
info.mode = 'text'
175177
return info
176178

177179

@@ -217,7 +219,7 @@ def isValid(self, elem) -> bool:
217219
if self.access.endswith('/text()'):
218220
pathValues = elem.xpath(f"./{self.access}", namespaces=used_namespaces)
219221
if self.values.intersection(pathValues):
220-
return True
222+
return True
221223
else:
222224
# assume path as an attribute label
223225
attrName = expand_with_namespaces(self.access)

0 commit comments

Comments
 (0)