Skip to content

[irc3-species]: match Perl reference behaviour - #484

Open
parmentf wants to merge 4 commits into
mainfrom
services/irc3-species/fix-silences
Open

parmentf wants to merge 4 commits into
mainfrom
services/irc3-species/fix-silences

Conversation

@parmentf

@parmentf parmentf commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Align the species extractor with the Perl script:

  • Compare strings by code point in the binary search, as locale collation reordered accented keys and broke lookups
  • Enable case-sensitive matching
  • Find abbreviated genus forms (e.g. "T. recurvata") in the second pass and drop ambiguous abbreviations
  • Search partial matches backwards from the insertion point only
  • Support -t and -c command line options

Align the species extractor with the Perl script:

- Compare strings by code point in the binary search, as locale
  collation reordered accented keys and broke lookups
- Enable case-sensitive matching
- Find abbreviated genus forms (e.g. "T. recurvata") in the second
  pass and drop ambiguous abbreviations
- Search partial matches backwards from the insertion point only
- Support -t and -c command line options
@parmentf parmentf self-assigned this Sep 7, 2026
@parmentf parmentf added the bug Something isn't working label Sep 7, 2026
@parmentf

parmentf commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Causes racines (portage Perl → Node, fidélisé au IRC3sp.pl v4.5.1 de Dominique)

Erreur de Camille Cause racine Correction
Serra do Navio mammarenavirus, Rio Grande phlebovirus, Pacific Coast orthonairovirus, Citrus aurantium subsp. junos, Mus musculus airolensis (faux positifs) findPartialMatches testait le motif des 2 premiers mots d'une entrée de table et sortait l'entrée longue comme canonique (ex. « Serra do » dans « Serra do Mar ») Tester uniquement le terme complet de la table, marche arrière depuis le point d'insertion, comme le recherche() du Perl
Lichen usnea (faux positif) Le script ignorait l'option -c (sensible à la casse) passée par irc3sp.ini — le Perl l'utilisait ; en insensible, « lichen Usnea » correspondait au basionyme « Lichen usnea » Parse des arguments -t/-c dans le .mjs (le README les documentait déjà)
Tillandsia recurvata, T. tricholepis non trouvés (silences) La table de 2ᵉ passe (résolution des formes abrégées) ne contenait pas les formes abrégées (T . recurvata), contrairement au passe2 Perl (tmpStr/tmpPref) Ajout des formes abrégées à la table de 2ᵉ passe + formes canoniques/préférentielles propres à la passe, dont l'ambiguïté (f1 ; f2 → avertissement, exclusion)
recherche binaire localeCompare (ordre local) et clé sur 2 mots seulement Comparaison par code-point (fidèle au cmp Perl) et dichotomie sur le texte restant entier, comme dich($rec)

Tests — examples.http (7 nouveaux cas) et tests.hurl régénéré

  • id 7 (Tillandsia, texte exact de Camille) → les 4 espèces, dont T. recurvata et T. tricholepis
  • id 8/10 (Serra do Mar, Pacific Coast) → aucun virus
  • id 9 (Rio Grande) → Microgramma squamulosa seul
  • id 11-13 (usnea/Citrus/Mus, cas minimaux) → plus de Lichen usnea, Citrus aurantium subsp. junos, Mus musculus airolensis (pour ces deux derniers, [] est le comportement fidèle au Perl : ces binômes ne sont pas dans CoL.txt)

Merci à Camille pour son rapport de bug:

J'ai relancé sur le même corpus dans une 3e colonne la dernière version du web service. Ce qui a changé par rapport à la version de Dominique : sotie de
Lichen usnea (usnea est un genre, et non encore le nom de l'espèce)
Citrus aurantium subsp. junos (je ne trouve que Citrus aurantium dans le résumé)
Mus musculus airolensis (Mus musculus uniquement dans le résumé)
En revanche, le web service n'a pas trouvé Tillandsia recurvata et Tillandsia tricholepis dans "Comparison of the air pollution biomonitoring ability of three Tillandsia species and the lichen Ramalina celastri in Argentina>Abstract: Bioaccumulation ability and response to air pollution sources were evaluated for Tillandsia capillaris Ruíz and Pav. f. capillaris, T. recurvata L., T. tricholepis Baker and the lichen Ramalina celastri (Spreng.) Krog. and Swinsc. "

Autre particularité : cette version sort des noms de virus (de pathologies) comme

"Serra do Navio mammarenavirus" que je ne trouve pas dans le texte : "Plants as bioindicators of air pollution at the serra do mar near the industrial complex of Cubatão, Brazil>Abstract: As a result of air pollutant emissions from the industrial complex of Cubatão, Brazil, the Atlantic Forest vegetation of the Serra do Mar shows severe and widespread damage. In order to obtain information on the type, intensity and causes of the vegetation damage, bioindicator plants were exposed at different distances from the emission sources. Air-pollution-induced effects were evaluated by estimation of visible injury symptoms and chemical analyses of leaves. The results prove the occurrence of phytotoxic levels of photochemical oxidants in wide parts of the research area. Intense fluoride-induced damage and high leaf fluoride concentrations were found in a valley downwind of fertiliser industries. The study showed that some of the traditional standardised bioindication methods from temperate climates may be successfully employed in biomonitoring programmes in tropical and subtropical regions."
"Rio Grande phlebovirus" : pas de trace dans le texte non plus : "Morphometric differences of Microgramma squamulosa (Kaulf.) de la Sota (Polypodiaceae) leaves in environments with distinct atmospheric air quality>Plants growing in environments with different atmospheric conditions may present changes in the morphometric parameters of their leaves.Microgramma squamulosa (Kaulf.)de la Sota is a neotropical epiphytic fern found in impacted environments.The aims of this study were to quantitatively compare structural characteristics of leaves in areas with different air quality conditions, and to identify morphometric parameters that are potential indicators of the effects of pollution on these plants.Fertile and sterile leaves growing on isolated trees were collected from an urban (Estância Velha) and a rural (Novo Hamburgo) environment, in Rio Grande do Sul, Brazil.For each leaf type, macroscopic and microscopic analyses were performed on 192 samples collected in each environment.The sterile and fertile leaves showed significantly greater thickness of the midrib and greater vascular bundle and leaf blade areas in the rural environment, which is characterized by less air pollution.The thickness of the hypodermis and the stomatal density of the fertile leaves were greater in the urban area, which is characterized by more air pollution.Based on the fact that significant changes were found in the parameters of both types of leaves, which could possibly be related to air pollutants, M. squamulosa may be a potential bioindicator."
"Pacific Coast orthonairovirus" : toujours aucune trace dans "A Preliminary Assessment of the Montréal Process Indicators of Air Pollution for the United States>Abstract: Air pollutants pose a risk to forest health and vitality in the UnitedStates. Here we present the major findings from a national scale air pollution assessment that is part of the United States' 2003 Report on Sustainable Forests. We examine trends and the percent forest subjected to specific levels of ozone and wet deposition of sulfate, nitrate, and ammonium. Results are reported by Resource Planning Act (RPA) reporting region and integrated by forest type using multivariate clustering. Estimates of sulfate deposition for forested areas had decreasing trends (1994–2000) across RPA regions that were statistically significant for North and South RPA regions. Nitrate deposition rates were relatively constant for the 1994 to 2000 period, but the South RPA region had a statistically decreasing trend. The North and South RPA regions experienced the highest ammonium deposition rates and showed slightly decreasing trends. Ozone concentrations were highest in portions of the Pacific Coast RPA region and relatively high across much of the South RPA region. Both the South and Rocky Mountain RPA regions had an increasing trend in ozone exposure. Ozone-induced foliar injury to sensitive species was recorded in all regions except for the Rocky Mountain region. The multivariate analysis showed that the oak-hickory and loblolly-shortleaf pine forest types were generally exposed to more air pollution than other forest types, and the redwood, western white pine, and larch forest types were generally exposed to less. These findings offer a new approach to national air pollution assessments and are intended to help focus research and planning initiatives related to air pollution and forest health."

Ces problèmes venaient du fait que les cas de test du service n'étaient pas exhaustifs, et donc lors du portage du programme perl en node, l'assistant s'est contenté de faire passer les tests, tout en simplifiant l'algorithme (ce que je lui avais demandé).
Malheureusement, cela a laissé des trous béants dans le comportement préalable du programme perl.

@parmentf
parmentf requested review from leogail and revolj September 7, 2026 09:45
@parmentf

parmentf commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

La 2e passe est-elle nécessaire ?

Cas Texte Perl (référence) Portage Node actuel
A seulement « T. recurvata L. » [] []
B genre seul « Tillandsia » + « T. recurvata L., T. tricholepis Baker » Tillandsia recurvata, Tillandsia tricholepis [] ⚠️
C « Tillandsia capillaris … » + abréviations les 3 espèces les 3 espèces

Non, une forme abrégée ne suffit jamais à elle seule. Une abréviation ne peut être résolue que si le genre a été détecté in extenso quelque part dans le document, en deux temps :

  1. Passe 1 : elle ne cherche que dans la table principale, qui ne contient aucune forme abrégée. Avec seulement « T. recurvata » dans le texte (cas A), elle ne trouve rien — ni espèce, ni genre — et la passe 2 n'est même pas lancée (retour anticipé dès que rawMatches est vide). D'où [] dans les deux implémentations.
  2. Passe 2 : la table réduite est construite à partir des genres trouvés en passe 1. Une fois le genre ouvert, ses formes abrégées deviennent cherchables — et c'est là que « T. recurvata » est résolu en Tillandsia recurvata alors que le nom complet de l'espèce n'apparaît nulle part (cas C, et c'est exactement le test id 7 de Camille).

