diff --git a/nlp-tools2/README.md b/nlp-tools2/README.md index 87b1634..1b56143 100644 --- a/nlp-tools2/README.md +++ b/nlp-tools2/README.md @@ -1,5 +1,7 @@ # nlp-tools2 +**Service migré vers https://github.com/Inist-CNRS/web-services** + Cette instance propose des outils de traitement de la langue diff --git a/nlp-tools2/requirements.txt b/nlp-tools2/requirements.txt deleted file mode 100644 index ed440b4..0000000 --- a/nlp-tools2/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pycld3 -spacy==2.3.5 -en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz diff --git a/nlp-tools2/v1/detect-lang.ini b/nlp-tools2/v1/detect-lang.ini deleted file mode 100644 index 278f8f6..0000000 --- a/nlp-tools2/v1/detect-lang.ini +++ /dev/null @@ -1,62 +0,0 @@ -# OpenAPI Documentation - JSON format (dot notation) -mimeType = application/json -post.operationId = post-v1-detect-lang -post.description = Détecte la langue d'un texte et renvoie un code langue sur 2 caractères -post.responses.default.description = Renvoie un Json composé d'`id`, `value` avec `value` un code langue sur 2 caractères -post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream -post.summary = Détection de langue -post.tags.0 = NLP -post.requestBody.required = true -post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream -post.parameters.0.in = query -post.parameters.0.name = path -post.parameters.0.schema.type = string -post.parameters.0.description = The path in each object to enrich with an Python script -post.parameters.1.in = query -post.parameters.1.name = indent -post.parameters.1.schema.type = boolean -post.parameters.1.description = Indent or not the JSON Result - -# Examples -post.requestBody.content.application/json.example.0.id = 1 -post.requestBody.content.application/json.example.0.value = The COVID-19 pandemic, also known as the coronavirus pandemic, is an ongoing global pandemic of coronavirus disease 2019 (COVID-19) caused by severe acute respiratory syndrome coronavirus2 (SARS-CoV-2). It was first identified in December 2019 in Wuhan, China. The World Health Organization declared the outbreak a Public Health Emergency of International Concern on 20 January 2020, and later a pandemic on 11 March 2020. As of 2 April 2021, more than 129 million cases have been confirmed, with more than 2.82 million deaths attributed to COVID-19, making it one of the deadliest pandemics in history. -post.requestBody.content.application/json.example.1.id = 2 -post.requestBody.content.application/json.example.1.value = In the southern French Massif Central, the Montagne Noire axial zone is a NE-SW elongated granite-migmatite dome emplaced within Visean south-verging recumbent folds and intruded by syn- to late-migmatization granitoids. The tectonic setting of this dome is still disputed, thus several models have been proposed. In order to better understand the emplacement mechanism of this dome, petrofabric and Anisotropy of Magnetic Susceptibility (AMS) studies have been carried out. In the granites and migmatites that form the dome core, magmatic texture and to a lesser extent weak solid-state texture are dominant. As a paramagnetic mineral, biotite is the main carrier of the magnetic susceptibility. On the basis of 135 AMS sites, the magnetic fabrics appear as independent of the lithology but related to the dome architecture. Coupling our results with previous structural and geochronological studies, allows us to propose a new emplacement model. Between 340-325 Ma, the Palaeozoic series underwent a compressional deformation represented by nappes and recumbent folds involving the thermal event leading to partial melting. Until ~325-310 Ma, the dome emplacement was assisted by diapiric processes. An extensional event took place at 300 Ma, after the emplacement of the late to post-migmatitic granitic plutons. In the northeast side of the dome, a brittle normal-dextral faulting controlled the opening of the Graissessac coal-basin. -post.requestBody.content.application/json.example.2.id = 3 -post.requestBody.content.application/json.example.2.value = La pandémie de Covid-19 est une pandémie d'une maladie infectieuse émergente, appelée la maladie à coronavirus 2019 ou Covid-19, provoquée par le coronavirus SARS-CoV-2, apparue à Wuhan le 16 novembre 20193, dans la province de Hubei (en Chine centrale), avant de se propager dans le monde. L'Organisation mondiale de la santé (OMS) alerte dans un premier temps la République populaire de Chine et ses autres états membres, puis prononce l'état d'urgence de santé publique de portée internationale le 30 janvier 2020. -post.requestBody.content.application/json.example.3.id = 4 -post.requestBody.content.application/json.example.3.value = Au dernier recensement de 2018, la commune comptait 46 513 habitants appelés les Carcassonnais. Carcassonne est la ville principale de la Carcassonne Agglo 111 452 habitants (2016), de l'aire urbaine de Carcassonne 99 448 habitants (2017)1 et de son unité urbaine qui compte 48 633 habitants (2017). Occupée depuis le Néolithique, Carcassonne se trouve dans la plaine de l'Aude entre deux grands axes de circulation reliant l'Atlantique à la mer Méditerranée et le Massif central aux Pyrénées. La ville est connue pour la Cité de Carcassonne, ensemble architectural médiéval restauré par Viollet-le-Duc au xixe siècle et inscrit au patrimoine mondial de l'UNESCO depuis 1997. -post.requestBody.content.application/json.example.4.id = 5 -post.requestBody.content.application/json.example.4.value = Par rapport à la période écoulée, le fait d'avoir appris après coup que des circulaires imposaient de manière retroactive le retrait de jours de congés pour des personnes qui s'étaient mises en ASA pour cause de garde d'enfants m'a semblé particulièrement injuste et m'a mis vraiment en colère. J'aurais eu besoin de soutien à ce niveau là de la part du CNRS, car faire l'école à la maison était un travail à temps plein aussi nécessaire à la nation que mon travail au CNRS.Par rapport au satisfaction, j'ai trouvé que le télétravail me convenait bien. -post.responses.default.content.application/json.example.0.id = 1 -post.responses.default.content.application/json.example.0.value = en -post.responses.default.content.application/json.example.1.id = 2 -post.responses.default.content.application/json.example.1.value = en -post.responses.default.content.application/json.example.2.id = 3 -post.responses.default.content.application/json.example.2.value = fr -post.responses.default.content.application/json.example.3.id = 4 -post.responses.default.content.application/json.example.3.value = fr -post.responses.default.content.application/json.example.4.id = 5 -post.responses.default.content.application/json.example.4.value = fr - -[use] -plugin = @ezs/spawn -plugin = @ezs/basics -plugin = @ezs/storage -plugin = @ezs/analytics - -[JSONParse] -separator = * - -[expand] -path = env('path', 'value') -size = 100 -# in production mode, uncomment the following line -# cache = boost - -[expand/exec] -# command should be executable ! -command = ./v1/detect_lang.py - -[dump] -indent = env('indent', false) diff --git a/nlp-tools2/v1/detect_lang.py b/nlp-tools2/v1/detect_lang.py deleted file mode 100644 index ba4a1a1..0000000 --- a/nlp-tools2/v1/detect_lang.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Created on Thu Jun 17 15:18:10 2021 - -@author: cuxac - -A partir d'un texte (pas d'un mot) affiche le code langue du texte (2 caractères) si ça probabilité est supérieure au seuil de 0.85 - -""" - -import json - -import sys - -import cld3 - - -#fin=json.loads(json.dumps([{ -#"id":1, -#"value":"The COVID-19 pandemic, also known as the coronavirus pandemic, is an ongoing global pandemic of coronavirus disease 2019 (COVID-19) caused by severe acute respiratory syndrome coronavirus2 (SARS-CoV-2). It was first identified in December 2019 in Wuhan, China. The World Health Organization declared the outbreak a Public Health Emergency of International Concern on 20 January 2020, and later a pandemic on 11 March 2020. As of 2 April 2021, more than 129 million cases have been confirmed, with more than 2.82 million deaths attributed to COVID-19, making it one of the deadliest pandemics in history." -#}, -#{"id":2, -#"value":"In the southern French Massif Central, the Montagne Noire axial zone is a NE-SW elongated granite-migmatite dome emplaced within Visean south-verging recumbent folds and intruded by syn- to late-migmatization granitoids. The tectonic setting of this dome is still disputed, thus several models have been proposed. In order to better understand the emplacement mechanism of this dome, petrofabric and Anisotropy of Magnetic Susceptibility (AMS) studies have been carried out. In the granites and migmatites that form the dome core, magmatic texture and to a lesser extent weak solid-state texture are dominant. As a paramagnetic mineral, biotite is the main carrier of the magnetic susceptibility. On the basis of 135 AMS sites, the magnetic fabrics appear as independent of the lithology but related to the dome architecture. Coupling our results with previous structural and geochronological studies, allows us to propose a new emplacement model. Between 340-325 Ma, the Palaeozoic series underwent a compressional deformation represented by nappes and recumbent folds involving the thermal event leading to partial melting. Until ~325-310 Ma, the dome emplacement was assisted by diapiric processes. An extensional event took place at 300 Ma, after the emplacement of the late to post-migmatitic granitic plutons. In the northeast side of the dome, a brittle normal-dextral faulting controlled the opening of the Graissessac coal-basin." -#}, -#{"id":3, -# "value":"La pandémie de Covid-19 est une pandémie d'une maladie infectieuse émergente, appelée la maladie à coronavirus 2019 ou Covid-19, provoquée par le coronavirus SARS-CoV-2, apparue à Wuhan le 16 novembre 20193, dans la province de Hubei (en Chine centrale), avant de se propager dans le monde. L'Organisation mondiale de la santé (OMS) alerte dans un premier temps la République populaire de Chine et ses autres états membres, puis prononce l'état d'urgence de santé publique de portée internationale le 30 janvier 2020."} -#, -#{"id":4, -# "value":"Au dernier recensement de 2018, la commune comptait 46 513 habitants appelés les Carcassonnais. Carcassonne est la ville principale de la Carcassonne Agglo 111 452 habitants (2016), de l'aire urbaine de Carcassonne 99 448 habitants (2017)1 et de son unité urbaine qui compte 48 633 habitants (2017). Occupée depuis le Néolithique, Carcassonne se trouve dans la plaine de l'Aude entre deux grands axes de circulation reliant l'Atlantique à la mer Méditerranée et le Massif central aux Pyrénées. La ville est connue pour la Cité de Carcassonne, ensemble architectural médiéval restauré par Viollet-le-Duc au xixe siècle et inscrit au patrimoine mondial de l'UNESCO depuis 1997."} -#, -#{"id":5, -#"value":"Par rapport à la période écoulée, le fait d'avoir appris après coup que des circulaires imposaient de manière retroactive le retrait de jours de congés pour des personnes qui s'étaient mises en ASA pour cause de garde d'enfants m'a semblé particulièrement injuste et m'a mis vraiment en colère. J'aurais eu besoin de soutien à ce niveau là de la part du CNRS, car faire l'école à la maison était un travail à temps plein aussi nécessaire à la nation que mon travail au CNRS.Par rapport au satisfaction, j'ai trouvé que le télétravail me convenait bien." -#} -#])) - - -for line in sys.stdin: - data=json.loads(line) - - text=data['value'] - if cld3.get_language(text).probability>0.85: - - data['value']=cld3.get_language(text).language#,round(cld3.get_language(text).probability,2) - - else: - data['value']='unknown' - - - - - sys.stdout.write(json.dumps(data)) - sys.stdout.write('\n') - diff --git a/nlp-tools2/v1/lemma.ini b/nlp-tools2/v1/lemma.ini deleted file mode 100644 index 7fe8a7c..0000000 --- a/nlp-tools2/v1/lemma.ini +++ /dev/null @@ -1,57 +0,0 @@ -# OpenAPI Documentation - JSON format (dot notation) -mimeType = application/json -post.operationId = post-v1-lemma -post.description = Lemmatise un texte en anglais -post.responses.default.description = Renvoie un Json composé de`id`, `value` avec `value` un texte anglais lemmatisé en minuscule -post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream -post.summary = Lemmatisation de textes en anglais -post.tags.0 = NLP -post.requestBody.required = true -post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream -post.parameters.0.in = query -post.parameters.0.name = path -post.parameters.0.schema.type = string -post.parameters.0.description = The path in each object to enrich with an Python script -post.parameters.1.in = query -post.parameters.1.name = indent -post.parameters.1.schema.type = boolean -post.parameters.1.description = Indent or not the JSON Result - -# Examples -post.requestBody.content.application/json.example.0.id = 1 -post.requestBody.content.application/json.example.0.value.0 = rocks -post.requestBody.content.application/json.example.0.value.1 = are -post.requestBody.content.application/json.example.0.value.2 = images analysis -post.requestBody.content.application/json.example.1.id = 2 -post.requestBody.content.application/json.example.1.value = Computers -post.requestBody.content.application/json.example.2.id = 3 -post.requestBody.content.application/json.example.2.value = As of 2 April 2021, more than 129 million cases have been confirmed, with more than 2.82 million deaths attributed to COVID-19, making it one of the deadliest pandemics in history. -post.responses.default.content.application/json.example.0.id = 1 -post.responses.default.content.application/json.example.0.value.0 = rock -post.responses.default.content.application/json.example.0.value.1 = be -post.responses.default.content.application/json.example.0.value.2 = image analysis -post.responses.default.content.application/json.example.1.id = 2 -post.responses.default.content.application/json.example.1.value = computer -post.responses.default.content.application/json.example.2.id = 3 -post.responses.default.content.application/json.example.2.value = as of 2 April 2021 , more than 129 million case have be confirm , with more than 2.82 million death attribute to COVID-19 , make -PRON- one of the deadly pandemic in history . - -[use] -plugin = @ezs/spawn -plugin = @ezs/basics -plugin = @ezs/storage -plugin = @ezs/analytics - -[JSONParse] - -[expand] -path = env('path', 'value') -size = 100 -# in production mode, uncomment the following line -# cache = boost - -[expand/exec] -# command should be executable ! -command = ./v1/ws_lemmatization.py - -[dump] -indent = env('indent', false) diff --git a/nlp-tools2/v1/ws_lemmatization.py b/nlp-tools2/v1/ws_lemmatization.py deleted file mode 100644 index 999b17c..0000000 --- a/nlp-tools2/v1/ws_lemmatization.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Created on Thu Sep 29 16:57:23 2022 - -@author: cuxac -""" -import json -import sys -import spacy -nlp=spacy.load('en_core_web_sm', disable = ['parser','ner']) - - -for line in sys.stdin: - data=json.loads(line) - i=data['value'] - if type(i)==str and (len(i.split(' '))==1 and len(i.split('-'))==1 and len(i.split('/'))==1): - i=i.replace("*"," ").strip() - data["value"]=nlp(i)[0].lemma_ - elif type(i)==list: - ll=list() - for j in i: - j=j.replace('*',' ').strip() - if len(j.split())==1: - ll.append(nlp(j)[0].lemma_) - else: - ll.append(' '.join([w.lemma_ for w in nlp(j)])) - - data['value']=ll - else: - i=i.replace('*',' ').strip() - sent=' '.join([w.lemma_ for w in nlp(i)]) - - data['value']=sent - - sys.stdout.write(json.dumps(data)) - sys.stdout.write('\n')