diff --git a/.vscode/settings.json b/.vscode/settings.json index 1a12a8a..d79f301 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,9 @@ { "markdown.extension.toc.updateOnSave": false, "python.linting.enabled": true, - "python.linting.flake8Enabled": true + "python.linting.flake8Enabled": true, + "markdownlint.config": { + "MD024": false, // MD024: Duplicate headings + "MD051": false // MD051: Broken link fragment (ex: #v1/teeft instead of #v1teeft) + } } \ No newline at end of file diff --git a/README.md b/README.md index 74db3e0..e2fde2d 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,12 @@ > **Note 2**: préférez plusieurs valeurs dans le tableau de l'exemple, pour > éviter que le script ne fasse abstraction du tableau (auquel cas il faudrait > l'ajouter à la main dans les exemples). +> +> **Note 3**: vous pouvez _nommer_ les exemples, en ajoutant `# @name +> identifiant` sur une ligne avant la requête (en remplaçant identifiant par une +> valeur unique). +> Ainsi vous pouvez appeler la commande `make example-metadata terms-extraction +> v1TeeftWithNumbersEn`. ### Déclarer la documentation Swagger diff --git a/terms-extraction/README.md b/terms-extraction/README.md index 278ddaa..36601f0 100644 --- a/terms-extraction/README.md +++ b/terms-extraction/README.md @@ -4,7 +4,7 @@ ## Teeft -Le service Teeft renvoie les cinq termes les plus spécificiques d'un texte, en +Le service Teeft renvoie les termes les plus spécificiques d'un texte, en français ou en anglais. ### Bibliographie @@ -40,7 +40,7 @@ | nb | nombre de termes à récupérer au maximum (de `1` à `Infinity`, `5` par défaut) | | indent | `true` ou `false`, indente le JSON résultat ou non (`false` par défaut) | -#### Exemple de teeft/fr +##### Exemple de teeft/fr En entrée: @@ -99,7 +99,7 @@ | nb | nombre de termes à récupérer au maximum (de `1` à `Infinity`, `5` par défaut) | | indent | `true` ou `false`, indente le JSON résultat ou non (`false` par défaut) | -#### Exemple de teeft/en +##### Exemple de teeft/en En entrée: @@ -142,3 +142,83 @@ } ] ``` + +#### v1/teeft/with-numbers/fr + +Prend en entrée un JSON avec deux champs: `id` et `value`, et renvoie un JSON +avec un tableau de 5 termes (par défaut) dans le champ `value`. + +Ne fonctionne correctement que sur un texte en français de plusieurs +paragraphes. +La différence par rapport à [v1/teeft/fr](#v1teeftfr) est que les chiffres sont +encodés avant traitement (et décodés après), ce qui peut produire des termes +incluant des nombres. + +##### Paramètres + +| nom | description | +| :----- | :---------------------------------------------------------------------------- | +| nb | nombre de termes à récupérer au maximum (de `1` à `Infinity`, `5` par défaut) | +| indent | `true` ou `false`, indente le JSON résultat ou non (`false` par défaut) | + +#### v1/teeft/with-numbers/en + +Prend en entrée un JSON avec deux champs: `id` et `value`, et renvoie un JSON +avec un tableau de 5 termes (au plus) dans le champ `value`. + +Ne fonctionne correctement que sur un texte en anglais de plusieurs paragraphes. + +Cette version `with-numbers` de [v1/teeft/en](#v1/teeft/en) encode les chiffres +avant de traiter le texte, et les décode ensuite, évitant ainsi certains +mécanismes d'élimination des nombres. + +##### Paramètres + +| nom | description | +| :----- | :---------------------------------------------------------------------------- | +| nb | nombre de termes à récupérer au maximum (de `1` à `Infinity`, `5` par défaut) | +| indent | `true` ou `false`, indente le JSON résultat ou non (`false` par défaut) | + +##### Exemple + +En entrée: + +```json +[ + { + "id": "MPES-ERM_ER2023_000737", + "value": "Flow control based 5 MW wind turbine enhanced energy production for hydrogen generation cost reduction" + }, + { + "id": "MPES-ERM_ER2023_001916", + "value": "Study on the Motion Characteristics of 10 MW Superconducting Floating Offshore Wind Turbine Considering 2nd Order Wave Effect" + } +] +``` + +En sortie: + +```json +[ + { + "id": "MPES-ERM_ER2023_000737", + "value": + [ + "flow control", + "5 mw wind turbine", + "energy production", + "hydrogen generation cost" + ] + }, + { + "id": "MPES-ERM_ER2023_001916", + "value": + [ + "motion characteristics", + "10 mw", + "offshore wind turbine", + "2nd order wave" + ] + } +] +``` diff --git a/terms-extraction/examples.http b/terms-extraction/examples.http index 846eb0f..4e57648 100644 --- a/terms-extraction/examples.http +++ b/terms-extraction/examples.http @@ -38,6 +38,41 @@ ] ### +# @name v1TeeftWithNumbersEn +# Extraction des termes de deux textes en anglais, en gardant les nombres +POST {{baseUrl}}/v1/teeft/with-numbers/en?indent=true HTTP/1.1 +Content-Type: application/json + +[ + { + "id": "MPES-ERM_ER2023_000737", + "value": "Flow control based 5 MW wind turbine enhanced energy production for hydrogen generation cost reduction" + }, + { + "id": "MPES-ERM_ER2023_001916", + "value": "Study on the Motion Characteristics of 10 MW Superconducting Floating Offshore Wind Turbine Considering 2nd Order Wave Effect" + } +] +### + +# @name v1TeeftWithNumbersFr +# Extraction des termes de deux textes en français, en gardant les nombres +POST {{baseUrl}}/v1/teeft/with-numbers/fr?indent=true HTTP/1.1 +Content-Type: application/json + +[ + { + "id": "MPES-ERM_ER2023_000737", + "value": "Production d'énergie améliorée par une turbine éolienne de 5 MW basée sur le contrôle du flux pour la réduction des coûts de production d'hydrogène" + }, + { + "id": "MPES-ERM_ER2023_001916", + "value": "Étude des caractéristiques de mouvement d'une éolienne offshore flottante supraconductrice de 10 MW en tenant compte de l'effet de vague du deuxième ordre" + } +] +### + + # Normalisation des termes de deux textes POST {{baseUrl}}/v1/tools/keywords-clean?indent=true HTTP/1.1 Content-Type: application/json diff --git a/terms-extraction/v1/teeft/with-numbers/en.ini b/terms-extraction/v1/teeft/with-numbers/en.ini new file mode 100644 index 0000000..2607cf2 --- /dev/null +++ b/terms-extraction/v1/teeft/with-numbers/en.ini @@ -0,0 +1,140 @@ +# OpenAPI Documentation - JSON format (dot notation) +mimeType = application/json + +post.operationId = post-v1-teeft-with-numbers-en +post.requestBody.content.application/json.example.0.id = MPES-ERM_ER2023_000737 +post.requestBody.content.application/json.example.0.value = Flow control based 5 MW wind turbine enhanced energy production for hydrogen generation cost reduction +post.requestBody.content.application/json.example.1.id = MPES-ERM_ER2023_001916 +post.requestBody.content.application/json.example.1.value = Study on the Motion Characteristics of 10 MW Superconducting Floating Offshore Wind Turbine Considering 2nd Order Wave Effectpost.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.requestBody.required = true +post.responses.default.content.application/json.example.0.id = MPES-ERM_ER2023_000737 +post.responses.default.content.application/json.example.0.value.0 = flow control +post.responses.default.content.application/json.example.0.value.1 = 5 mw wind turbine +post.responses.default.content.application/json.example.0.value.2 = energy production +post.responses.default.content.application/json.example.0.value.3 = hydrogen generation cost +post.responses.default.content.application/json.example.1.id = MPES-ERM_ER2023_001916 +post.responses.default.content.application/json.example.1.value.0 = motion characteristics +post.responses.default.content.application/json.example.1.value.1 = 10 mw +post.responses.default.content.application/json.example.1.value.2 = offshore wind turbine +post.responses.default.content.application/json.example.1.value.3 = 2nd order wave +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.responses.default.description = Termes extraits du texte envoyé +post.summary = Extrait des termes du texte en anglais en utilisant Teeft prenant en compte les nombres +post.tags.0: terms-extraction +post.parameters.0.description = Nombre maximal de termes à récupérer +post.parameters.0.in = query +post.parameters.0.name = nb +post.parameters.0.required = false +post.parameters.0.schema.type = number +post.parameters.1.description = Indenter le JSON résultant +post.parameters.1.in = query +post.parameters.1.name = indent +post.parameters.0.required = false +post.parameters.1.schema.type = boolean + +[use] +plugin = @ezs/basics +plugin = @ezs/teeft +plugin = @ezs/strings + +[JSONParse] +separator = * + +[encode] +path = value +from = 1 +to = one +from = 2 +to = two +from = 3 +to = three +from = 4 +to = four +from = 5 +to = five +from = 6 +to = six +from = 7 +to = seven +from = 8 +to = eight +from = 9 +to = nine +from = 0 +to = zero +prefix = inf +suffix = sup + +[replace] +path = content +value = get('value') + +path = path +value = get('id', 'n/a') + +[TeeftToLowerCase] +path = content + +[TeeftSentenceTokenize] +[TeeftTokenize] + +[TeeftNaturalTag] +lang = en + +[TeeftExtractTerms] +lang = en + +[TeeftFilterTags] +lang = en + +[TeeftRemoveNumbers] +[TeeftRemoveShortTerms] +[TeeftRemoveLongTerms] +[TeeftRemoveWeirdTerms] +[TeeftStopWords] +lang = en + +[TeeftSumUpFrequencies] +[TeeftSpecificity] +lang = en +sort = true + +[TeeftFilterMonoFreq] + +[replace] +path = id +value = get('path') + +path = value +value = get('terms').map('term').slice(0, env("nb", 5)) + +[map] +path = value + +[map/decode] +from = 1 +to = one +from = 2 +to = two +from = 3 +to = three +from = 4 +to = four +from = 5 +to = five +from = 6 +to = six +from = 7 +to = seven +from = 8 +to = eight +from = 9 +to = nine +from = 0 +to = zero +prefix = inf +suffix = sup + +[dump] +indent = env('indent', false) diff --git a/terms-extraction/v1/teeft/with-numbers/fr.ini b/terms-extraction/v1/teeft/with-numbers/fr.ini new file mode 100644 index 0000000..024e0c3 --- /dev/null +++ b/terms-extraction/v1/teeft/with-numbers/fr.ini @@ -0,0 +1,135 @@ +# OpenAPI Documentation - JSON format (dot notation) +mimeType = application/json + +post.operationId = post-v1-teeft-with-numbers-fr +post.requestBody.content.application/json.example.0.id = 1 +post.requestBody.content.application/json.example.0.value = Pour faciliter l’accès aux techniques de fouille de données notamment pour les non spécialistes, le service TDM de l’Inist-CNRS développe des web services autour du traitement de l’information scientifique et technique. Ces services peuvent être appelés en ligne de commande ou au sein de LODEX, outil libre de visualisation. La démonstration montre comment, à partir des informations présentes dans une notice bibliographique et plus particulièrement à partir d’une adresse d’auteur, l’identifiant RNSR (Répertoire national des structures de recherche) est attribué automatiquement au document initial et comment cette nouvelle donnée est exploitée au sein de LODEX. Ainsi, programme ou algorithme développé par des enseignants chercheurs pourrait être adapté pour devenir un web service et être utilisé par le plus grand nombre. +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.requestBody.required = true +post.responses.default.content.application/json.example.0.id = 1 +post.responses.default.content.application/json.example.0.value.0 = service tdm +post.responses.default.content.application/json.example.0.value.1 = web services +post.responses.default.content.application/json.example.0.value.2 = information scientifique +post.responses.default.content.application/json.example.0.value.3 = outil libre +post.responses.default.content.application/json.example.0.value.4 = informations présentes +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.responses.default.description = Termes extraits du texte envoyé +post.summary = Extrait des termes du texte en français en utilisant Teeft prenant en compte les nombres +post.tags.0: terms-extraction +post.parameters.0.description = Nombre maximal de termes à récupérer +post.parameters.0.in = query +post.parameters.0.name = nb +post.parameters.0.required = false +post.parameters.0.schema.type = number +post.parameters.1.description = Indenter le JSON résultant +post.parameters.1.in = query +post.parameters.1.name = indent +post.parameters.0.required = false +post.parameters.1.schema.type = boolean + +[use] +plugin = @ezs/basics +plugin = @ezs/teeft +plugin = @ezs/strings + +[JSONParse] +separator = * + +[encode] +path = value +from = 1 +to = one +from = 2 +to = two +from = 3 +to = three +from = 4 +to = four +from = 5 +to = five +from = 6 +to = six +from = 7 +to = seven +from = 8 +to = eight +from = 9 +to = nine +from = 0 +to = zero +prefix = inf +suffix = sup + +[replace] +path = content +value = get('value') + +path = path +value = get('id', 'n/a') + +[TeeftToLowerCase] +path = content + +[TeeftSentenceTokenize] +[TeeftTokenize] + +[TeeftNaturalTag] +lang = fr + +[TeeftExtractTerms] +lang = fr + +[TeeftFilterTags] +lang = fr + +[TeeftRemoveNumbers] +[TeeftRemoveShortTerms] +[TeeftRemoveLongTerms] +[TeeftRemoveWeirdTerms] +[TeeftStopWords] +lang = fr + +[TeeftSumUpFrequencies] +[TeeftSpecificity] +lang = fr +sort = true + +[TeeftFilterMonoFreq] + +[replace] +path = id +value = get('path') + +path = value +value = get('terms').map('term').slice(0, env("nb", 5)) + +[map] +path = value + +[map/decode] +from = 1 +to = one +from = 2 +to = two +from = 3 +to = three +from = 4 +to = four +from = 5 +to = five +from = 6 +to = six +from = 7 +to = seven +from = 8 +to = eight +from = 9 +to = nine +from = 0 +to = zero +prefix = inf +suffix = sup + +[dump] +indent = env('indent', false)