Donc, en résumé :

  • nom complet de l'espèce requis ? Non — c'est tout l'intérêt de la passe 2 ;
  • détection du genre requise ? Oui, par n'importe quel binôme complet du genre ;
  • genre jamais mentionné in extenso ? Aucune résolution d'abréviation possible.

Divergence détectée au passage

Le cas B révèle un écart de fidélité : dans le Perl, la mention du genre seul (« the genus Tillandsia ») est matchée en passe 1 ; la ligne de genre est filtrée de la sortie finale, mais elle sert quand même à ouvrir la table du genre en passe 2 → les abréviations sont résolues. Dans le portage Node, les correspondances de genre seul ne sont jamais émises (contrôle isBinomial), donc si le genre n'apparaît qu'à travers aucun binôme complet, la passe 2 ne s'ouvre pas et les abréviations restent muettes ([] au lieu des 2 espèces).

C'est un cas limite (genre cité seul + abréviations, sans aucun nom d'espèce complet), mais le README documente le comportement Perl (« faire la liste des noms de genre présents dans le document analysé »)

@parmentf

parmentf commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Changements

services/irc3-species/v1/IRC3sp.mjs — parité avec le Perl sur les correspondances de genre seul :

  • findExactMatch et findPartialMatches émettent désormais aussi les correspondances de genre seul (suppression du filtre isBinomial) ;
  • ces lignes ne sortent jamais dans la liste finale : le filtre includes(' ') de processDocument les écarte, exactement comme le next if $genre{$champs[0]} du Perl ;
  • leur rôle est uniquement d'ouvrir la table du genre pour la passe 2, ce qui permet de résoudre « T. recurvata » quand aucun binôme complet du genre n'apparaît dans le document.

examples.http / tests.hurl — 2 nouveaux cas de régression :

  • id 14 (genre seul + abréviations) : "Plants of the genus Tillandsia were studied, and specimens of T. recurvata L. and T. tricholepis Baker were collected."["Tillandsia recurvata", "Tillandsia tricholepis"] — c'était le cas divergent ;
  • id 15 (abréviation sans aucune mention du genre) : → [] — garde-fou contre une résolution hallucinée.

Validation

  • Sonde A/B/C exécutée côte à côte Perl (IRC3sp.pl 4.5.1, -c -j) vs Node : réponses identiques sur les trois cas (A : [], B : les 2 espèces, C : les 3 espèces) ;
  • Suite complète npm run test:local irc3-species : succès, 15 documents (conteneur docker avec le code corrigé, puis arrêté) ;
  • Durée du requêtage : 1,6 s à chaud ; les 47 s observées une fois étaient le chargement à froid de CoL.txt dans le conteneur, pas une régression ;
  • diagnostics : aucune erreur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants