interface interactive

This commit is contained in:
nBiqoz
2025-09-07 12:30:23 +02:00
parent 74e56c956c
commit ef0819ae90
27 changed files with 1827 additions and 515 deletions

View File

@@ -0,0 +1,32 @@
import { EntityMapping } from "@/app/config/entityLabels";
export const generateAnonymizedText = (
originalText: string,
mappings: EntityMapping[]
): string => {
if (!originalText || !mappings || mappings.length === 0) {
return originalText;
}
// Trier les mappings par position de début
const sortedMappings = [...mappings].sort((a, b) => a.start - b.start);
let result = "";
let lastIndex = 0;
for (const mapping of sortedMappings) {
// Ajouter le texte avant l'entité
result += originalText.slice(lastIndex, mapping.start);
// Utiliser displayName comme dans le tableau de mapping
result += mapping.displayName;
// Mettre à jour la position
lastIndex = mapping.end;
}
// Ajouter le reste du texte
result += originalText.slice(lastIndex);
return result;
};