Achivements überarbeitet
This commit is contained in:
@@ -987,6 +987,85 @@ async function testNameAgainstBlacklist() {
|
||||
}
|
||||
}
|
||||
|
||||
// Detailed Levenshtein test function
|
||||
async function testLevenshteinDetailed() {
|
||||
const firstname = document.getElementById('testFirstname').value.trim();
|
||||
const lastname = document.getElementById('testLastname').value.trim();
|
||||
const resultDiv = document.getElementById('testResult');
|
||||
|
||||
if (!firstname || !lastname) {
|
||||
showBlacklistMessage('Bitte gib Vorname und Nachname ein', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/v1/admin/blacklist/levenshtein-test', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ firstname, lastname, threshold: 0.3 })
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
const data = result.data;
|
||||
let html = `
|
||||
<div style="background: #f3e5f5; color: #4a148c; padding: 1rem; border-radius: 5px; margin-top: 1rem;">
|
||||
<h4>🔍 Detaillierte Levenshtein-Analyse</h4>
|
||||
<p><strong>Getesteter Name:</strong> ${data.input.firstname} ${data.input.lastname}</p>
|
||||
<p><strong>Schwellenwert:</strong> ${data.threshold}</p>
|
||||
<hr style="margin: 1rem 0;">
|
||||
`;
|
||||
|
||||
// Show results for each category
|
||||
for (const [category, categoryResult] of Object.entries(data.results)) {
|
||||
if (categoryResult.hasSimilarTerms && categoryResult.similarTerms.length > 0) {
|
||||
html += `
|
||||
<div style="margin-bottom: 1rem; padding: 0.5rem; background: #fff3e0; border-left: 4px solid #ff9800; border-radius: 3px;">
|
||||
<h5>📁 ${getCategoryDisplayName(category)} (Schwellenwert: ${categoryResult.categoryThreshold})</h5>
|
||||
`;
|
||||
|
||||
categoryResult.similarTerms.forEach(term => {
|
||||
const similarityPercent = Math.round((1 - term.distance) * 100);
|
||||
html += `
|
||||
<div style="margin: 0.5rem 0; padding: 0.5rem; background: white; border-radius: 3px;">
|
||||
<strong>Begriff:</strong> "${term.term}"<br>
|
||||
<strong>Levenshtein-Distanz:</strong> ${term.levenshteinDistance}<br>
|
||||
<strong>Normalisierte Distanz:</strong> ${term.distance.toFixed(4)}<br>
|
||||
<strong>Ähnlichkeit:</strong> ${similarityPercent}%<br>
|
||||
<strong>Match-Typ:</strong> ${term.matchType || 'similar'}
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
html += `</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
// If no matches found
|
||||
if (!Object.values(data.results).some(r => r.hasSimilarTerms)) {
|
||||
html += `
|
||||
<div style="background: #e8f5e8; color: #2e7d32; padding: 1rem; border-radius: 3px;">
|
||||
<strong>✅ Keine ähnlichen Begriffe gefunden</strong><br>
|
||||
Der Name "${data.input.firstname} ${data.input.lastname}" hat keine ähnlichen Begriffe in der Blacklist.
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
html += `</div>`;
|
||||
resultDiv.innerHTML = html;
|
||||
resultDiv.style.display = 'block';
|
||||
} else {
|
||||
showBlacklistMessage(result.message || 'Fehler beim Testen', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error testing Levenshtein:', error);
|
||||
showBlacklistMessage('Fehler beim Testen der Levenshtein-Distanz', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function addToBlacklist() {
|
||||
const term = document.getElementById('newTerm').value.trim();
|
||||
const category = document.getElementById('newCategory').value;
|
||||
|
||||
Reference in New Issue
Block a user