mac multi select
This commit is contained in:
@@ -175,8 +175,8 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
// ✅ Définir l'URL AVANT de l'utiliser
|
||||
const presidioAnalyzerUrl =
|
||||
"http://analyzer.151.80.20.211.sslip.io/analyze";
|
||||
|
||||
// "http://analyzer.151.80.20.211.sslip.io/analyze";
|
||||
"http://localhost:5001/analyze";
|
||||
try {
|
||||
const analyzeResponse = await fetch(presidioAnalyzerUrl, {
|
||||
method: "POST",
|
||||
@@ -213,7 +213,8 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
console.log("🔍 Appel à Presidio Anonymizer...");
|
||||
const presidioAnonymizerUrl =
|
||||
"http://analyzer.151.80.20.211.sslip.io/anonymize";
|
||||
// "http://analyzer.151.80.20.211.sslip.io/anonymize";
|
||||
"http://localhost:5001/anonymize";
|
||||
|
||||
const anonymizeResponse = await fetch(presidioAnonymizerUrl, {
|
||||
method: "POST",
|
||||
@@ -251,32 +252,45 @@ export async function POST(req: NextRequest) {
|
||||
analyzerResults: AnalyzerResult[]
|
||||
) => {
|
||||
const replacementMap: Record<string, string> = {};
|
||||
|
||||
|
||||
// Extraire tous les remplacements [XXX] du texte anonymisé
|
||||
const replacementPattern = /\[[^\]]+\]/g;
|
||||
const foundReplacements = anonymizedText.match(replacementPattern) || [];
|
||||
|
||||
console.log("🔍 Remplacements trouvés dans le texte anonymisé:", foundReplacements);
|
||||
|
||||
const foundReplacements =
|
||||
anonymizedText.match(replacementPattern) || [];
|
||||
|
||||
console.log(
|
||||
"🔍 Remplacements trouvés dans le texte anonymisé:",
|
||||
foundReplacements
|
||||
);
|
||||
|
||||
// Trier les entités par position
|
||||
const sortedResults = [...analyzerResults].sort((a, b) => a.start - b.start);
|
||||
|
||||
const sortedResults = [...analyzerResults].sort(
|
||||
(a, b) => a.start - b.start
|
||||
);
|
||||
|
||||
// Associer chaque entité avec son remplacement correspondant
|
||||
sortedResults.forEach((result, index) => {
|
||||
const originalValue = originalText.substring(result.start, result.end);
|
||||
|
||||
const originalValue = originalText.substring(
|
||||
result.start,
|
||||
result.end
|
||||
);
|
||||
|
||||
if (index < foundReplacements.length) {
|
||||
// Utiliser le remplacement correspondant par ordre d'apparition
|
||||
replacementMap[originalValue] = foundReplacements[index];
|
||||
console.log(`✅ Mapping ordonné: "${originalValue}" -> "${foundReplacements[index]}"`);
|
||||
console.log(
|
||||
`✅ Mapping ordonné: "${originalValue}" -> "${foundReplacements[index]}"`
|
||||
);
|
||||
} else {
|
||||
// Fallback si pas assez de remplacements trouvés
|
||||
const fallbackValue = `[${result.entity_type.toUpperCase()}]`;
|
||||
replacementMap[originalValue] = fallbackValue;
|
||||
console.log(`⚠️ Fallback: "${originalValue}" -> "${fallbackValue}"`);
|
||||
console.log(
|
||||
`⚠️ Fallback: "${originalValue}" -> "${fallbackValue}"`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
console.log("🔧 Mapping final:", replacementMap);
|
||||
return replacementMap;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user