Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #42 from Inist-CNRS/fix-json-protege
Browse files Browse the repository at this point in the history
fix: expand all properties
  • Loading branch information
touv authored Oct 26, 2020
2 parents 0d3f38b + 80d8632 commit 6ebdea1
Showing 1 changed file with 129 additions and 22 deletions.
151 changes: 129 additions & 22 deletions public/loaders/json-protege.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,84 @@ 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')

; BEGIN (expand onProperty) {
[expand]
path = http://www.w3.org/2002/07/owl#onProperty
;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.

; 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

[expand/exploding]

[expand/combine]
path = value.@id
primer = env('bufferID')
Expand All @@ -37,35 +98,81 @@ 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')
; } END.


; 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.

; 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') \
.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')))
value = self().omit('bufferID').mapValues((o) => Array.isArray(o) && o.length === 1 ? o.pop() : o)

[OBJFlatten]
; } END.


[remove]
reverse = true
test = get('rdfs:subClassOf/obo:IAO_0000594/@id').includes('obo:IAO_0000594')


[objects2columns]

0 comments on commit 6ebdea1

Please sign in to comment.