Add Latin-root lexeme analysis to prompt tools

This commit is contained in:
GangGreenTemperTatum
2026-04-05 15:23:09 -04:00
parent d0918fe5ea
commit 0a27bc73fd
11 changed files with 638 additions and 2 deletions
+41
View File
@@ -24,6 +24,7 @@ class AntiClassifierTool extends Tool {
acInput: '',
acOutput: '',
acError: '',
acLexemeAnalysis: { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' },
acLoading: false,
acModel: localStorage.getItem('ac-model') || 'anthropic/claude-sonnet-4.6',
acModels: models,
@@ -49,6 +50,13 @@ class AntiClassifierTool extends Tool {
? window.ANTICLASSIFIER_SYSTEM_PROMPT
: '';
},
acRefreshLexemeAnalysis: function() {
if (typeof window === 'undefined' || !window.LexemeAnalysis || typeof window.LexemeAnalysis.analyze !== 'function') {
this.acLexemeAnalysis = { totalFindings: 0, findings: [], summary: 'Lexeme analysis unavailable.' };
return;
}
this.acLexemeAnalysis = window.LexemeAnalysis.analyze(this.acInput);
},
acRun: async function() {
const apiKey = this.acGetApiKey();
if (!apiKey) {
@@ -123,6 +131,39 @@ class AntiClassifierTool extends Tool {
if (this.acOutput) {
this.copyToClipboard(this.acOutput);
}
},
acGetLexemeAnalysis: function() {
return this.acLexemeAnalysis || { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' };
},
acNeutralizeInput: function() {
const analysis = this.acGetLexemeAnalysis();
if (!analysis.totalFindings || !window.LexemeAnalysis || typeof window.LexemeAnalysis.neutralizeText !== 'function') {
return;
}
this.acInput = window.LexemeAnalysis.neutralizeText(this.acInput, analysis);
if (typeof this.showNotification === 'function') {
this.showNotification('Applied neutral Latin-root rewrites', 'success', 'fas fa-seedling');
}
},
acApplyLexemeRewrite: function(term, rewrite) {
if (!term || !rewrite) {
return;
}
const escapedTerm = String(term).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
this.acInput = this.acInput.replace(new RegExp('\\b' + escapedTerm + '\\b', 'i'), rewrite);
if (typeof this.showNotification === 'function') {
this.showNotification('Applied rewrite for ' + term, 'success', 'fas fa-pen');
}
}
};
}
getVueWatchers() {
return {
acInput: function() {
if (typeof this.acRefreshLexemeAnalysis === 'function') {
this.acRefreshLexemeAnalysis();
}
}
};
}
+41
View File
@@ -21,6 +21,7 @@ class PromptCraftTool extends Tool {
pcInput: '',
pcOutput: '',
pcOutputs: [],
pcLexemeAnalysis: { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' },
pcStrategy: 'rephrase',
pcModel: localStorage.getItem('pc-model') || 'nousresearch/hermes-3-llama-3.1-405b',
pcTemperature,
@@ -78,6 +79,13 @@ class PromptCraftTool extends Tool {
}
return base;
},
pcRefreshLexemeAnalysis: function() {
if (typeof window === 'undefined' || !window.LexemeAnalysis || typeof window.LexemeAnalysis.analyze !== 'function') {
this.pcLexemeAnalysis = { totalFindings: 0, findings: [], summary: 'Lexeme analysis unavailable.' };
return;
}
this.pcLexemeAnalysis = window.LexemeAnalysis.analyze(this.pcInput);
},
pcRunMutation: async function() {
const apiKey = this.pcGetApiKey();
if (!apiKey) {
@@ -163,6 +171,39 @@ class PromptCraftTool extends Tool {
},
pcUseAsInput: function(text) {
this.pcInput = text;
},
pcGetLexemeAnalysis: function() {
return this.pcLexemeAnalysis || { totalFindings: 0, findings: [], summary: 'No Latin-root wording findings.' };
},
pcNeutralizeInput: function() {
const analysis = this.pcGetLexemeAnalysis();
if (!analysis.totalFindings || !window.LexemeAnalysis || typeof window.LexemeAnalysis.neutralizeText !== 'function') {
return;
}
this.pcInput = window.LexemeAnalysis.neutralizeText(this.pcInput, analysis);
if (typeof this.showNotification === 'function') {
this.showNotification('Applied neutral Latin-root rewrites', 'success', 'fas fa-seedling');
}
},
pcApplyLexemeRewrite: function(term, rewrite) {
if (!term || !rewrite) {
return;
}
const escapedTerm = String(term).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
this.pcInput = this.pcInput.replace(new RegExp('\\b' + escapedTerm + '\\b', 'i'), rewrite);
if (typeof this.showNotification === 'function') {
this.showNotification('Applied rewrite for ' + term, 'success', 'fas fa-pen');
}
}
};
}
getVueWatchers() {
return {
pcInput: function() {
if (typeof this.pcRefreshLexemeAnalysis === 'function') {
this.pcRefreshLexemeAnalysis();
}
}
};
}