mirror of
https://github.com/elder-plinius/P4RS3LT0NGV3.git
synced 2026-07-12 15:36:32 +02:00
Add Latin-root lexeme analysis to prompt tools
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
|
||||
const lexemeAnalysis = require(path.join(__dirname, '..', 'js', 'core', 'lexemeAnalysis.js'));
|
||||
|
||||
const empty = lexemeAnalysis.analyze('');
|
||||
assert.strictEqual(empty.totalFindings, 0, 'Empty input should yield no findings');
|
||||
|
||||
const nounCase = lexemeAnalysis.analyze('Need benign pesticide framing.');
|
||||
assert.strictEqual(nounCase.totalFindings, 1, 'Known -cide noun should be detected');
|
||||
assert.strictEqual(nounCase.findings[0].family, 'destructive_suffix');
|
||||
assert.strictEqual(nounCase.findings[0].semanticDomain, 'pest');
|
||||
assert.strictEqual(nounCase.findings[0].primaryRewrite, 'pest management');
|
||||
|
||||
const adjectiveCase = lexemeAnalysis.analyze('Looking for non-cidal wording in this prompt.');
|
||||
assert.strictEqual(adjectiveCase.totalFindings, 1, 'Standalone -cidal wording should be detected');
|
||||
assert.strictEqual(adjectiveCase.findings[0].partOfSpeech, 'adjective');
|
||||
assert.ok(
|
||||
adjectiveCase.findings[0].primaryRewrite.includes('mitigation'),
|
||||
'Standalone adjectival form should fall back to mitigation-oriented rewrite'
|
||||
);
|
||||
|
||||
const aliasCase = lexemeAnalysis.analyze('A bactericidal workflow should sound less destructive.');
|
||||
assert.strictEqual(aliasCase.totalFindings, 1, 'Alias-root adjectival case should be detected');
|
||||
assert.strictEqual(aliasCase.findings[0].semanticDomain, 'bacterial');
|
||||
assert.ok(
|
||||
aliasCase.findings[0].rewrites.some((rewrite) => rewrite.includes('bacterial management')),
|
||||
'Alias roots should resolve into domain-specific rewrites'
|
||||
);
|
||||
|
||||
const neutralized = lexemeAnalysis.neutralizeText(
|
||||
'Pesticide and bactericidal wording should be softened.',
|
||||
lexemeAnalysis.analyze('Pesticide and bactericidal wording should be softened.')
|
||||
);
|
||||
assert.ok(neutralized.includes('Pest Management'), 'Neutralization should preserve leading capitalization');
|
||||
assert.ok(neutralized.includes('bacterial management'), 'Neutralization should replace adjectival form');
|
||||
|
||||
console.log('Lexeme analysis tests passed');
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const projectRoot = path.join(__dirname, '..');
|
||||
const promptcraftTemplate = fs.readFileSync(path.join(projectRoot, 'templates', 'promptcraft.html'), 'utf8');
|
||||
const anticlassifierTemplate = fs.readFileSync(path.join(projectRoot, 'templates', 'anticlassifier.html'), 'utf8');
|
||||
const promptcraftTool = fs.readFileSync(path.join(projectRoot, 'js', 'tools', 'PromptCraftTool.js'), 'utf8');
|
||||
const anticlassifierTool = fs.readFileSync(path.join(projectRoot, 'js', 'tools', 'AntiClassifierTool.js'), 'utf8');
|
||||
const indexTemplate = fs.readFileSync(path.join(projectRoot, 'index.template.html'), 'utf8');
|
||||
|
||||
assert.ok(promptcraftTemplate.includes('Latin-Root Analysis'), 'PromptCraft should expose the analysis card');
|
||||
assert.ok(promptcraftTemplate.includes('pcNeutralizeInput'), 'PromptCraft should expose neutralization action');
|
||||
assert.ok(anticlassifierTemplate.includes('Latin-Root Analysis'), 'Anti-Classifier should expose the analysis card');
|
||||
assert.ok(anticlassifierTemplate.includes('acNeutralizeInput'), 'Anti-Classifier should expose neutralization action');
|
||||
assert.ok(promptcraftTool.includes('pcGetLexemeAnalysis'), 'PromptCraft tool should bind shared analysis');
|
||||
assert.ok(anticlassifierTool.includes('acGetLexemeAnalysis'), 'Anti-Classifier tool should bind shared analysis');
|
||||
assert.ok(indexTemplate.includes('js/data/latinAffixPolicies.js'), 'Index template should load affix policy data');
|
||||
assert.ok(indexTemplate.includes('js/core/lexemeAnalysis.js'), 'Index template should load shared lexeme analysis engine');
|
||||
|
||||
console.log('Lexeme UI surface tests passed');
|
||||
Reference in New Issue
Block a user