matematicsolutions/awesome-matematic-skills-pl / dokumenty/skills/let-it-be
let-it-be
VerifiedAnonimizacja i pseudonimizacja polskich danych osobowych (PESEL, NIP, REGON, KRS, telefon, e-mail, imiona i nazwiska, nazwy firm) w tekscie - RODO-safe, offline, deterministycznie (bez wysylania tresci do modelu). Uzywaj gdy uzytkownik chce zanonimizowac lub spseudonimizowac dokument, usunac dane osobowe z pisma, przygotowac tekst do publikacji albo do wyslania do LLM, lub mowi o PESEL/NIP/REGON/RODO/anonimizacji/pseudonimizacji.
src/detect.mjs
View on GitHub// Orchestrator detekcji: uruchamia reguly regex, rozwiazuje nakladajace
// sie spany (czego pl-entities NIE robil - tam detectAll zwracal konflikty
// "do rozwiazania w T2"). Tutaj rozwiazujemy je deterministycznie:
// wyzsze confidence wygrywa, przy remisie dluzszy span, potem wczesniejszy.
import { detectAll, PL_EXTRACTION_RULES, SUMA_NIE_DOTYCZY } from "./regex.mjs";
import { propagujNazwiska, propagujFirmy } from "./propaguj.mjs";
/**
* Typy traktowane jako dane osobowe (RODO) - tylko te sa domyslnie
* podmieniane. Sygnatury orzeczen i aktow prawnych to informacja publiczna,
* NIE dane osobowe - domyslnie zostaja w tekscie (mozna wlaczyc opcja).
*/
export const PII_TYPES = new Set([
"PESEL", "NIP", "REGON", "KRS", "EMAIL", "PHONE", "OSOBA", "FIRMA",
"IBAN", "DOWOD_OSOBISTY", "ADRES",
]);
const overlaps = (a, b) => a.start < b.end && b.start < a.end;
/** Rozwiazuje nakladajace sie dopasowania - zwraca rozlaczne, posortowane. */
function resolveOverlaps(matches) {
const ranked = [...matches].sort((a, b) =>
b.confidence - a.confidence ||
(b.end - b.start) - (a.end - a.start) ||
a.start - b.start,
);
const accepted = [];
for (const m of ranked) {
if (!accepted.some((a) => overlaps(a, m))) accepted.push(m);
}
return accepted.sort((a, b) => a.start - b.start);
}
/**
* Wykrywa encje w tekscie i oznacza ktore sa danymi osobowymi.
*
* @param {string} text
* @param {object} [opts]
* @param {boolean} [opts.includeSignatures=false] traktuj sygnatury orzeczen
* i aktow jako podlegajace podmianie (domyslnie NIE - to nie PII).
* @param {number} [opts.minConfidence=0] odrzuc dopasowania ponizej progu
* (np. 0.8 zostawia tylko PESEL/NIP/REGON/IBAN/KRS/email/osoba).
* @param {Array} [opts.rules] niestandardowy zestaw regul.
* @returns {{entities: Array, text: string}} encje rozlaczne, posortowane wg
* pozycji, kazda z polem `isPii`, oraz tekst po normalizacji NFC.
* Offsety `start`/`end` odnosza sie do zwroconego `text`. Dla wejscia
* juz w NFC (zwykly przypadek) to ten sam tekst co wejscie.
*/
export function detect(text, opts = {}) {
const { includeSignatures = false, minConfidence = 0, rules = PL_EXTRACTION_RULES } = opts;
// Tekst z PDF bywa w NFD ("S" + laczacy akcent zamiast "Ś") - reguly tego nie widza.
text = text.normalize("NFC");
const matches = detectAll(text, rules).filter((m) => m.confidence >= minConfidence);
const wykryte = resolveOverlaps(matches);
// Dalsze wystapienia nazwisk juz wykrytych osob, takze w odmianie (propaguj.mjs).
const odmiany = minConfidence <= 0.8 ? propagujNazwiska(text, wykryte) : [];
// Dalsze wystapienia nazwy spolki bez formy prawnej (propaguj.mjs).
const firmy = minConfidence <= 0.7 ? propagujFirmy(text, [...wykryte, ...odmiany]) : [];
const resolved = [...wykryte, ...odmiany, ...firmy].sort((x, y) => x.start - y.start);
const entities = resolved.map((m) => ({
// Encje z propagacji (odmiany nazwisk, dalsze wystapienia firmy) nie maja sumy.
walidacjaSumy: SUMA_NIE_DOTYCZY,
doPrzegladu: false,
...m,
isPii: PII_TYPES.has(m.type) ||
(includeSignatures && m.type.startsWith("SYGNATURA")),
}));
return { entities, text };
}
/** Liczniki encji per typ - dla audit logu i raportu. */
export function countByType(entities) {
const counts = {};
for (const e of entities) counts[e.type] = (counts[e.type] || 0) + 1;
return counts;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |