Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
0ba26df
added initial gliner notebook
omri374 Dec 16, 2025
c88e799
added approaches for entity mapping
omri374 Jan 1, 2026
f14cd07
updated design doc
omri374 Jan 6, 2026
5da5de1
entity mapping
omri374 Feb 28, 2026
b4b3e3c
Delete .github/agents/Research.agent.md
omri374 Feb 28, 2026
b8add90
Delete docs/entity_mapping_analysis.md
omri374 Feb 28, 2026
511fb0f
Modify ner group dependencies in pyproject.toml
omri374 Feb 28, 2026
1e01a9f
Update presidio_evaluator/models/base_model.py
omri374 Feb 28, 2026
7cd3aab
updates to PR
omri374 Feb 28, 2026
8b023f2
Merge branch 'omri/enhanced_mapping' of https://github.com/microsoft/…
omri374 Feb 28, 2026
8ef4dc7
ruff
omri374 Feb 28, 2026
bf47a51
updates to notebooks and PR comments
omri374 Mar 1, 2026
fb989b9
Remove deprecated entity_mapping check from model
omri374 Mar 1, 2026
f867938
added changelog
omri374 Mar 1, 2026
d40a4fd
changed iou_threshold
omri374 Mar 1, 2026
f057b78
changed iou to 0.75
omri374 Mar 1, 2026
27eb133
removed dead code on mapper.py
omri374 Mar 1, 2026
1601dc1
removed dead code from interactive.py
omri374 Mar 1, 2026
496d40c
updating flair test
omri374 Mar 1, 2026
58043eb
deprecating old models and removing tests
omri374 Mar 2, 2026
b2b4d88
forgotten comma
omri374 Mar 2, 2026
ea98c02
bugfix
omri374 Mar 2, 2026
c085704
Update base_evaluator.py
omri374 Mar 2, 2026
19fcfea
feat: [US-001] - CanonicalMapper core implementation
omri374 Mar 20, 2026
dfb146d
feat: [US-002,US-003,US-004,US-005,US-006] - Complete CanonicalMapper…
omri374 Mar 20, 2026
d58f0f7
chore: mark all stories complete and add progress log
omri374 Mar 20, 2026
9490eb3
chore: update progress log with full implementation details
omri374 Mar 20, 2026
4caccdf
chore: remove stale test_entity_mapping.py (tested old SemanticEntity…
omri374 Mar 20, 2026
fcfec9d
Initial plan
Copilot Mar 21, 2026
95f230c
Add ADR-001: Simplified Evaluation Pipeline Using DataFrame as Clean …
Copilot Mar 21, 2026
b59cded
Simplify evaluation pipeline and update model prediction
omri374 Mar 21, 2026
1df517c
docs: add ADR-002 for entity mapping via CanonicalMapper
Copilot Mar 21, 2026
3e900aa
docs: revise ADR-002 per review feedback
Copilot Mar 21, 2026
6ca1cac
Add hierarchical entity mapping dictionary
omri374 Mar 21, 2026
e1b5884
Update entity mapping details in ADR-002
omri374 Mar 21, 2026
ec19dc7
Refactor CanonicalMapper usage examples
omri374 Mar 21, 2026
87a9d8e
Update docs/adr/ADR-001-simplified-evaluation-pipeline.md
omri374 Mar 22, 2026
cddbdda
docs: move DOMAIN, WEB, URL, WEBSITE to NETWORK_IDENTIFIER
Copilot Mar 22, 2026
e0daa3c
Update docs/adr/ADR-001-simplified-evaluation-pipeline.md
omri374 Mar 22, 2026
d7d95e9
docs: update CanonicalMapper API and map_entities interface per revie…
Copilot Mar 22, 2026
6d6866f
docs: remove HOSPITAL alias from ORGANIZATION.COMPANY
Copilot Mar 22, 2026
151acad
Apply suggestions from code review
omri374 Mar 22, 2026
44adbc0
docs: remove MRN alias from PHI.PATIENT_ID
Copilot Mar 22, 2026
a56c6ac
Add example mappings for entity labels
omri374 Mar 22, 2026
a34a441
updates to canonical mapper
omri374 Mar 24, 2026
c74e418
Enhance ADR-001 with additional evaluation details
omri374 Mar 24, 2026
5fdf500
Enhance evaluation pipeline with hierarchy scoring
omri374 Mar 24, 2026
b400004
Update ADR-001-simplified-evaluation-pipeline.md
omri374 Mar 24, 2026
7c600b6
Modify prediction method to return DataFrame
omri374 Mar 24, 2026
aac1880
Merge remote-tracking branch 'origin/copilot/add-simplified-evaluatio…
omri374 Mar 24, 2026
191f330
Enhance ADR-002 with input format and usage updates
omri374 Mar 24, 2026
6bb51f7
Merge remote-tracking branch 'origin/copilot/add-simplified-evaluatio…
omri374 Mar 24, 2026
6725db7
Enhance ADR-001 with multi-hierarchical evaluation example
omri374 Mar 24, 2026
f8d6f01
Merge remote-tracking branch 'origin/copilot/add-simplified-evaluatio…
omri374 Mar 24, 2026
6012aff
feat: [US-001] - Add predict_dataset() to BaseModel
omri374 Mar 24, 2026
3ae9a1b
chore: mark US-001 as passing, update progress log
omri374 Mar 24, 2026
3165f4a
feat: [US-005] - Strip entity mapping from evaluation package
omri374 Mar 24, 2026
613aa46
chore: mark US-005 as passing, update progress log
omri374 Mar 24, 2026
4392d3f
feat: [US-002] - Add get_mapped_results_dataframe() to CanonicalMapper
omri374 Mar 24, 2026
34ce7b2
chore: mark US-002 as passing, update progress log
omri374 Mar 24, 2026
8aa9634
feat: [US-006] - Add calculate_score_on_df() to TokenEvaluator, integ…
omri374 Mar 24, 2026
a332a08
chore: mark US-006 as passing, update progress log
omri374 Mar 24, 2026
0808679
feat: [US-003] - Add get_mapping(mode=html/text) to CanonicalMapper
omri374 Mar 24, 2026
75a5f64
chore: mark US-003 as passing, gitignore temp test file
omri374 Mar 24, 2026
33a1299
feat: [US-004] - Remove from_dataset() classmethod from CanonicalMapper
omri374 Mar 24, 2026
e50e5ce
chore: mark US-003, US-004 as passing, update progress
omri374 Mar 24, 2026
601fc18
feat: [US-007] - Deprecate evaluate_all() with hard stop
omri374 Mar 24, 2026
fd91fce
chore: remove temp files
omri374 Mar 24, 2026
0bc911f
chore: US-007 passing - update prd and progress
omri374 Mar 24, 2026
3cf7988
feat: [US-008] - Soft deprecate get_results_dataframe() with Deprecat…
omri374 Mar 24, 2026
f3d8b07
chore: US-008 passing - update prd and progress
omri374 Mar 24, 2026
6dfe5a7
feat: [US-010] - Remove non-Presidio model wrappers
omri374 Mar 24, 2026
c37d88f
chore: US-010 passing - update prd and progress
omri374 Mar 24, 2026
2ad5fa0
feat: [US-013] - Migrate to uv, update dependency versions
omri374 Mar 24, 2026
8128ee0
chore: US-013 passing - update prd and progress
omri374 Mar 24, 2026
429d77c
feat: [US-015] - Add ruff linter and formatter configuration
omri374 Mar 24, 2026
90bd50b
chore: US-015 passing - update prd and progress
omri374 Mar 24, 2026
bcd4915
feat: [US-016] - Add pre-commit hooks
omri374 Mar 24, 2026
fdf9fdc
chore: US-016 passing - update prd and progress
omri374 Mar 24, 2026
a4fc0c7
feat: [US-017] - Reorganize tests into topic-based directories
omri374 Mar 24, 2026
589c0de
chore: US-017 passing - update prd and progress
omri374 Mar 24, 2026
6f455fc
feat: [US-011] - Update evaluation notebooks to the new pipeline
omri374 Mar 24, 2026
58db30f
feat: [US-012] - Replace obsolete model notebooks with deprecation no…
omri374 Mar 24, 2026
cee532b
feat: [US-018] - Write migration guide and changelog
omri374 Mar 24, 2026
e37e40c
chore: US-011, US-012, US-018 passing - update prd and progress
omri374 Mar 24, 2026
69e5eab
chore: fix trailing commas in prd.json - all 16 stories complete
omri374 Mar 24, 2026
828ae34
fix: ruff format/check violations + update stale evaluate_all() in docs
omri374 Mar 25, 2026
2fed0ca
chore: update progress.txt and codebase patterns after quality audit
omri374 Mar 25, 2026
0452700
fix: docs review - update stale references after redesign
omri374 Mar 25, 2026
d2a00f2
fix: update test_entity_hierarchy import path and remove --ignore wor…
omri374 Mar 25, 2026
3a18844
fix: replace CanonicalMapper.from_dataset() with CanonicalMapper(labe…
omri374 Mar 25, 2026
051108f
feat: [US-009] - Decouple model from evaluators
omri374 Mar 25, 2026
9016dce
chore: mark US-009 passes=true and update progress log
omri374 Mar 25, 2026
ffec2f8
fix: update notebooks 4 and 5 to use model=None in SpanEvaluator (US-…
omri374 Mar 25, 2026
f69dc84
docs: split run-experiment cells into 3 labelled steps (predict → map…
omri374 Mar 25, 2026
ef9e7c6
fix: use CanonicalMapper() with no labels in notebooks; map via get_m…
omri374 Mar 25, 2026
d33fd71
refactor: restructure notebook flow — predict first, then review mapp…
omri374 Mar 25, 2026
8ecd174
fix: exclude 'O' non-entity tag from label discovery in get_mapped_re…
omri374 Mar 25, 2026
1c897a9
fix: update integration tests and notebooks for new evaluator pipeline
omri374 Mar 25, 2026
9d269ad
refactor: move compare, evaluate_sample, and helpers to TokenEvaluator
omri374 Mar 25, 2026
e514407
feat: add level parameter to calculate_score_on_df for entity/pii/bot…
omri374 Mar 25, 2026
464398a
updates to notebooks
omri374 Mar 26, 2026
3282b60
delete unneeded files
omri374 Mar 26, 2026
e4f6b60
Align TokenEvaluator and SpanEvaluator EvaluationResult outputs; add …
omri374 Mar 26, 2026
8af177e
pr updates
omri374 Mar 28, 2026
1d5f566
feat: [US-001 through US-017] - Complete two-phase CanonicalMapper re…
omri374 Apr 27, 2026
c185e35
chore: update PRD passes:true for US-001 through US-017 + progress log
omri374 Apr 27, 2026
aea64bb
feat: [US-018] - Update Notebook 4 for two-phase CanonicalMapper API
omri374 Apr 27, 2026
337d3c1
chore: update PRD passes:true for US-018 + progress log
omri374 Apr 27, 2026
3034701
feat: [US-019 through US-023] - Update notebooks and docs for two-pha…
omri374 Apr 28, 2026
f734f02
chore: update PRD passes:true for US-019 through US-023 + progress log
omri374 Apr 28, 2026
0ff60a1
fix: review fixes — DATASET_ONLY never fired, keep_as_fp invalid, mod…
omri374 Apr 28, 2026
6c4ef2b
refactor: extract rendering into MapperRenderer in rendering.py
omri374 Apr 28, 2026
dce6a28
refactor: rename eval_surface/eval_depth to canonical_surface/canonic…
omri374 Apr 28, 2026
a209a65
feat: [US-024] - Hierarchical multi-level evaluation convenience wrapper
omri374 Apr 29, 2026
e08ab5e
chore: mark US-024 passes=true, update progress.txt
omri374 Apr 29, 2026
44c5ff6
refactor: move calculate_hierarchical_scores to evaluation module
omri374 Apr 29, 2026
a36fe49
chore: mark US-006/012/014/015 passes=false per ADR-003 (COLLISION_AM…
omri374 Apr 29, 2026
625367d
chore: US-024 passes=false — wrapper must be method on SpanEvaluator,…
omri374 Apr 29, 2026
85dceae
chore: US-024 — move calculate_hierarchical_scores to BaseEvaluator, …
omri374 Apr 29, 2026
fb3021a
feat: [US-006/US-012/US-014/US-015/US-024] - Demote COLLISION_AMBIGUO…
omri374 Apr 29, 2026
02a2fd3
chore: mark US-006/012/014/015/024 as passing and update progress
omri374 Apr 29, 2026
771f033
feat: [US-001] - Define MappedResults and level helpers
omri374 May 1, 2026
0a078ce
feat: [US-002] - Update IssueType taxonomy
omri374 May 1, 2026
a68d3e4
feat: [US-003] - Remove projection phase, emit MappedResults
omri374 May 1, 2026
f39d49b
feat: [US-004] - Add min_severity to analyze()
omri374 May 1, 2026
2393901
feat: [US-005] - Add get_mapping() method
omri374 May 1, 2026
c6e0537
feat: [US-006] - Update HTML audit table for new issue taxonomy
omri374 May 1, 2026
dadc8bc
feat: [US-007] - Update calculate_hierarchical_scores() to accept Map…
omri374 May 1, 2026
d9945bf
feat: [US-008, US-009, US-010] - Update Notebooks 4, 5, 6 for single-…
omri374 May 1, 2026
5b1c2b0
docs: add AGENTS.md with codebase patterns
omri374 May 1, 2026
bb10aca
fix: remove mapping-to-entity rendering, rename Mapped to -> Resolved as
omri374 May 3, 2026
493b33d
fix: suppress COLLISION_CROSS_BRANCH when same-branch co-occurrences …
omri374 May 3, 2026
2d0f204
fix: COLLISION_CROSS_BRANCH only fires when model has no prediction c…
omri374 May 3, 2026
e0d3e1b
feat: add suppress_prediction_only() to CanonicalMapper
omri374 May 3, 2026
704a73c
docs: update AGENTS.md — level_helpers merged into EntityHierarchy
omri374 May 3, 2026
976b8b7
refactor: mutation methods return None (analyze, map, suppress_predic…
omri374 May 3, 2026
3f59bc5
fix: COLLISION_CROSS_BRANCH 3-case logic — suppress when pred has sam…
omri374 May 8, 2026
3b13779
refining the noteboks and html rendering
omri374 May 12, 2026
53e08d1
fix: correct wheel target configuration in pyproject.toml
RonShakutai May 24, 2026
2bc9ebb
Delete .github/instructions/prd-skill.md
omri374 Jun 29, 2026
28730e4
Delete .github/instructions directory
omri374 Jun 29, 2026
99d327b
Delete .github/agents/Ralph.agent.md
omri374 Jun 29, 2026
95e381b
Delete ralph/archive/2026-05-01-dataset-anchored-mapper/progress.txt
omri374 Jun 29, 2026
cda8fd7
Delete ralph directory
omri374 Jun 29, 2026
d890e64
Delete progress.txt
omri374 Jun 29, 2026
1366b5b
Update README.md
omri374 Jun 30, 2026
fb436e3
Add Python 3.10 to CI workflow matrix
omri374 Jun 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
contents: read
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@v4
Expand All @@ -32,33 +32,30 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache Poetry dependencies

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/pypoetry
~/.cache/pip
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ matrix.python-version }}-${{ hashFiles('**/uv.lock') }}
restore-keys: |
${{ runner.os }}-poetry-${{ matrix.python-version }}-
${{ runner.os }}-uv-${{ matrix.python-version }}-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --with dev,ner
poetry run python -m spacy download en_core_web_sm
poetry run python -m spacy download en_core_web_lg
uv venv --seed
uv sync --extra dev
uv run python -m spacy download en_core_web_sm
uv run python -m spacy download en_core_web_lg

- name: Run pytest
run: |
poetry run pytest --runslow
uv run pytest --runslow

- name: Clean up after tests
if: always()
run: |
# Clean up pip cache and poetry cache to free space for next matrix job
pip cache purge || true
poetry cache clear pypi --all -n || true
df -h
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,11 @@ datasets/
*.spacy
*.pickle
/poetry.lock


*.xml
*.json
*.html
*.svg
!synth_dataset_v2.json
test_us002.py
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: local
hooks:
- id: ruff-format
name: ruff format
language: system
entry: uv run ruff format --check
types: [python]
pass_filenames: false

- id: ruff-check
name: ruff check
language: system
entry: uv run ruff check
types: [python]
pass_filenames: false

- id: pytest
name: pytest (unit tests only)
language: system
entry: uv run pytest -m "not slow and not integration" --ignore=tests/integration -q
pass_filenames: false
always_run: true
53 changes: 53 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# AGENTS.md — Codebase Patterns

## Project Setup
- Python managed with `uv` — always use `uv run` for Python, never bare `python` or `pip`
- Virtualenv at `.venv/`
- Quality checks: `uv run ruff check --fix`, `uv run ruff format`, `uv run pytest`
- Fast entity-mapping tests: `pytest tests/entity_mapping/`

## CanonicalMapper
- Single-phase (Identify-only) — no projection phase
- `analyze(results_df, min_severity='WARNING')` — COLLISION_SAME_BRANCH (INFO) hidden unless `min_severity='INFO'`
- `get_mapped_results_dataframe()` returns `MappedResults` (frozen dataclass with `.original`, `.binary`, `.branch`, `.detailed`)
- `get_mapping()` returns `{label: resolved}` dict — UNRESOLVED labels excluded
- `get_issues()` filters by `_min_severity` — call after `analyze()` or `map()`

## Five Issue Types (IssueType enum)
- UNRESOLVED (ERROR, blocking)
- COLLISION_CROSS_BRANCH (WARNING, blocking) — only raised when cross-branch co-occurrences outnumber same-branch ones for the prediction label
- PREDICTION_ONLY (WARNING, blocking)
- DATASET_ONLY (WARNING, non-blocking)
- COLLISION_SAME_BRANCH (INFO, non-blocking)

## _Resolution dataclass fields
- `tier` — identification tier (EXACT, COUNTRY, COUNTRY_FALLBACK, FUZZY, UNRESOLVED)
- `resolved` — resolved canonical entity name (or None for UNRESOLVED)
- `score` — fuzzy match score (0.0–1.0, None for non-FUZZY tiers)
- NO `canonical`, `projected`, or `projection_type` fields

## IssueSeverity enum
- Values are lowercase: `'error'`, `'warning'`, `'info'`
- Use `.lower()` when converting from string; do NOT use `.upper()`

## Hierarchical Evaluation
- `calculate_hierarchical_scores(mapped_results: MappedResults)` returns `{"binary", "branch", "detailed"}`
- NOT `{"L0", "L1", "L2"}` — use the string level names
- `MappedResults` is in `presidio_evaluator/entity_mapping/data_objects.py`

## level_helpers
- `to_binary(label)` and `to_branch(label)` are now **instance methods on `EntityHierarchy`** (moved from the deleted `level_helpers.py`)
- Call via `hierarchy_instance.to_binary(label)` / `hierarchy_instance.to_branch(label)`
- `EntityHierarchy` has no imports from `mapper.py` — no circular deps
- For branch lookups use `EntityHierarchy(canonical_depth=10)`

## Notebooks
- NB4: `4_Evaluate_Presidio_Analyzer.ipynb` — standard Presidio evaluation
- NB5: `5_Evaluate_Custom_Presidio_Analyzer.ipynb` — custom model evaluation
- NB6: `6_Interactive_Entity_Mapping.ipynb` — interactive mapping tutorial
- All notebooks use `mapped_results = mapper.get_mapped_results_dataframe()` (not `mapped_df`)
- `edit_notebook_file` requires VSC cell IDs (`#VSC-xxxx`) — use `copilot_getNotebookSummary` to get current IDs

## Git
- Pre-commit hooks: ruff-format, ruff-check, pytest (unit tests only)
- Branch: `ralph/canonical-mapper-single-phase`
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# CHANGELOG

## Unreleased

> **Migration guide:** See [docs/migration-guide.md](docs/migration-guide.md) for step-by-step upgrade instructions.

### Breaking Changes

- **`evaluate_all()` removed** — raises `DeprecationError` at runtime. Replace with the three-step pipeline: `predict_dataset()` → `CanonicalMapper.get_mapped_results_dataframe()` → `calculate_score_on_df()`.
- **`entity_mapping` parameter removed** from `SpanEvaluator`, `TokenEvaluator`, and `BaseEvaluator` — entity mapping is now the responsibility of `CanonicalMapper`.
- **`compare_by_io` parameter removed** from evaluator constructors — BIO/BILUO prefix stripping is now performed by `CanonicalMapper`.
- **`BaseEvaluator.from_dataset()` removed** — use `model.predict_dataset(dataset)` directly.
- **Non-Presidio model wrappers removed**: `FlairModel`, `SpacyModel`, `StanzaModel`, `AzureAITextAnalyticsWrapper`. Add models directly through Presidio to evaluate them.
- **Minimum Python version raised to 3.11** (was 3.10) — required by `numpy >= 2.4.0`.
- **Package manager changed from Poetry to uv** — install with `uv sync`, run with `uv run`.

### New Features

- **`BaseModel.predict_dataset(dataset)`** — runs the model on a list of `InputSample` objects and returns a 5-column DataFrame (`sentence_id`, `token`, `annotation`, `prediction`, `start_indices`).
- **`CanonicalMapper`** — replaces `EntityMappingHelper` with an improved four-tier auto-resolution strategy (`EXACT`, `COUNTRY`, `FUZZY`, `PENDING`). Key methods:
- `CanonicalMapper.from_dataset(dataset)` — builds a mapper from dataset labels.
- `mapper.get_mapped_results_dataframe(results_df)` — applies entity mapping to a predictions DataFrame.
- `mapper.get_mapping(mode='html' | 'text')` — returns the final `{raw_label: canonical | None}` dict.
- `mapper.map({"LABEL": "CANONICAL"})` — manually resolve pending labels.
- `mapper.render_html()` — display the resolution audit table in Jupyter.
- **`TokenEvaluator.calculate_score_on_df(results_df)`** — score token-level predictions from a DataFrame.
- **`SpanEvaluator.calculate_score_on_df(per_type, results_df)`** — score span-level predictions from a DataFrame.
- **Ruff** — added as the project linter and formatter (`ruff.toml` at project root).
- **Pre-commit hooks** — `ruff format`, `ruff check`, and `pytest` run automatically before every commit (`.pre-commit-config.yaml`).
- **Test reorganisation** — tests are now grouped by topic (`tests/data_generator/`, `tests/entity_mapping/`, `tests/evaluation/`, `tests/models/`, `tests/integration/`). Integration tests are tagged with `pytest.mark.integration`.

### Deprecations

- **`evaluator.get_results_dataframe()`** — soft `DeprecationWarning` emitted at runtime. Replace with `model.predict_dataset(dataset)`.



## Version 0.2.5

### Improvements
Expand Down
4 changes: 2 additions & 2 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ tqdm

`tqdm` is a product of collaborative work.
Unless otherwise stated, all authors (see commit logs) retain copyright
for their respective work, and release the work under the MIT licence
for their respective work, and release the work under the MIT license
(text below).

Exceptions or notable authors are listed below
Expand All @@ -368,7 +368,7 @@ in reverse chronological order:
[PR #96]: https://github.com/tqdm/tqdm/pull/96


Mozilla Public Licence (MPL) v. 2.0 - Exhibit A
Mozilla Public license (MPL) v. 2.0 - Exhibit A
-----------------------------------------------

This Source Code Form is subject to the terms of the
Expand Down
37 changes: 13 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Presidio-research

This package provides evaluation and data-science capabilities for
This package provides evaluation and data-science capabilities for
[Presidio](https://github.com/microsoft/presidio) and PII detection models in general.

It also includes a fake data generator that creates synthetic sentences based on templates and fake PII.
Expand All @@ -20,16 +20,13 @@ The easiest way to get started is by reviewing the notebooks.
- [Notebook 3](notebooks/3_Split_by_pattern_number.ipynb): Provides tools to split the dataset into train/test/validation sets while avoiding leakage due to the same pattern appearing in multiple folds (only applicable for synthetically generated data).
- [Notebook 4](notebooks/4_Evaluate_Presidio_Analyzer.ipynb): Shows how to use the evaluation tools to evaluate how well Presidio detects PII. Note that this is using the vanilla Presidio, and the results aren't very accurate.
- [Notebook 5](notebooks/5_Evaluate_Custom_Presidio_Analyzer.ipynb): Shows how one can configure Presidio to detect PII much more accurately, and boost the f score in ~30%.
- [Notebook 6](notebooks/6_Interactive_Entity_Mapping.ipynb): Explains the entity mapping process, which is crucial when evaluating multiple models each returning a different set of entities.

### Installation

>Note: Presidio evaluator requires Python version 3.9 or higher.

#### From PyPI

``` sh
conda create --name presidio python=3.12
conda activate presidio
pip install presidio-evaluator
python -m spacy download en_core_web_sm # for tokenization
python -m spacy download en_core_web_lg # for NER
Expand All @@ -43,31 +40,29 @@ To install the package:
2. Install all dependencies:

``` sh
# Install package+dependencies
pip install poetry
poetry install --with=dev
# Install uv if not already installed
pip install uv

# Download tge spaCy pipeline used for tokenization
poetry run python -m spacy download en_core_web_sm
# Install package + dev dependencies
uv sync --extra dev

# To install with all additional NER dependencies (e.g. Flair, Stanza), run:
# poetry install --with='ner,dev'
# Download the spaCy pipeline used for tokenization
uv run python -m spacy download en_core_web_sm

# To use the default Presidio configuration, a spaCy model is required:
poetry run python -m spacy download en_core_web_lg
uv run python -m spacy download en_core_web_lg

# Verify installation
pytest
uv run pytest
```

Note that some dependencies (such as Flair and Stanza) are not automatically installed to reduce installation complexity.
Note that some dependencies (such as Flair and Stanza) are no longer supported. Use Presidio Analyzer directly to add custom NER models.

## What's in this package?

1. **Fake data generator** for PII recognizers and NER models
2. **Data representation layer** for data generation, modeling and analysis
3. Multiple **Model/Recognizer evaluation** files (e.g. for Presidio, Spacy, Flair, Azure AI Language)
4. **Training and modeling code** for multiple models
3. **Model/Recognizer evaluation** for Presidio Analyzer and custom Presidio recognizers
5. Helper functions for **results analysis**

## 1. Data generation
Expand Down Expand Up @@ -120,13 +115,6 @@ The standardized structure, `List[InputSample]`, can be translated into differen
InputSample.create_spacy_dataset(dataset, output_path="dataset.spacy")
```

- Flair
```python
from presidio_evaluator import InputSample
dataset = InputSample.read_dataset_json("data/synth_dataset_v2.json")
flair = InputSample.create_flair_dataset(dataset)
```

- json
```python
from presidio_evaluator import InputSample
Expand All @@ -140,6 +128,7 @@ The presidio-evaluator framework allows you to evaluate Presidio as a system, a

## For more information

- [Blog post on PII evaluation](https://omri-mendels.medium.com/evaluating-pii-detection-models-fa0c745d7a4c)
- [Blog post on NLP approaches to data anonymization](https://towardsdatascience.com/nlp-approaches-to-data-anonymization-1fb5bde6b929)
- [How to evaluate PII Detection output with Presidio Evaluator](https://tranguyen221.medium.com/how-to-evaluate-pii-detection-output-with-presidio-evaluator-3f2684ba3091)
- [Conference talk about leveraging Presidio and utilizing NLP approaches for data anonymization](https://youtu.be/Tl773LANRwY)
Expand Down
4 changes: 0 additions & 4 deletions docs/.markdownlint.json

This file was deleted.

Loading
Loading