Détection par regex des mentions de collaboration externe dans les amendements#7
Closed
DavidNO wants to merge 3 commits into
Closed
Détection par regex des mentions de collaboration externe dans les amendements#7DavidNO wants to merge 3 commits into
DavidNO wants to merge 3 commits into
Conversation
Stores external-collaboration mentions detected in amendments' exposé sommaire. Analysis table (not in ETL_TABLES): survives rebuilds via create_all while amendements/dossiers are dropped and reloaded. amendementUid is a soft reference to amendements.uid (no ForeignKey), matching the RefUid pattern in the Amendement model, so the referential constraint never blocks the drop of the ETL-managed amendements table. One row per mention; provenance kept via modele/createdAt. (cherry picked from commit 726994f)
Detects amendments whose exposé sommaire declares a collaboration or inspiration with an external entity (lobby, union, association, company, NGO...). Pattern families are calibrated on formulations observed on the real corpus: travaillé avec, en concertation avec, inspiré de, issu d'une proposition de, proposé par, à la demande de... Contextual exclusions keep precision up: public or parliamentary actors right after the wording (Gouvernement, commission, rapporteur, Conseil d'État...), legal-object referents after 'inspiré de' (loi, article, procédure...), and text/role referents after citation-like families (le texte, le rapport, le groupe X, l'autorité...). Detection only: fills citation + formulation, leaves entite/typeEntite/ externe NULL (qualifying the entity needs semantic analysis). With --persist, rows land in amendement_mentions tagged modele='regex:v1'; re-runs are idempotent per amendment and scoped to that tag. Also documents DB setup and detector usage in the README, and fixes the stale Dossier model example.
load() sent the whole dataset as a single INSERT: with the full corpus (123k amendments x ~30 columns) that exceeds the 65,535-parameter limit of the Postgres protocol and the load fails. Insert in batches of 1,000 rows instead (single transaction, still idempotent via on_conflict_do_nothing).
Collaborator
Author
|
Remplacé par #9 : même travail de détection regex, mais empilé sur #8 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objectif
Détecter les amendements dont l'exposé sommaire déclare une collaboration ou une inspiration avec une entité externe (lobby, syndicat, association, entreprise, fédération professionnelle, ONG…) — formulations du type « travaillé avec… », « en concertation avec… », « inspiré de… ».
Cette PR apporte un détecteur par expressions régulières.
Contenu
Table d'analyse (
models/amendement_mention.py→amendement_mentions)amendementUid,citation,formulation,entite,typeEntite,externe,modele,createdAt.ETL_TABLES: survit aux rebuilds pendant queamendements/dossierssont recréées.amendementUidest une référence molle (pas deForeignKey), sur le modèle desRefUidexistants, pour ne pas bloquer le drop des tables ETL.Détecteur regex (
analysis/detect_mentions_regex.py)travaillé avec,en collaboration/concertation avec,inspiré de,issu d'une proposition de,proposé par,à la demande de,avec le concours de,recommandation de…--persist: écriture dansamendement_mentions, scopée au tagmodele='regex:v1'Fix ETL (
etl/loading.py)Insertion par batch de 1 000 lignes. Nécessaire pour charger le corpus complet.
Docs : setup complet dans le README (
.env, docker compose, usage du détecteur) et correction de l'exemple de modèle obsolète (User→Dossier).Résultats sur le corpus complet (123 084 amendements AN, législature 17)
travaillé avec(6 337),proposé par(1 956),recommandation de(815),en collaboration avec(692),issu d'une proposition de(662),inspiré de(581)…Évaluation contre un jeu de référence
Les motifs ont été calibrés et évalués contre un jeu de référence de 797 amendements annotés par un LLM (détecteur exploratoire conservé sur la branche
detect-mentions-poc, non destiné à être mergé) :Exemples de FN : (« le CNB demandent », « l'Interfédération a relevé ») — semble hors de portée d'un regex.