From d95bcfefa296a1c1b15d908c2dbd045fe04ca452 Mon Sep 17 00:00:00 2001 From: Nicolas Thouvenin Date: Wed, 21 Oct 2020 16:02:04 +0200 Subject: [PATCH 1/3] fix: expand all properties --- public/loaders/json-protege.ini | 98 ++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 27 deletions(-) diff --git a/public/loaders/json-protege.ini b/public/loaders/json-protege.ini index 8f67e4f..05b4820 100644 --- a/public/loaders/json-protege.ini +++ b/public/loaders/json-protege.ini @@ -9,23 +9,34 @@ plugin = lodex [JSONParse] separator = * - [bufferize] path = bufferID -[filter] -path = @type.0 -if = http://www.w3.org/2002/07/owl#Class - [env] path = bufferID value = get('bufferID') -[expand] -path = http://www.w3.org/2000/01/rdf-schema#subClassOf +; [expand] +; path = http://www.w3.org/2002/07/owl#onProperty +; file = ./json-protege-resolver.ini -[expand/exploding] +; [expand] +; path = http://www.w3.org/2002/07/owl#someValuesFrom +; file = ./json-protege-resolver.ini + +; [debug] +; [bufferize] +; path = bufferID +; [env] +; path = bufferID +; value = get('bufferID') + +; [expand] +; path = http://www.w3.org/2000/01/rdf-schema#subClassOf +; file = ./json-protege-resolver.ini + +[expand/exploding] [expand/combine] path = value.@id primer = env('bufferID') @@ -37,35 +48,68 @@ value = get('@id') path = value value = self().omit('bufferID') -; [expand/combine/OBJFlatten] -; safe = false -[expand/combine/exchange] -value = self() -[expand/combine/assign] +[expand/replace] +path = id +value = get('id') path = value -value = get('value').mapValues((o) => Array.isArray(o) && o.length === 1 ? o[0] : o) - +value = get('value.@id.value').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o) [expand/aggregate] [exchange] -value = self().mapValues((o) => Array.isArray(o) && o.length === 1 ? o[0] : o) +value = self().omit('bufferID').mapValues((o) => Array.isArray(o) && o.length === 1 ? o[0] : o) +; BEGIN (Use prefix) [OBJFlatten] +safe = false + +[OBJNamespaces] +prefix = dc: +namespace = http://purl.org/dc/terms/ + +prefix = dc: +namespace = http://purl.org/dc/elements/1.1/ + +prefix = place: +namespace = http://purl.org/ontology/places# + +prefix = rdfs: +namespace = http://www.w3.org/2000/01/rdf-schema# + +prefix = obo: +namespace = http://purl.obolibrary.org/obo/ + +prefix = swo: +namespace = http://www.ebi.ac.uk/swo/ + +prefix = swo: +namespace = http://www.ebi.ac.uk/efo/swo/ + +prefix = owl +namespace = http://www.w3.org/2002/07/owl# + +prefix = inist: +namespace = http://www.inist.fr/Ontology# + +prefix = skos: +namespace = http://www.w3.org/2004/02/skos/core# + +prefix = ontoTM: +namespace = http://data.loterre.fr/ontoTM# + +reference = (@id|@type)$ + +[OBJFlatten] +reverse = true +safe = false + +; END. -[exchange] -value = self().omit('bufferID') \ - .mapKeys((value, key) => key \ - .replace(/(http:[^#]+#)|\/@id\/value|@|(http:\/\/[^\/]+\/)/g, '') \ - .replace(/(id\/id)/g,'id')) \ - .mapValues((value, key) => (key.search(/(id|type)$/) === -1 || !value || typeof value !== 'string' \ - ? value \ - : value \ - .replace(/(http:[^#]+#)|\/@id\/value|@|(http:\/\/[^\/]+\/)/g, '') \ - .replace(/(id\/id)/g,'id'))) +[remove] +test = get('@id').includes('ontoTM:').thru(b => !b) -[objects2columns] +;[objects2columns] From 04d96d6a2b0600c8ff8b34a03a56e5224082213d Mon Sep 17 00:00:00 2001 From: Nicolas Thouvenin Date: Thu, 22 Oct 2020 10:49:25 +0200 Subject: [PATCH 2/3] more linear --- public/loaders/json-protege.ini | 71 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/public/loaders/json-protege.ini b/public/loaders/json-protege.ini index 05b4820..a4c276e 100644 --- a/public/loaders/json-protege.ini +++ b/public/loaders/json-protege.ini @@ -16,48 +16,48 @@ path = bufferID path = bufferID value = get('bufferID') -; [expand] -; path = http://www.w3.org/2002/07/owl#onProperty -; file = ./json-protege-resolver.ini +[expand] +path = http://www.w3.org/2002/07/owl#onProperty +file = ./json-protege-resolver.ini ; [expand] ; path = http://www.w3.org/2002/07/owl#someValuesFrom ; file = ./json-protege-resolver.ini -; [debug] -; [bufferize] -; path = bufferID +[bufferize] +path = bufferID -; [env] -; path = bufferID -; value = get('bufferID') +[env] +path = bufferID +value = get('bufferID') -; [expand] -; path = http://www.w3.org/2000/01/rdf-schema#subClassOf -; file = ./json-protege-resolver.ini + [expand] + path = http://www.w3.org/2000/01/rdf-schema#subClassOf + file = ./json-protege-resolver.ini -[expand/exploding] -[expand/combine] -path = value.@id -primer = env('bufferID') -prepend = buffers +; Inline +; [expand/exploding] +; [expand/combine] +; path = value.@id +; primer = env('bufferID') +; prepend = buffers -[expand/combine/replace] -path = id -value = get('@id') -path = value -value = self().omit('bufferID') +; [expand/combine/replace] +; path = id +; value = get('@id') +; path = value +; value = self().omit('bufferID') -[expand/replace] -path = id -value = get('id') -path = value -value = get('value.@id.value').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o) +; [expand/replace] +; path = id +; value = get('id') +; path = value +; value = get('value.@id.value').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o) -[expand/aggregate] +; [expand/aggregate] -[exchange] -value = self().omit('bufferID').mapValues((o) => Array.isArray(o) && o.length === 1 ? o[0] : o) +; [exchange] +; value = self().omit('bufferID') ; BEGIN (Use prefix) @@ -106,10 +106,17 @@ safe = false ; END. - +[assign] +path = rdfs:subClassOf +value = get('rdfs:subClassOf').reduce((obj, item) => ((obj[item['@id']] = item), obj), {}) [remove] -test = get('@id').includes('ontoTM:').thru(b => !b) +reverse = true +;test = get('rdfs:subClassOf.@id').includes('obo:IAO_0000594') +test = get('@id').includes('ontoTM') +[OBJFlatten] ;[objects2columns] + +;for debug[CSVString] From 80d863283e3f32a28058e1c438750fd3c0b7574a Mon Sep 17 00:00:00 2001 From: Nicolas Thouvenin Date: Thu, 22 Oct 2020 13:49:06 +0200 Subject: [PATCH 3/3] json-protege ready to be modelled --- public/loaders/json-protege.ini | 126 +++++++++++++++++++++++--------- 1 file changed, 91 insertions(+), 35 deletions(-) diff --git a/public/loaders/json-protege.ini b/public/loaders/json-protege.ini index a4c276e..50cab07 100644 --- a/public/loaders/json-protege.ini +++ b/public/loaders/json-protege.ini @@ -16,51 +16,102 @@ path = bufferID path = bufferID value = get('bufferID') +; BEGIN (expand onProperty) { [expand] path = http://www.w3.org/2002/07/owl#onProperty -file = ./json-protege-resolver.ini - -; [expand] -; path = http://www.w3.org/2002/07/owl#someValuesFrom -; file = ./json-protege-resolver.ini - +;file = ./json-protege-resolver.ini ; inline statements, it's more verbose but it's self-sufficient +[expand/exploding] +[expand/combine] +path = value.@id +primer = env('bufferID') +prepend = buffers + +[expand/combine/replace] +path = id +value = get('@id') +path = value +value = self().omit('bufferID') + +[expand/replace] +path = id +value = get('id') +path = value +value = get('value.@id.value').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o) + +[expand/aggregate] + +[exchange] +value = self().omit('bufferID') +; } END. + +; BEGIN (expand someValuesFrom) { +[expand] +path = http://www.w3.org/2002/07/owl#someValuesFrom +;file = ./json-protege-resolver.ini ; inline statements, it's more verbose but it's self-sufficient +[expand/exploding] +[expand/combine] +path = value.@id +primer = env('bufferID') +prepend = buffers + +[expand/combine/replace] +path = id +value = get('@id') +path = value +value = self().omit('bufferID') + +[expand/replace] +path = id +value = get('id') +path = value +value = get('value.@id.value').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o) + +[expand/aggregate] + +[exchange] +value = self().omit('bufferID') +; } END. + +; BEGIN (re-bufferize all nodes, with there enrichments) { [bufferize] path = bufferID [env] path = bufferID value = get('bufferID') +; } END. - [expand] - path = http://www.w3.org/2000/01/rdf-schema#subClassOf - file = ./json-protege-resolver.ini +; BEGIN (expand subClassOf) { +[expand] +path = http://www.w3.org/2000/01/rdf-schema#subClassOf +;file = ./json-protege-resolver.ini ; inline statements, it's more verbose but it's self-sufficient -; Inline -; [expand/exploding] -; [expand/combine] -; path = value.@id -; primer = env('bufferID') -; prepend = buffers +[expand/exploding] +[expand/combine] +path = value.@id +primer = env('bufferID') +prepend = buffers -; [expand/combine/replace] -; path = id -; value = get('@id') -; path = value -; value = self().omit('bufferID') +[expand/combine/replace] +path = id +value = get('@id') +path = value +value = self().omit('bufferID') -; [expand/replace] -; path = id -; value = get('id') -; path = value -; value = get('value.@id.value').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o) +[expand/replace] +path = id +value = get('id') +path = value +value = get('value.@id.value').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o) -; [expand/aggregate] +[expand/aggregate] -; [exchange] -; value = self().omit('bufferID') +[exchange] +value = self().omit('bufferID') +; } END. -; BEGIN (Use prefix) +; BEGIN (Use prefix) { [OBJFlatten] safe = false @@ -104,19 +155,24 @@ reference = (@id|@type)$ reverse = true safe = false -; END. +; } END. +; BEGIN (Simplify arrays, fields hierachy) { [assign] path = rdfs:subClassOf value = get('rdfs:subClassOf').reduce((obj, item) => ((obj[item['@id']] = item), obj), {}) +[exchange] +value = self().omit('bufferID').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o) + +[OBJFlatten] +; } END. + + [remove] reverse = true -;test = get('rdfs:subClassOf.@id').includes('obo:IAO_0000594') -test = get('@id').includes('ontoTM') +test = get('rdfs:subClassOf/obo:IAO_0000594/@id').includes('obo:IAO_0000594') -[OBJFlatten] -;[objects2columns] +[objects2columns] -;for debug[CSVString]