<!DOCTYPE html>
<html>
<head>
<title>PII Anonymization</title>
</head>
<body>
<script type="module">
import {
createAnonymizer,
InMemoryKeyProvider,
decryptPIIMap,
rehydrate
} from './node_modules/rehydra/dist/browser.js';
async function demo() {
const keyProvider = new InMemoryKeyProvider();
const anonymizer = createAnonymizer({
ner: {
mode: 'quantized',
onStatus: (s) => console.log('NER:', s),
onDownloadProgress: (p) => console.log(`Download: ${p.percent}%`)
},
semantic: { enabled: true },
keyProvider
});
await anonymizer.initialize();
const result = await anonymizer.anonymize(
'Contact Maria Schmidt at [email protected] in Berlin.'
);
console.log('Anonymized:', result.anonymizedText);
// Rehydrate
const key = await keyProvider.getKey();
const piiMap = await decryptPIIMap(result.piiMap, key);
const original = rehydrate(result.anonymizedText, piiMap);
console.log('Rehydrated:', original);
await anonymizer.dispose();
}
demo().catch(console.error);
</script>
</body>
</html>