Skip to content

cjensen506/open-redact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title Open Redact
emoji 🔒
colorFrom blue
colorTo indigo
sdk docker
app_port 7860
pinned false

open-redact

open-redact is an open source api to help anonymize pdf. This can be used can be used to redact names and other identifiable information from resume before review to create a more equitable hiring process.

open-redact can redact any PII entity type that Microsoft Presidio supports (people's names, email addresses, phone numbers, credit card numbers, and more). The caller chooses which entity types to redact per request.

Configuration

This package uses Microsoft Presidio to detect personally identifiable information (PII). Presidio combines regex-based recognizers (for entities such as email addresses) with a spaCy named entity recognition model (for entities such as people's names).

By default the spaCy model is en_core_web_lg, pinned in requirements.txt. You can swap in a smaller model to make development easier, a larger model for more accuracy, or a model for another language. Check out https://spacy.io/models/en for English options.

To use a different model, update the pinned model in requirements.txt and configure Presidio's NLP engine accordingly (see the Presidio customization docs). The default model is loaded automatically by the AnalyzerEngine in app/main/sensitive_text_check.py.

Installation

Clone from source and build an image using the included docker file

 docker build --tag openredact:python .

If not using the image, install dependencies (including the spaCy model) with

pip install -r requirements.txt

Usage

When up and running the system auto generates swagger documentation which can be viewed at http://127.0.0.1:8000/docs#/ where the address and port should be updated for your deployment.

Screenshot of documentation

Redacting a PDF

POST /redact_pdf accepts a multipart form with:

  • file — the PDF to redact (application/pdf).
  • entities — one or more PII entity types to redact. Repeat the field (entities=PERSON&entities=EMAIL_ADDRESS) or pass a comma-separated list (entities=PERSON,EMAIL_ADDRESS). At least one entity type is required; a request with none returns 400, as does an unsupported entity type.

GET /entities returns the full list of entity types you can request.

curl -X POST http://127.0.0.1:8000/redact_pdf \
  -F "file=@resume.pdf;type=application/pdf" \
  -F "entities=PERSON" \
  -F "entities=EMAIL_ADDRESS" \
  --output redacted.pdf

Testing

From root run the following command to execute all unit tests

python -m pytest .

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

open source pdf / resume redaction api

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors