diff --git a/js/data/latinAffixPolicies.js b/js/data/latinAffixPolicies.js index fed4f51..7e2a955 100644 --- a/js/data/latinAffixPolicies.js +++ b/js/data/latinAffixPolicies.js @@ -70,6 +70,71 @@ 'framed around management', 'operationally neutral' ] + }, + { + id: 'latin-eradication-verbs', + family: 'eradication_language', + kind: 'surface_pattern', + partOfSpeech: 'verb', + affixes: ['eradicate', 'exterminate', 'annihilate', 'obliterate'], + patterns: [ + /\b(?:eradicate|eradicates|eradicated|eradicating|eradication)\b/gi, + /\b(?:exterminate|exterminates|exterminated|exterminating|extermination)\b/gi, + /\b(?:annihilate|annihilates|annihilated|annihilating|annihilation)\b/gi, + /\b(?:obliterate|obliterates|obliterated|obliterating|obliteration)\b/gi + ], + severity: 'high', + confidence: 0.88, + semanticShift: 'total_removal', + explanation: 'Eradication language implies total destruction rather than bounded handling.', + fallbackTemplates: [ + 'reduce', + 'manage', + 'contain', + 'address' + ] + }, + { + id: 'latin-suppression-language', + family: 'suppression_language', + kind: 'surface_pattern', + partOfSpeech: 'verb', + affixes: ['neutralize', 'incapacitate', 'suppress'], + patterns: [ + /\b(?:neutralize|neutralizes|neutralized|neutralizing|neutralization)\b/gi, + /\b(?:incapacitate|incapacitates|incapacitated|incapacitating|incapacitation)\b/gi, + /\b(?:suppress|suppresses|suppressed|suppressing|suppression)\b/gi + ], + severity: 'medium', + confidence: 0.82, + semanticShift: 'forceful_control', + explanation: 'Suppression language can read as coercive or force-centric rather than operationally neutral.', + fallbackTemplates: [ + 'limit', + 'reduce', + 'constrain', + 'manage' + ] + }, + { + id: 'latin-terminality-language', + family: 'terminality_language', + kind: 'surface_pattern', + partOfSpeech: 'adjective', + affixes: ['lethal', 'fatal', 'terminal', 'mortal'], + patterns: [ + /\b(?:lethal|fatal|terminal|mortal)\b/gi + ], + severity: 'medium', + confidence: 0.8, + semanticShift: 'fatal_outcome_framing', + explanation: 'Terminality language frames outcomes as fatal or irreversible even when a softer operational phrasing would do.', + fallbackTemplates: [ + 'high-risk', + 'severe', + 'critical', + 'unsafe' + ] } ]; diff --git a/js/tools/BijectionTool.js b/js/tools/BijectionTool.js index 8bf9f30..bc1606c 100644 --- a/js/tools/BijectionTool.js +++ b/js/tools/BijectionTool.js @@ -20,6 +20,7 @@ class BijectionTool extends Tool { bijectionIncludeExamples: true, bijectionAutoCopy: false, bijectionInput: '', + bijectionLexemeAnalysis: { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' }, bijectionMapping: {}, bijectionOutputs: [] }; @@ -27,6 +28,36 @@ class BijectionTool extends Tool { getVueMethods() { return { + bijectionRefreshLexemeAnalysis() { + if (typeof window === 'undefined' || !window.LexemeAnalysis || typeof window.LexemeAnalysis.analyze !== 'function') { + this.bijectionLexemeAnalysis = { totalFindings: 0, findings: [], summary: 'Lexeme analysis unavailable.' }; + return; + } + this.bijectionLexemeAnalysis = window.LexemeAnalysis.analyze(this.bijectionInput); + }, + bijectionGetLexemeAnalysis() { + return this.bijectionLexemeAnalysis || { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' }; + }, + bijectionNeutralizeInput() { + const analysis = this.bijectionGetLexemeAnalysis(); + if (!analysis.totalFindings || !window.LexemeAnalysis || typeof window.LexemeAnalysis.neutralizeText !== 'function') { + return; + } + this.bijectionInput = window.LexemeAnalysis.neutralizeText(this.bijectionInput, analysis); + if (typeof this.showNotification === 'function') { + this.showNotification('Applied neutral Latin-root rewrites', 'success', 'fas fa-seedling'); + } + }, + bijectionApplyLexemeRewrite(term, rewrite) { + if (!term || !rewrite) { + return; + } + const escapedTerm = String(term).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + this.bijectionInput = this.bijectionInput.replace(new RegExp('\\b' + escapedTerm + '\\b', 'i'), rewrite); + if (typeof this.showNotification === 'function') { + this.showNotification('Applied rewrite for ' + term, 'success', 'fas fa-pen'); + } + }, generateBijectionMapping() { const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?'; const mapping = {}; @@ -229,6 +260,16 @@ Now, please translate and respond to this message in alphapr: ${encoded}`; } }; } + + getVueWatchers() { + return { + bijectionInput: function() { + if (typeof this.bijectionRefreshLexemeAnalysis === 'function') { + this.bijectionRefreshLexemeAnalysis(); + } + } + }; + } } if (typeof module !== 'undefined' && module.exports) { diff --git a/js/tools/MutationTool.js b/js/tools/MutationTool.js index 85a30b0..aac960d 100644 --- a/js/tools/MutationTool.js +++ b/js/tools/MutationTool.js @@ -15,6 +15,7 @@ class MutationTool extends Tool { getVueData() { return { fuzzerInput: '', + fuzzerLexemeAnalysis: { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' }, fuzzerCount: 20, fuzzerSeed: '', fuzzUseRandomMix: true, @@ -30,6 +31,36 @@ class MutationTool extends Tool { getVueMethods() { return { + fuzzerRefreshLexemeAnalysis: function() { + if (typeof window === 'undefined' || !window.LexemeAnalysis || typeof window.LexemeAnalysis.analyze !== 'function') { + this.fuzzerLexemeAnalysis = { totalFindings: 0, findings: [], summary: 'Lexeme analysis unavailable.' }; + return; + } + this.fuzzerLexemeAnalysis = window.LexemeAnalysis.analyze(this.fuzzerInput); + }, + fuzzerGetLexemeAnalysis: function() { + return this.fuzzerLexemeAnalysis || { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' }; + }, + fuzzerNeutralizeInput: function() { + const analysis = this.fuzzerGetLexemeAnalysis(); + if (!analysis.totalFindings || !window.LexemeAnalysis || typeof window.LexemeAnalysis.neutralizeText !== 'function') { + return; + } + this.fuzzerInput = window.LexemeAnalysis.neutralizeText(this.fuzzerInput, analysis); + if (typeof this.showNotification === 'function') { + this.showNotification('Applied neutral Latin-root rewrites', 'success', 'fas fa-seedling'); + } + }, + fuzzerApplyLexemeRewrite: function(term, rewrite) { + if (!term || !rewrite) { + return; + } + const escapedTerm = String(term).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + this.fuzzerInput = this.fuzzerInput.replace(new RegExp('\\b' + escapedTerm + '\\b', 'i'), rewrite); + if (typeof this.showNotification === 'function') { + this.showNotification('Applied rewrite for ' + term, 'success', 'fas fa-pen'); + } + }, seededRandomFactory: function(seedStr) { if (!seedStr) return Math.random; let h = 1779033703 ^ seedStr.length; @@ -106,6 +137,16 @@ class MutationTool extends Tool { } }; } + + getVueWatchers() { + return { + fuzzerInput: function() { + if (typeof this.fuzzerRefreshLexemeAnalysis === 'function') { + this.fuzzerRefreshLexemeAnalysis(); + } + } + }; + } } // Export @@ -116,4 +157,3 @@ if (typeof module !== 'undefined' && module.exports) { } - diff --git a/js/tools/TransformTool.js b/js/tools/TransformTool.js index 39b2b89..990ff1f 100644 --- a/js/tools/TransformTool.js +++ b/js/tools/TransformTool.js @@ -61,6 +61,7 @@ class TransformTool extends Tool { return { transformInput: 'Hello World', + transformLexemeAnalysis: { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' }, transformOutput: '', activeTransform: null, transforms: transforms, @@ -250,6 +251,36 @@ class TransformTool extends Tool { } return 'text'; }, + transformRefreshLexemeAnalysis: function() { + if (typeof window === 'undefined' || !window.LexemeAnalysis || typeof window.LexemeAnalysis.analyze !== 'function') { + this.transformLexemeAnalysis = { totalFindings: 0, findings: [], summary: 'Lexeme analysis unavailable.' }; + return; + } + this.transformLexemeAnalysis = window.LexemeAnalysis.analyze(this.transformInput); + }, + transformGetLexemeAnalysis: function() { + return this.transformLexemeAnalysis || { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' }; + }, + transformNeutralizeInput: function() { + const analysis = this.transformGetLexemeAnalysis(); + if (!analysis.totalFindings || !window.LexemeAnalysis || typeof window.LexemeAnalysis.neutralizeText !== 'function') { + return; + } + this.transformInput = window.LexemeAnalysis.neutralizeText(this.transformInput, analysis); + if (typeof this.showNotification === 'function') { + this.showNotification('Applied neutral Latin-root rewrites', 'success', 'fas fa-seedling'); + } + }, + transformApplyLexemeRewrite: function(term, rewrite) { + if (!term || !rewrite) { + return; + } + const escapedTerm = String(term).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + this.transformInput = this.transformInput.replace(new RegExp('\\b' + escapedTerm + '\\b', 'i'), rewrite); + if (typeof this.showNotification === 'function') { + this.showNotification('Applied rewrite for ' + term, 'success', 'fas fa-pen'); + } + }, openTransformOptions: function(transform, event) { if (event) { event.preventDefault(); @@ -623,6 +654,9 @@ class TransformTool extends Tool { getVueWatchers() { return { transformInput() { + if (typeof this.transformRefreshLexemeAnalysis === 'function') { + this.transformRefreshLexemeAnalysis(); + } if (this.activeTransform && this.activeTab === 'transforms') { const opts = this.getMergedOptionsForTransform(this.activeTransform.name); this.transformOutput = this.activeTransform.func(this.transformInput, opts); @@ -670,4 +704,3 @@ if (typeof module !== 'undefined' && module.exports) { } - diff --git a/templates/bijection.html b/templates/bijection.html index d5ba9ef..2336c5c 100644 --- a/templates/bijection.html +++ b/templates/bijection.html @@ -16,6 +16,41 @@ +
This target content contains loaded Latin-root wording. Neutralizing it here propagates through the generated alphapr prompts.
+{{ finding.term }}
+ {{ finding.partOfSpeech }}
+ {{ finding.family }}
+ confidence {{ Math.round(finding.confidence * 100) }}%
+ {{ finding.rationale }}
+This seed text contains loaded Latin-root wording. Neutralizing it here affects every generated mutation case.
+{{ finding.term }}
+ {{ finding.partOfSpeech }}
+ {{ finding.family }}
+ confidence {{ Math.round(finding.confidence * 100) }}%
+ {{ finding.rationale }}
+This shared input feeds transforms and inline translation. Neutralizing flagged wording here affects both paths.
+{{ finding.term }}
+ {{ finding.partOfSpeech }}
+ {{ finding.family }}
+ confidence {{ Math.round(finding.confidence * 100) }}%
+ {{ finding.rationale }}
+