diff --git a/conditor-dumps/.gitignore b/conditor-dumps/.gitignore index 68bbe88..46c8107 100644 --- a/conditor-dumps/.gitignore +++ b/conditor-dumps/.gitignore @@ -1,3 +1,4 @@ +01-query/*.txt 02-download/*.json 03-create-fields/*.json 04-enrich/*.json diff --git a/conditor-dumps/02-download.ini b/conditor-dumps/02-download.ini index 88db004..248d0f4 100644 --- a/conditor-dumps/02-download.ini +++ b/conditor-dumps/02-download.ini @@ -40,22 +40,41 @@ path = affiliations [map/map/assign] -path = ApilRnsr +path = ApilRnsr1 value = get("rnsr") [map/map/swing] -test = get("ApilRnsr").isEmpty() - +test = get("ApilRnsr1").isEmpty() [map/map/swing/assign] path = ApilRnsr value = get("enrichments.rnsr", []) \ .filter(rnsr => !["200612821P", "200018571R", "199812965F", "201523784S"].includes(rnsr)) +# On rassemble tous les RNSR au niveau de la notice (ceux en provenance de +# authors.*.rnsr et ceux en provenance de authors.*.affiliations.*) +# dans allAuthorsRnsr +[assign] +path=ApilRnsr2 +value= get("authors").map("rnsr").flatten() + +[assign] +path = allApilRnsr1 +; value= get("authors").map("affiliations").map("ApilRnsr1") +value= get("authors").flatMap("affiliations").flatMap("ApilRnsr1") + +[assign] +path= ApilRnsr +value= get("allApilRnsr1").concat(self.ApilRnsr2).compact().uniq() + # Garde un identifiant [assign] path = sourceUidChain value = get("business.sourceUidChain") +#On ajoute un objet pour attribuer 'OA - Inconnu' aux null ou undefined +path = enrichments.openAccess.unpaywall.oaLocations +value = get("enrichments.openAccess.unpaywall.oaLocations",[{"hostType":"OA - Inconnu"}]) + # Supprime les champs inutiles pour les études bibliométriques [exchange] -value = omit(['business','origins','technical']) +value = omit(['business','origins','technical','allApilRnsr1','ApilRnsr2']) diff --git a/conditor-dumps/04-enrich.ini b/conditor-dumps/04-enrich.ini index 49e1b97..57b1ea5 100644 --- a/conditor-dumps/04-enrich.ini +++ b/conditor-dumps/04-enrich.ini @@ -9,54 +9,42 @@ # Quand les RNSR ne sont pas fournis dans authors.*.affiliations.*.rnsr # on utilise le Web Service qui les met au même niveau dans wsRnsr -[map] -path = authors - -[map/map] -path = affiliations # Récupère les infos Loterre 2XK -[map/map/assign] +[assign] path = ws.loterre2xk value = get("ApilRnsr") -[map/map/expand] +[expand] path = ws.loterre2xk -[map/map/expand/exploding] -[map/map/expand/expand] +[expand/exploding] + +[expand/expand] path = value size = 100 cacheName = 04-2xk-expand -[map/map/expand/expand/URLConnect] +[expand/expand/URLConnect] url = https://loterre-resolvers.services.inist.fr/v1/2XK/identify timeout = 120000 noerror = true -[map/map/expand/aggregate] +[expand/aggregate] + +# On récupère tous les null, undefined, n/a qui viennent d'ApilRnsr et des +# champs qui en découlent afin de faire un zip ultérieur et que chaque tableau +# ait autant de valeurs. # Récupère les informations -[map/map/assign] +[assign] # Les éléments de ws.loterre2xk sont dans le même ordre que ApilRnsr, # et il y en a autant. path = ApilWsLaboIntitule -value = get("ws.loterre2xk").castArray().filter(Boolean).filter(x => (typeof x !== 'string') ) \ - .map((item) => item["prefLabel@fr"] ?? "n/a") +; value = get("ws.loterre2xk").castArray().filter(x => (typeof x !== 'string') ).map((item) => item["prefLabel@fr"] ?? "n/a") +value = get("ws.loterre2xk").castArray().map((item) => (item && item["prefLabel@fr"]) ?? "n/a") [assign] - -; path = ApilWsLaboSigle -; value = get("ws.rnsr").map("value").flatten().map("sigle") - -path = ApilWsLaboIntitule -value = get("authors").flatMap("affiliations").flatMap("ApilWsLaboIntitule").uniq() - -[assign] -# Concatène et dédoublonne tous les RNSR -path = ApilRnsr -value = get("authors").flatMap("affiliations").flatMap("ApilRnsr").uniq() - # Supprime les accents et met en majuscules path = tmp.ApilWsLaboIntitule value = get("ApilWsLaboIntitule").castArray().filter(Boolean) \ @@ -65,18 +53,27 @@ .toUpperCase() \ ) +# Loterre ne renvoie pas de sigle +; [assign] +; path = ApilWsSigleLaboIntitule +; value = get("ApilWsLaboSigle").castArray().filter(Boolean) \ +; .map((sigle,i) => [ \ +; sigle, \ +; _.get(self,"tmp.ApilWsLaboIntitule")[i] \ +; ] \ +; .filter(Boolean) \ +; .join(" - ")) + +#On récupère les nouvelles infos de Loterre sur les DR, puis fait tourner une table afin d'y mettre les intitulés +[env] +path=number2labelDR +value=fix({"01": "DR01 Ile-de-France Villejuif","02": "DR02 Paris-Centre","04": "DR04 Ile-de-France Gif-sur-Yvette","05": "DR05 Ile-de-France Meudon","16": "DR16 Paris-Normandie","06": "DR06 Centre Est","10": "DR10 Alsace","08": "DR08 Centre Limousin Poitou Charente","17": "DR17 Bretagne et Pays de la Loire","18": "DR18 Hauts-de-France","07": "DR07 Rhône Auvergne","11": "DR11 Alpes","12": "DR12 Provence et Corse","20": "DR20 Côte d'Azur","13": "DR13 Occitanie Est","14": "DR14 Occitanie Ouest","15": "DR15 Aquitaine"}) + [assign] -path = ApilWsSigleLaboIntitule -value = get("ApilWsLaboSigle").castArray().filter(Boolean) \ - .map((sigle,i) => [ \ - sigle, \ - _.get(self,"tmp.ApilWsLaboIntitule")[i] \ - ] \ - .filter(Boolean) \ - .join(" - ")) +path=ApilWsDr +value=get("ws.loterre2xk").flatMap("delegationRegionale_dep").compact().map(n => env("number2labelDR")[n]) # Récupère les instituts du CNRS à partir des RNSR - [assign] path = ApilWsInstitutCnrs value = get("ApilRnsr").castArray().filter(Boolean) \ @@ -100,18 +97,98 @@ [assign] path = ApilWsInstitutCnrs -value = get("ApilWsInstitutCnrs").castArray().filter(Boolean) \ - .map("value") \ - .filter(institut => institut && institut !== "n/a") +value = get("ApilWsInstitutCnrs").castArray() # S'il y a au moins un institut, il y a au moins une affiliation CNRS [assign] path = ApilWsIsCnrs value = get("ApilWsInstitutCnrs").thru(array => Boolean(array.length)) - ################################################################ -# Homogénéise les types de document +#interrogation d'Openalex depuis le champs doi https://biblio-tools.services.inist.fr/v1/openalex/works/expand +#Pas d'omit sur ce champs, les valeurs apc peuvent eventuellement servir pour d'autres cas +[assign] +path=ApilWsOpenalex +value = get("doi") + +[expand] +path = ApilWsOpenalex +size = 100 + +[expand/URLConnect] +url = https://biblio-tools.services.inist.fr/v1/openalex/works/expand +timeout = 90007 +noerror = true + +# Données Open Access host type modifiées à partir d'un champ fulltext, si hal est présent +#Transformer des données inconnues de 'HostType' en repository si absence d'un DOI mais présence de Hal dans 'fulltext' +[assign] +path=ApilOaLocationsHal +value=get("enrichments.openAccess.unpaywall.oaLocations").map("hostType").concat([self.fulltextUrl].map((value)=>value && value.replace(/^((?!hal).)*$/,"@@@@").replace(/.*hal.*/,"repository"))).uniq().filter((value, index, collection)=>{if(!(value === "OA - Inconnu" && collection[index+1] === "repository" )){return true}}).filter(value=>value!=="@@@@").compact() + +#Transformer des données inconnues en "green" si absence d'un DOI mais présence de "repository" dans 'ApilOaLocationsHal' +[assign] +path=ApilOaStatusHal +value=get("enrichments.openAccess.unpaywall.oaStatus").replace(/^$/,"OA - Inconnu").castArray().concat(self.ApilOaLocationsHal).compact().join(",").replace(/OA - Inconnu,repository|OA - Non,repository|closed,repository/g,"green").split(",").head().capitalize().replace("Oa - inconnu","OA - Inconnu") + +##Transformer des données inconnues en OA-Oui si absence d'un DOI mais présence de "green" dans 'ApiloaStatusHal' +[assign] +path=ApilIsOaHal +value=get("ApilOaStatusHal","OA - Inconnu").replace("closed","OA - Non").replace(/^((?!OA).)*$/,"OA - Oui") + +#On traduit les voies d'acces. Sort pour placer "publisher" avant "repository", replace puis si les 2 valeurs sont présentes, on remplace par "commun" +[assign] +path=ApilTypeDaccesHal +value=get("ApilOaLocationsHal").sort().replace("repository","Archive seule").replace("publisher","Editeur seul").replace("Editeur seul,Archive seule","Commun") + +#on crée un nouveau champ où l'on récupère les valeurs de "apc_list/value". Si value = 0 alors la publi est diamant. On remplace donc "0" par "diamond" et efface tout le reste. On concatène ensuite avec enrichments/openAccess/unpaywall/oaStatus qui donne les couleurs de l'OA. Puis on retire "gold" lorsqu'il est associé à "diamond" +[assign] +path=ApilOaStatusDiamond +value=get("ApilWsOpenalex").castArray().map("apc_list/value").replace(/^(?!0$).*$/,"").replace(/^0$/,"diamond").concat(_.get(self,"enrichments.openAccess.unpaywall.oaStatus")).filter((value, index, collection)=>{if(!(value === "gold" && collection[index-1] === "diamond" )){return true}}).last().capitalize().replace(/^$/,"OA - Inconnu") + + +#on crée un nouveau champ où l'on cumule les nouvelles données de 'ApilOaStatusDiamond' et 'ApilOaStatusHal' +[assign] +path=ApilOaStatusDiamondHal +value=get("ApilOaStatusDiamond").concat(self.ApilOaStatusHal).uniq().filter((value, index, collection)=>{if(!(value === "OA - Inconnu" && collection[index+1] === "Green" )){return true}}).filter((value, index, collection)=>{if(!(value === "Gold" && collection[index-1] === "Diamond" )){return true}}).toString() + +#Transformations spécifiques pour créer des valuers compatibles avec VEga-lite pour la création de graphiques +[assign] +path=ApilGraphSourceEditeurIsOa +value=get("enrichments.openAccess.unpaywall.isOa").replace(/^((?!Oui).)*$/,"null").prepend("OA=").append((";TypeAcces="+self.ApilTypeDaccesHal).replace(/Commun|Editeur seul/g,"Editeur").replace(/OA - Non|Archive seule|OA - Inconnu/g,"null")) + +[assign] +path=ApilGraphSourceEditeurIsOaHal +value=get("ApilIsOaHal").replace(/^((?!Oui).)*$/,"null").prepend("OA=").append((";TypeAcces="+self.ApilTypeDaccesHal).replace(/Commun|Editeur seul/g,"Editeur").replace(/OA - Non|Archive seule|OA - Inconnu/g,"null")) + +#On détermine l'ordre de provenance des notices composants la notice Conditor +[assign] +path = ApilProvenance +value = get("sourceUidChain").replace(/\$.*?!/g,"!").split("!").compact() + +#On concatène 'volume', 'issue' et 'pages.range' dans un seul champ +[assign] +path = ApilCollation +value = get("host.volume").concat(_.get(self,"host.issue")).concat(_.get(self,"host.pages.range")).join(" / ") + +#Récupère les fulltext d'unpaywall si le champs 'fulltexturl' (qui vient de conditor) est nul dans une colonne nommée ApilFullText (je ne sais pas comment on déclare le nom de la colonne dans ce cas précis) + +[assign] +path = fulltextUrl +value = get("fulltextUrl").castArray().compact() + +[swing] +test = get("fulltextUrl").isEmpty() + +[swing/assign] +path = fulltextUrl +value=get("enrichments.openAccess.unpaywall.oaLocations").filter(item=>item.hostType==="repository").map(item=>item.url) + +; [assign] +; path = value +; value = get('fulltextUrl').castArray().uniq() + +#Homogénéise les types de document [assign] path = ApilWsTypeDoc value = get("originalGenre").trim()