feat(humanizer): pondération par mode + profils multiples#3
Open
freemind25 wants to merge 1 commit into
Open
Conversation
Add per-mode scoring weights to the AI-detection engine and turn the single writer profile into persisted, named, multiple profiles. Problem: - analyzeText() scored every text the same way regardless of the selected rewrite mode, so academic/professional text was unfairly flagged for using formal connectors or lacking oral markers. - The writer profile lived only in React state: it vanished on every reload, and only one profile could exist at a time. Changes: - textAnalysis.ts: introduce ScoreMode and MODE_TOLERANCE, weighting the contribution of perfection/transition/voice/staccato signals to the final score by mode. Raw sub-scores shown to the user stay untouched; only the aggregate score and SUCKS sub-metrics shift. - humanizer.ts: HumanizeMode now aliases ScoreMode (single source of truth). performHumanize threads mode through every analyzeText call so before/after scores and the "until natural" loop match the engine's weighting. Add two opt-in lexical-variation rules (aggressive intensity only) that never introduce spelling errors. - useAIDetector.ts / TextCleaner/index.tsx: thread the active mode into manual and background analysis calls. - profileStore.ts (new) + WriterProfilePanel.tsx: persist profiles to localStorage, support multiple named profiles with selection and deletion. Storage failures degrade silently. - engine.test.ts: 7 new tests covering mode weighting, raw-score stability, lexical variation gating by intensity, and profileStore behavior without localStorage. Verified: tsc --noEmit, npm run lint, npm test (15/15), npm run build all pass.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Résumé
Phase 0 de la feuille de route d'humanisation (voir échange avec Claude) :
pondération du score IA par mode de réécriture + persistance/multiplicité
des profils d'écriture.
Changements
textAnalysis.ts: nouveau typeScoreMode+ tableMODE_TOLERANCE.Un texte académique avec des connecteurs formels n'est plus pénalisé à
tort ; il l'est davantage en mode Naturel/Personnel où l'oralité est
attendue. Les sous-scores bruts affichés à l'utilisateur restent
inchangés (seule l'agrégation finale est pondérée).
humanizer.ts:HumanizeModedevient un alias deScoreMode(plus de duplication de type). Le score avant/après et la boucle
« jusqu'à naturel » utilisent désormais le mode actif. + 2 règles de
variation lexicale sûres (intensité aggressive uniquement, jamais de
faute volontaire).
useAIDetector.ts/TextCleaner/index.tsx: le mode actif esttransmis à chaque analyse (manuelle et en arrière-plan).
profileStore.ts(nouveau) : persistance localStorage desprofils, dégradation silencieuse si le stockage est indisponible.
WriterProfilePanel.tsx: profils multiples nommés, sélection,suppression, restauration automatique au rechargement.
engine.test.ts: +7 tests (pondération par mode, stabilité desscores bruts, variation lexicale selon l'intensité, robustesse de
profileStoresanslocalStorage).Vérifications effectuées avant la PR
npx tsc --noEmit→ 0 erreurnpm run lint→ 0 erreur (warnings préexistants non liés au diff)npm test→ 15/15 (8 existants + 7 nouveaux)npm run build→ build de production réussiNon inclus volontairement
prévues comme spikes séparés, pas encore développées.
etc.) : hors périmètre de cette PR.