Processing TXT Files

Private AI supports scanning TXT files for PII and creating de-identified or redacted copies. Private AI’s supported entity types function across each file type, with localized variants of different PII (Personally Identifiable Information) entities, PHI (Protected Health Information) entities, and PCI (Payment Card Industry) entities being detected. Our Supported Languages and Supported Entity Types page provides a more detailed look.

info

If you'd like to try it yourself, please visit our free interactive web demo. No code or account is necessary.

How TXT Files Are Processed

TXT files are processed by simply reading in the contents of the TXT files verbatim and passing it through Private AI's text module. The resulting file will contain the labelled and redacted version of contents of the original.

Constraints

  • Private AI currently only supports utf-8 encoding for text files.

Support Matrix

CPU Container GPU Container Demo API Prod API PrivateGPT UI
Supported? Yes Yes No Yes No

Sample Request

info

Please sign up for a free API key to run this code.

Copy
Copied
import requests
import base64

file_url = "https://paidocumentation.blob.core.windows.net/$web/sample.txt"
file_content = requests.get(file_url).content
file_content_base64 = base64.b64encode(file_content).decode()

url = "https://api.private-ai.com/deid/v3/process/files/base64"

headers = {"Content-Type": "application/json", "x-api-key": "<INSERT API KEY>"}

payload = {
  "file":{
    "data": file_content_base64,
    "content_type": "text/plain",
  },
  "entity_detection": {
    "accuracy": "high",
    "return_entity": True
  }
}

response = requests.post(url, json=payload, headers=headers)

Sample Response

Copy
Copied
"processed_file": "Base64 Encoded File Content of the Redacted File",
"processed_text":"string",
"entities":"List[Entity]",
"entities_present":true,
"languages_detected":{"lang_1":0.67, "lang_2": 0.74}
© Copyright 2024 Private AI.