diff --git a/biblio-tools/examples.http b/biblio-tools/examples.http index 685bf86..cac4312 100644 --- a/biblio-tools/examples.http +++ b/biblio-tools/examples.http @@ -7,13 +7,13 @@ Content-Type: application/json [ - { "value": "10.1016/j.fuel.2018.07.071" }, - { "value": "10.1007/s10980-018-0699-8" }, - { "value": "10.1159/000490004" }, - { "value": "10.1016/j.memsci.2018.08.024"}, - { "value": "10.1029/2018jd029272"}, - { "value": "10.4000/edc.9014"}, - { "value": "unknown"} + { "id":1, "value": "10.1016/j.fuel.2018.07.071" }, + { "id":2, "value": "10.1007/s10980-018-0699-8" }, + { "id":3, "value": "10.1159/000490004" }, + { "id":4, "value": "10.1016/j.memsci.2018.08.024"}, + { "id":5, "value": "10.1029/2018jd029272"}, + { "id":6, "value": "10.4000/edc.9014"}, + { "id":7, "value": "unknown"} ] ### @@ -24,13 +24,13 @@ Content-Type: application/json [ - { "value": "10.1016/j.fuel.2018.07.071" }, - { "value": "10.1007/s10980-018-0699-8" }, - { "value": "10.1159/000490004" }, - { "value": "10.1016/j.memsci.2018.08.024"}, - { "value": "10.1029/2018jd029272"}, - { "value": "10.4000/edc.9014"}, - { "value": "unknown"} + { "id":1, "value": "10.1016/j.fuel.2018.07.071" }, + { "id":2, "value": "10.1007/s10980-018-0699-8" }, + { "id":3, "value": "10.1159/000490004" }, + { "id":4, "value": "10.1016/j.memsci.2018.08.024"}, + { "id":5, "value": "10.1029/2018jd029272"}, + { "id":6, "value": "10.4000/edc.9014"}, + { "id":7, "value": "unknown"} ] ### @@ -54,13 +54,13 @@ Content-Type: application/json [ - { "value": "10.1016/j.fuel.2018.07.071" }, - { "value": "10.1007/s10980-018-0699-8" }, - { "value": "10.1159/000490004" }, - { "value": "10.1016/j.memsci.2018.08.024"}, - { "value": "10.1029/2018jd029272"}, - { "value": "10.4000/edc.9014"}, - { "value": "unknown"} + { "id":1, "value": "10.1016/j.fuel.2018.07.071" }, + { "id":2, "value": "10.1007/s10980-018-0699-8" }, + { "id":3, "value": "10.1159/000490004" }, + { "id":4, "value": "10.1016/j.memsci.2018.08.024"}, + { "id":5, "value": "10.1029/2018jd029272"}, + { "id":6, "value": "10.4000/edc.9014"}, + { "id":7, "value": "unknown"} ] ### @@ -69,12 +69,12 @@ Content-Type: application/json [ - { "value": "10.3998"}, - { "value": "10.1016" }, - { "value": "10.1007" }, - { "value": "10.1159" }, - { "value": "10.1037"}, - { "value": "unknown"} + { "id":1, "value": "10.3998"}, + { "id":2, "value": "10.1016" }, + { "id":3, "value": "10.1007" }, + { "id":4, "value": "10.1159" }, + { "id":5, "value": "10.1037"}, + { "id":6, "value": "unknown"} ] ### @@ -85,13 +85,13 @@ Content-Type: application/json [ - { "value": "10.1016/j.fuel.2018.07.071" }, - { "value": "10.1007/s10980-018-0699-8" }, - { "value": "10.1159/000490004" }, - { "value": "10.1016/j.memsci.2018.08.024"}, - { "value": "10.1029/2018jd029272"}, - { "value": "10.4000/edc.9014"}, - { "value": "unknown"} + { "id":1, "value": "10.1016/j.fuel.2018.07.071" }, + { "id":2, "value": "10.1007/s10980-018-0699-8" }, + { "id":3, "value": "10.1159/000490004" }, + { "id":4, "value": "10.1016/j.memsci.2018.08.024"}, + { "id":5, "value": "10.1029/2018jd029272"}, + { "id":6, "value": "10.4000/edc.9014"}, + { "id":7, "value": "unknown"} ] ### @@ -100,14 +100,14 @@ Content-Type: application/json [ - { "value": "10.1103/PhysRevLett.19.1264"}, - { "value": "10.1016/j.fuel.2018.07.071" }, - { "value": "10.1007/s10980-018-0699-8" }, - { "value": "10.1159/000490004" }, - { "value": "10.1016/j.memsci.2018.08.024"}, - { "value": "10.1029/2018jd029272"}, - { "value": "10.4000/edc.9014"}, - { "value": "unknown"} + { "id":1, "value": "10.1103/PhysRevLett.19.1264"}, + { "id":2, "value": "10.1016/j.fuel.2018.07.071" }, + { "id":3, "value": "10.1007/s10980-018-0699-8" }, + { "id":4, "value": "10.1159/000490004" }, + { "id":5, "value": "10.1016/j.memsci.2018.08.024"}, + { "id":6, "value": "10.1029/2018jd029272"}, + { "id":7, "value": "10.4000/edc.9014"}, + { "id":8, "value": "unknown"} ] ### @@ -116,14 +116,14 @@ Content-Type: application/json [ - { "value": "10.1103/PhysRevLett.19.1264"}, - { "value": "10.1016/j.fuel.2018.07.071" }, - { "value": "10.1007/s10980-018-0699-8" }, - { "value": "10.1159/000490004" }, - { "value": "10.1016/j.memsci.2018.08.024"}, - { "value": "10.1029/2018jd029272"}, - { "value": "10.4000/edc.9014"}, - { "value": "unknown"} + { "id":1, "value": "10.1103/PhysRevLett.19.1264"}, + { "id":2, "value": "10.1016/j.fuel.2018.07.071" }, + { "id":3, "value": "10.1007/s10980-018-0699-8" }, + { "id":4, "value": "10.1159/000490004" }, + { "id":5, "value": "10.1016/j.memsci.2018.08.024"}, + { "id":6, "value": "10.1029/2018jd029272"}, + { "id":7, "value": "10.4000/edc.9014"}, + { "id":8, "value": "unknown"} ] ### @@ -132,10 +132,10 @@ Content-Type: application/json [ - { "value": "10.1016/S0047-6374(98)00099-2"}, - { "value": "10.1016/S0167-4943(01)00186-8"}, - { "value": "10.1093/ageing/afm016"}, - { "value": ""} + { "id":1, "value": "10.1016/S0047-6374(98)00099-2"}, + { "id":2, "value": "10.1016/S0167-4943(01)00186-8"}, + { "id":3, "value": "10.1093/ageing/afm016"}, + { "id":4, "value": ""} ] ### @@ -174,9 +174,9 @@ Content-Type: application/json [ - { "value": "10.1016/S0047-6374(98)00099-2"}, - { "value": "10.1016/S0167-4943(01)00186-8"}, - { "value": "10.1093/ageing/afm016"}, - { "value": ""} + { "id":1, "value": "10.1016/S0047-6374(98)00099-2"}, + { "id":2, "value": "10.1016/S0167-4943(01)00186-8"}, + { "id":3, "value": "10.1093/ageing/afm016"}, + { "id":4, "value": ""} ] ### diff --git a/biblio-tools/v1/crossref/works/expand.ini b/biblio-tools/v1/crossref/works/expand.ini index d696ee7..bdff123 100644 --- a/biblio-tools/v1/crossref/works/expand.ini +++ b/biblio-tools/v1/crossref/works/expand.ini @@ -18,6 +18,9 @@ post.parameters.0.name = indent post.parameters.0.schema.type = boolean +# Rétablissons la coloration syntaxique (une ou deux apostrophes selon les besoins): ' +value = fix('').join('') + # Necessary plugins [use] plugin = basics @@ -34,6 +37,11 @@ path = indent value = true +# Passage des doi en minuscule pour être compatible unpaywall +[assign] +path = value +value = get('value').toLower() + # Début du traitement par lot [group] size = env('size') @@ -44,7 +52,7 @@ value = fix(self.length) path = output.0.filter -value = self().map('value').filter(x => x.match(/^10.\d{4,9}\/[^\s]+$/i)).map(x => 'doi:'.concat(x)).join(',') +value = self().map('value').filter(Boolean).filter(x => x.match(/^10.\d{4,9}\/[^\s]+$/i)).map(x => 'doi:'.concat(x)).join(',') path = input value = self() @@ -64,37 +72,21 @@ [map/OBJFlatten] -# Création d'un objet similaire à l'objet reponse +# Création d'un objet réponse [map/replace] -path = __id -value = get('doi.0') - +path = id +value = get('DOI').toLower() path = value value = self().omit(['indexed', 'reference']) -# Reformatage des DOIS (input) -[map] -path = input - -[map/replace] -path = __id -value = get('value') - -path = value -value = get('value') - -# Croissements des resultats et des dois (avec le champ __id comme clé) +# Croisements des resultats et des dois [exchange] -value = get('output').unionBy(self.input, '__id') +value = get('input').map((i) => ({ ...i, value:_.get(_.find(self.output, {id:i.value}), 'value') })) # Fin du traitement par lot [ungroup] -# Suppression des champs ajoutés -[exchange] -value = self().omit('__id') - -# On marque les réponses qui n'ont pas abouties +# On marque les réponses qui n'ont pas abouti [swing] test = has('value.DOI') reverse = true @@ -105,4 +97,3 @@ [dump] indent = env('indent', false) - diff --git a/biblio-tools/v1/istex/works/expand.ini b/biblio-tools/v1/istex/works/expand.ini index 9f6a60c..0c2425d 100644 --- a/biblio-tools/v1/istex/works/expand.ini +++ b/biblio-tools/v1/istex/works/expand.ini @@ -75,37 +75,20 @@ [map/OBJFlatten] -# Création d'un objet similaire à l'objet reponse +# Création d'un objet réponse [map/replace] -path = __id -value = get('doi.0') - +path = id +value = get('doi').toLower() path = value value = self().omit(['refBibs', 'enrichments', 'metadata', 'fulltext', 'annexes', 'covers']) -# Reformatage des DOIS (input) -[map] -path = input - -[map/replace] -path = __id -value = get('value') - -path = value -value = get('value') - -# Croissements des resultats et des dois (avec le champ __id comme clé) +# Croisements des resultats et des dois [exchange] -value = get('output').unionBy(self.input, '__id') +value = get('input').map((i) => ({ ...i, value:_.get(_.find(self.output, {id:i.value}), 'value') })) # Fin du traitement par lot [ungroup] - -# Suppression des champs ajoutés -[exchange] -value = self().omit('__id') - # On marque les réponses qui n'ont pas abouti [swing] test = has('value.arkIstex') @@ -114,14 +97,6 @@ [swing/assign] path = value value = fix('n/a') -# On marque les réponses qui n'ont pas abouties -[swing] -test = has('value.doi') -reverse = true - -[swing/assign] -path = value -value = fix('n/a') [dump] indent = env('indent', false) diff --git a/biblio-tools/v1/unpaywall/corhal.ini b/biblio-tools/v1/unpaywall/corhal.ini index 4a279d5..c4f3e90 100644 --- a/biblio-tools/v1/unpaywall/corhal.ini +++ b/biblio-tools/v1/unpaywall/corhal.ini @@ -52,7 +52,7 @@ # Création d'une requete graphql avec une liste de DOI [replace] path = output.0.query -value = self().map('value').map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi,is_oa,oa_status,has_repository_copy,oa_locations{host_type,is_best,license,url,url_for_landing_page,url_for_pdf,version}}}`) +value = self().map('value').filter(Boolean).map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi,is_oa,oa_status,has_repository_copy,oa_locations{host_type,is_best,license,url,url_for_landing_page,url_for_pdf,version}}}`) path = input value = self() @@ -81,6 +81,7 @@ path = value value = self() +# Croisements des resultats et des dois [exchange] value = get('input').map((i) => ({ ...i, value:_.get(_.find(self.output, {id:i.value}), 'value') })) @@ -97,4 +98,4 @@ value = fix('n/a') [dump] -indent = env('indent') +indent = env('indent', false) diff --git a/biblio-tools/v1/unpaywall/expand.ini b/biblio-tools/v1/unpaywall/expand.ini index 8ed8fb7..87bc0cc 100644 --- a/biblio-tools/v1/unpaywall/expand.ini +++ b/biblio-tools/v1/unpaywall/expand.ini @@ -52,7 +52,7 @@ # Création d'une requete graphql avec une liste de DOI [replace] path = output.0.query -value = self().map('value').map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi, is_oa, oa_status, has_repository_copy, best_oa_location { host_type }}}`) +value = self().map('value').map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi,is_oa,oa_status,has_repository_copy,oa_locations{host_type,is_best,license,url,url_for_landing_page,url_for_pdf,version}}}`) path = input value = self() @@ -76,8 +76,10 @@ # Création d'un objet réponse [map/replace] -path = __id +path = id value = get('doi').toLower() +path = value +value = self() path = value.is_oa value = get('is_oa') @@ -91,29 +93,14 @@ path = value.has_repository_copy value = get('has_repository_copy', 'n/a') -# Reformatage des DOIS (input) -[map] -path = input -# Création d'un objet similaire à l'objet reponse -[map/replace] -path = __id -value = get('value') - -path = value -value = self() - -# Croissements des resultats et des dois (avec le champ __id comme clé) +# Croisements des resultats et des dois [exchange] -value = get('output').unionBy(self.input, '__id') +value = get('input').map((i) => ({ ...i, value:_.get(_.find(self.output, {id:i.value}), 'value') })) # Fin du traitement par lot [ungroup] -# Suppression des champs ajoutés -[exchange] -value = self().omit('__id') - # On marque les réponses qui n'ont pas abouti [swing] test = has('value.is_oa') diff --git a/biblio-tools/v1/unpaywall/is_oa.ini b/biblio-tools/v1/unpaywall/is_oa.ini index 972fc4c..845ab66 100644 --- a/biblio-tools/v1/unpaywall/is_oa.ini +++ b/biblio-tools/v1/unpaywall/is_oa.ini @@ -52,7 +52,7 @@ # Création d'une requete graphql avec une liste de DOI [replace] path = output.0.query -value = self().map('value').map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi, is_oa}}`) +value = self().map('value').filter(Boolean).map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi,is_oa}}`) path = input value = self() @@ -76,35 +76,19 @@ # Création d'un objet réponse [map/replace] -path = __id +path = id value = get('doi').toLower() - path = value value = get('is_oa') -# Reformatage des DOIS (input) -[map] -path = input -# Création d'un objet similaire à l'objet reponse -[map/replace] -path = __id -value = get('value') - -path = value -value = self() - -# Croissements des resultats et des dois (avec le champ __id comme clé) +# Croisements des resultats et des dois [exchange] -value = get('output').unionBy(self.input, '__id') +value = get('input').map((i) => ({ ...i, value:_.get(_.find(self.output, {id:i.value}), 'value') })) # Fin du traitement par lot [ungroup] -# Suppression des champs ajoutés -[exchange] -value = self().omit('__id') - # On marque les réponses qui n'ont pas abouti [swing] test = get('value').isBoolean() @@ -115,4 +99,4 @@ value = fix('n/a') [dump] -indent = env('indent') +indent = env('indent', false) diff --git a/biblio-tools/v1/unpaywall/works/expand.ini b/biblio-tools/v1/unpaywall/works/expand.ini index 3ed9c8c..a527662 100644 --- a/biblio-tools/v1/unpaywall/works/expand.ini +++ b/biblio-tools/v1/unpaywall/works/expand.ini @@ -52,7 +52,7 @@ # Création d'une requete graphql avec une liste de DOI [replace] path = output.0.query -value = self().map('value').map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi,data_standard,genre,is_paratext,is_oa,journal_is_in_doaj,journal_is_oa,journal_issns,journal_issn_l,journal_name,oa_status,has_repository_copy,published_date,publisher,title,updated,year,oa_locations{host_type,is_best,license,url,url_for_landing_page,url_for_pdf},first_oa_location{host_type,is_best,license,pmh_id,updated,url,url_for_landing_page,url_for_pdf,version}}}`) +value = self().map('value').filter(Boolean).map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi,data_standard,genre,is_paratext,is_oa,journal_is_in_doaj,journal_is_oa,journal_issns,journal_issn_l,journal_name,oa_status,has_repository_copy,published_date,publisher,title,updated,year,oa_locations{host_type,is_best,license,url,url_for_landing_page,url_for_pdf},first_oa_location{host_type,is_best,license,pmh_id,updated,url,url_for_landing_page,url_for_pdf,version}}}`) path = input value = self() @@ -76,35 +76,18 @@ # Création d'un objet réponse [map/replace] -path = __id +path = id value = get('doi').toLower() - path = value value = self() -# Reformatage des DOIS (input) -[map] -path = input - -# Création d'un objet similaire à l'objet reponse -[map/replace] -path = __id -value = get('value') - -path = value -value = self() - -# Croissements des resultats et des dois (avec le champ __id comme clé) +# Croisements des resultats et des dois [exchange] -value = get('output').unionBy(self.input, '__id') +value = get('input').map((i) => ({ ...i, value:_.get(_.find(self.output, {id:i.value}), 'value') })) # Fin du traitement par lot [ungroup] -# Suppression des champs ajoutés -[exchange] -value = self().omit('__id') - # On marque les réponses qui n'ont pas abouti [swing] test = has('value.is_oa') @@ -115,4 +98,4 @@ value = fix('n/a') [dump] -indent = env('indent') +indent = env('indent', false) diff --git a/biblio-tools/v1/wos/works/expand.ini b/biblio-tools/v1/wos/works/expand.ini index 1d542e0..fe88082 100644 --- a/biblio-tools/v1/wos/works/expand.ini +++ b/biblio-tools/v1/wos/works/expand.ini @@ -18,6 +18,8 @@ post.parameters.0.name = indent post.parameters.0.schema.type = boolean +# Rétablissons la coloration syntaxique (une ou deux apostrophes selon les besoins): ' +value = fix('').join('') # Necessary plugins [use] @@ -38,6 +40,7 @@ path = token value = env('WOS_API_KEY') +# Passage des doi en minuscule pour être compatible unpaywall [assign] path = value value = get('value').toLower() @@ -76,44 +79,27 @@ retries = 3 noerror = false -# On supprime les réponses qui n'ont pas abouties +# Suppression des réponses qui n'ont pas abouties [map/remove] test = get('UID').isEmpty() [map/OBJFlatten] -# Création d'un objet similaire à l'objet reponse +# Création d'un objet réponse [map/replace] -path = __id +path = id value = get('dynamic_data/cluster_related/identifiers/identifier').find({ type: 'xref_doi'}).get('value').toLower() - path = value value = self() -# Reformatage des DOIS (input) -[map] -path = input - -[map/replace] -path = __id -value = get('value') - -path = value -value = get('value') - -# Croissements des resultats et des dois (avec le champ __id comme clé) +# Croisements des resultats et des dois [exchange] -value = get('output').unionBy(self.input, '__id') +value = get('input').map((i) => ({ ...i, value:_.get(_.find(self.output, {id:i.value}), 'value') })) # Fin du traitement par lot [ungroup] - -# Suppression des champs ajoutés -[exchange] -value = self().omit('__id') - -# On marque les réponses qui n'ont pas abouties +# On marque les réponses qui n'ont pas abouti [swing] test = get('value.UID').isEmpty()