ds-EkaCare commited on
Commit
580620f
·
verified ·
1 Parent(s): 9fb8a15

Docs: symmetric variable names image_redactor / text_redactor

Browse files
Files changed (1) hide show
  1. README.md +15 -15
README.md CHANGED
@@ -61,25 +61,25 @@ first, once, and every transform consumes its output.
61
  ```python
62
  from document_pii_redactor import ImagePIIRedactor
63
 
64
- redactor = ImagePIIRedactor(
65
  "ekacare/document-pii-redactor",
66
  detect_visual=True, # set False to skip visual entities (QR codes,
67
  # face photos, signatures, etc.) — text PII only
68
  )
69
 
70
- entities = redactor.detect("page.jpg") # list[PIIEntity] — the core call
71
  for e in entities:
72
  print(e.kind, e.category, e.bbox, e.text, e.score)
73
 
74
  # Bring your own OCR (skips the built-in Tesseract step; your pixel-space
75
  # word boxes pass through to the emitted entities):
76
- entities = redactor.detect("page.jpg", words=["John", "Doe"],
77
- boxes=[[100, 20, 140, 40], [145, 20, 180, 40]])
78
 
79
  # One detection, three possible outputs:
80
- redactor.redact("page.jpg", entities).save("redacted.png")
81
- redactor.anonymize("page.jpg", entities).save("anonymized.png")
82
- deid = redactor.deidentify("page.jpg", entities)
83
  deid.image.save("deidentified.png"); deid.mapping.to_dict()
84
  ```
85
 
@@ -88,16 +88,16 @@ deid.image.save("deidentified.png"); deid.mapping.to_dict()
88
  ```python
89
  from document_pii_redactor import TextPIIRedactor
90
 
91
- r = TextPIIRedactor("ekacare/document-pii-redactor")
92
 
93
  text = "John Doe, DOB 1990-01-01, john@x.com"
94
- spans = r.detect(text) # char-offset spans — the core call
95
  for s in spans:
96
  print(s.category, s.start, s.end, s.text, s.score)
97
 
98
- r.redact(text, spans, mask="[REDACTED]")
99
- r.anonymize(text, spans)
100
- r.deidentify(text, spans) # .text + .mapping
101
  ```
102
 
103
  ### De-identify and anonymize (v0.2.0+, both modalities)
@@ -119,13 +119,13 @@ Beyond redaction, both redactors support:
119
 
120
  ```python
121
  text = "Mr. John Doe, 45 yrs, DOB 12-03-1979, Indiranagar, Karnataka."
122
- spans = r.detect(text)
123
 
124
- result = r.deidentify(text, spans)
125
  result.text # "Person_1, Age_1 yrs, DOB Date_1, City_1, State_1."
126
  result.mapping # yours to store securely; never persisted by the library
127
 
128
- r.anonymize(text, spans)
129
  # -> "[PERSON], 40–49 yrs, DOB 1979, [LOCATION], Karnataka."
130
  ```
131
 
 
61
  ```python
62
  from document_pii_redactor import ImagePIIRedactor
63
 
64
+ image_redactor = ImagePIIRedactor(
65
  "ekacare/document-pii-redactor",
66
  detect_visual=True, # set False to skip visual entities (QR codes,
67
  # face photos, signatures, etc.) — text PII only
68
  )
69
 
70
+ entities = image_redactor.detect("page.jpg") # list[PIIEntity] — the core call
71
  for e in entities:
72
  print(e.kind, e.category, e.bbox, e.text, e.score)
73
 
74
  # Bring your own OCR (skips the built-in Tesseract step; your pixel-space
75
  # word boxes pass through to the emitted entities):
76
+ entities = image_redactor.detect("page.jpg", words=["John", "Doe"],
77
+ boxes=[[100, 20, 140, 40], [145, 20, 180, 40]])
78
 
79
  # One detection, three possible outputs:
80
+ image_redactor.redact("page.jpg", entities).save("redacted.png")
81
+ image_redactor.anonymize("page.jpg", entities).save("anonymized.png")
82
+ deid = image_redactor.deidentify("page.jpg", entities)
83
  deid.image.save("deidentified.png"); deid.mapping.to_dict()
84
  ```
85
 
 
88
  ```python
89
  from document_pii_redactor import TextPIIRedactor
90
 
91
+ text_redactor = TextPIIRedactor("ekacare/document-pii-redactor")
92
 
93
  text = "John Doe, DOB 1990-01-01, john@x.com"
94
+ spans = text_redactor.detect(text) # char-offset spans — the core call
95
  for s in spans:
96
  print(s.category, s.start, s.end, s.text, s.score)
97
 
98
+ text_redactor.redact(text, spans, mask="[REDACTED]")
99
+ text_redactor.anonymize(text, spans)
100
+ text_redactor.deidentify(text, spans) # .text + .mapping
101
  ```
102
 
103
  ### De-identify and anonymize (v0.2.0+, both modalities)
 
119
 
120
  ```python
121
  text = "Mr. John Doe, 45 yrs, DOB 12-03-1979, Indiranagar, Karnataka."
122
+ spans = text_redactor.detect(text)
123
 
124
+ result = text_redactor.deidentify(text, spans)
125
  result.text # "Person_1, Age_1 yrs, DOB Date_1, City_1, State_1."
126
  result.mapping # yours to store securely; never persisted by the library
127
 
128
+ text_redactor.anonymize(text, spans)
129
  # -> "[PERSON], 40–49 yrs, DOB 1979, [LOCATION], Karnataka."
130
  ```
131