Skip to content

Commit 6445328

Browse files
committed
2 parents 70e3136 + e667908 commit 6445328

File tree

6 files changed

+37
-29
lines changed

6 files changed

+37
-29
lines changed

LidoRDFConverter.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ def add_triples(graph, mapping: x3ml.Mapping, recID: str, **kw) -> None:
115115
id_S = recID + '-' + id_S
116116
S = make_n4o_id(id_S, tag='S')
117117
all_triples = []
118-
all_triples.append((S, RF.RDF.type, make_short_uri(mapping.S.entity, tag='S')))
119-
#all_triples.append((S,make_short_uri('crm:P999'), RF.Literal(id_S)))
118+
all_triples.append(
119+
(S, RF.RDF.type, make_short_uri(mapping.S.entity, tag='S')))
120+
# all_triples.append((S,make_short_uri('crm:P999'), RF.Literal(id_S)))
120121
num_S_triples = len(all_triples)
121122
for po in mapping.POs:
122123
all_triples.extend(get_po_triples(S, recID, po, **kw))
@@ -135,8 +136,9 @@ def get_po_triples(S, recID, po: x3ml.PO, **kw) -> list:
135136
id_O = recID + '-' + info.id.strip()
136137
O = make_n4o_id(id_O, tag='O')
137138
if (O != S):
138-
triples.append((O, RF.RDF.type, make_short_uri(po.O.entity, tag='O')))
139-
#triples.append((O, make_short_uri('crm:P90_has_value'), RF.Literal(info.id.strip(), lang=info.lang)))
139+
triples.append(
140+
(O, RF.RDF.type, make_short_uri(po.O.entity, tag='O')))
141+
# triples.append((O, make_short_uri('crm:P90_has_value'), RF.Literal(info.id.strip(), lang=info.lang)))
140142
triples.append((S, P, O))
141143
else:
142144
if text := info.text:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ Therefore, you can use these shell commands:
102102

103103
~~~sh
104104
cd ./lidoapp_bp/static
105-
npm init -y
106-
npm install
105+
npm ci
106+
cd ../..
107107
~~~
108108

109109
Then start `app.py` (optionally with argument `--port`):

defaultMapping.x3ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
</info>
3737
<namespaces>
3838
<namespace prefix="rdfs" uri="http://www.w3.org/2000/01/rdf-schema#"/>
39+
<namespace prefix="rdf" uri="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
40+
<namespace prefix="skos" uri="http://www.w3.org/2004/02/skos/core#"/>
3941
<namespace prefix="xsd" uri="http://www.w3.org/2001/XMLSchema#"/>
4042
<namespace prefix="crm" uri="http://www.cidoc-crm.org/cidoc-crm/"/>
4143
<namespace prefix="lido" uri="http://www.lido-schema.org/"/>

getCidocInfo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ def graphFromFile(file_path):
1111
'http://www.cidoc-crm.org/cidoc-crm/'))
1212
graph.namespace_manager.bind('skos', rdflib.URIRef(
1313
'http://www.w3.org/2004/02/skos/core#'))
14+
graph.namespace_manager.bind('rdf', rdflib.URIRef(
15+
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'))
1416
graph.parse(file_path)
1517
return graph
1618

lidoapp_bp/templates/index.html

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
<datalist id="DLCidocClasses"></datalist>
1717
<datalist id="DLCidocProperties"></datalist>
1818
<datalist id="DLLidoClasses"></datalist>
19+
<style>
20+
.btn { margin-left: 0.8em; }
21+
h4 { padding: 0.2em; }
22+
.row { --bs-gutter-x: 2px; }
23+
</style>
1924
</head>
2025

2126
<body>
@@ -82,7 +87,7 @@ <h5 class="modal-title" id="uploadX3mlModalLabel">Uploading X3ml mappings</h5>
8287
<div class="modal-dialog">
8388
<div class="modal-content">
8489
<div class="modal-header">
85-
<h5 class="modal-title" id="uploadLidoModalLabel">Uploading Lido file</h5>
90+
<h5 class="modal-title" id="uploadLidoModalLabel">Upload LIDO/XML file</h5>
8691
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
8792
</div>
8893
<div class="modal-body">
@@ -103,14 +108,13 @@ <h5 class="modal-title" id="uploadLidoModalLabel">Uploading Lido file</h5>
103108
<div class="row">
104109
<div class="col-2"></div>
105110
<div class="col-8">
106-
<h4><span class="label label-default">Mappings (x3ml)</span></h4>
107-
<p>
108-
<button type="button" class="btn btn-primary btn-sm" @click="addMapping">Add mapping</button>&nbsp;
109-
<button type="button" class="btn btn-primary btn-sm" @click="clearMappings">Clear all</button>&nbsp;
110-
<button type="button" class="btn btn-primary btn-sm" @click="resetMappings">Reset</button>&nbsp;
111-
<button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#uploadX3mlModal">Upload</button>&nbsp;
112-
<a href="downloadX3ml" target="blank"><button class='btn btn-primary btn-sm'>Download</button></a>&nbsp;
113-
</p>
111+
<h4>Mappings (x3ml)
112+
<button type="button" class="btn btn-primary btn-sm" @click="addMapping">Add mapping</button>
113+
<button type="button" class="btn btn-primary btn-sm" @click="clearMappings">Clear all</button>
114+
<button type="button" class="btn btn-primary btn-sm" @click="resetMappings">Reset</button>
115+
<button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#uploadX3mlModal">Upload</button>
116+
<a href="downloadX3ml" target="blank"><button class='btn btn-primary btn-sm'>Download</button></a>
117+
</h4>
114118
<div id="acc" class="accordion accordion-flush" style="overflow-y: scroll; height:600px; width: 100%;">
115119
<div class="accordion-item" v-for="(mapping, i) in x3ml.mappings" :key="i">
116120
<h2 class="accordion-header" :id="'M' + i">
@@ -176,18 +180,15 @@ <h2 class="accordion-header" :id="'L' + j">
176180
</div>
177181
<div class="row">
178182
<div class="col">
179-
<h4>Lido source (xml)</h4>
180-
<p>
181-
<button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#uploadLidoModal">Upload Lido</button>&nbsp;
182-
<button type="button" class="btn btn-primary btn-sm" onclick="getLido(1)">Reset</button>&nbsp;
183-
</p>
183+
<h4>LIDO/XML
184+
<button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#uploadLidoModal">Upload</button>
185+
<button type="button" class="btn btn-primary btn-sm" onclick="getLido(1)">Reset</button>
186+
<button type="button" class="btn btn-success btn-sm" style="float:right" onclick="runMappings()">Apply mappings</button>
187+
</h4>
184188
<div id="lidoEditor" style="height:600px"></div>
185189
</div>
186190
<div class="col">
187-
<h4>RDF Output (ttl)</h4>
188-
<p>
189-
<button type="button" class="btn btn-success btn-sm" onclick="runMappings()">Apply mappings</button>&nbsp;
190-
</p>
191+
<h4>RDF/Turtle</h4>
191192
<div id="rdfEditor"></div>
192193
</div>
193194
</div>
@@ -415,10 +416,10 @@ <h4>RDF Output (ttl)</h4>
415416
}
416417
}).mount('#app');
417418

418-
function makeEditor(label, style = "ace/theme/monokai", fmt = "ace/mode/xml") {
419+
function makeEditor(label, fmt = "ace/mode/xml") {
419420
// Returns an ace editor object
420421
var ed = ace.edit(label);
421-
ed.setTheme(style);
422+
//ed.setTheme("") //ace/theme/monokai");
422423
ed.session.setMode(fmt);
423424
ed.setPrintMarginColumn(-1);
424425
return ed;
@@ -428,7 +429,7 @@ <h4>RDF Output (ttl)</h4>
428429
var lidoEditor = makeEditor("lidoEditor");
429430
lidoEditor.setValue(app.lido);
430431
lidoEditor.on('change', function() {onLidoChanged()});
431-
var rdfEditor = makeEditor("rdfEditor", "", "ace/mode/turtle");
432+
var rdfEditor = makeEditor("rdfEditor", "ace/mode/turtle");
432433
rdfEditor.setValue('')
433434

434435
function getLido(mode=0) {

x3ml.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def strip_elem_text(elem):
4848
'lido': 'http://www.lido-schema.org',
4949
'gml': 'http://www.opengis.net/gml',
5050
'skos': 'http://www.w3.org/2004/02/skos/core#',
51-
'xml': 'http://www.w3.org/XML/1998/namespace'
51+
'xml': 'http://www.w3.org/XML/1998/namespace',
52+
'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
5253
}
5354

5455

@@ -93,7 +94,7 @@ def transform_subs(path_to_subs, sub_elements):
9394

9495
def root_path_as_list(elem):
9596
'''Return the full lido path of an element'''
96-
tags = elem.tag.replace(f"{{{ used_namespaces.get('lido','') }}}", '')
97+
tags = elem.tag.replace(f"{{{used_namespaces.get('lido', '')}}}", '')
9798
parent = elem.getparent()
9899
if not_none(parent):
99100
tags = root_path_as_list(parent) + '/' + tags

0 commit comments

Comments
 (0)