Overview

Redact Raw Text

Pass a string to the redact method to redact sensitive information from the text

from tonic_textual.redact_api import TonicTextual

textual = TonicTextual("<TONIC-TEXTUAL-URL>")

raw_redaction = textual.redact("My name is John, and today I am demo-ing Textual, a software product created by Tonic")
raw_redaction.describe()

This produces the following output:

My name is [NAME_GIVEN_WpFV4], and [DATE_TIME_9gaJAH] I am demo-ing [PRODUCT_gQUbYJKD], a software product created by [ORGANIZATION_nc31lH]

{"start": 11, "end": 15, "label": "NAME_GIVEN", "text": "John", "score": 0.9}
{"start": 21, "end": 26, "label": "DATE_TIME", "text": "today", "score": 0.85}
{"start": 41, "end": 48, "label": "PRODUCT", "text": "Textual", "score": 0.85}
{"start": 80, "end": 85, "label": "ORGANIZATION", "text": "Tonic", "score": 0.85}

Synthesize Raw Text

Passing the same string to the redact method, with some categorites set to synthesize

from tonic_textual.redact_api import TonicTextual

textual = TonicTextual("<TONIC-TEXTUAL-URL>")
generator_config = {"NAME_GIVEN":"Synthesis", "ORGANIZATION":"Synthesis"}
raw_synthesis = textual.redact(
    "My name is John, and today I am demo-ing Textual, a software product created by Tonic",
    generator_config=generator_config)
raw_synthesis.describe()

This produces the following output:

My name is Vada, and [DATE_TIME_9gaJAH] I am demo-ing [PRODUCT_gQUbYJKD], a software product created by New Terranova

{"start": 11, "end": 15, "label": "NAME_GIVEN", "text": "John", "score": 0.9}
{"start": 21, "end": 26, "label": "DATE_TIME", "text": "today", "score": 0.85}
{"start": 41, "end": 48, "label": "PRODUCT", "text": "Textual", "score": 0.85}
{"start": 80, "end": 85, "label": "ORGANIZATION", "text": "Tonic", "score": 0.85}

Using LLM Synthesis

Passing the same string to the llm synthesis method

from tonic_textual.redact_api import TonicTextual

textual = TonicTextual("<TONIC-TEXTUAL-URL>")

raw_synthesis = textual.llm_synthesis("My name is John, and today I am demo-ing Textual, a software product created by Tonic")
raw_synthesis.describe()

This produces the following output:

My name is John, and on Monday afternoon I am demo-ing Widget Pro, a software product created by Initech Enterprises.

{"start": 11, "end": 15, "label": "NAME_GIVEN", "text": "John", "score": 0.9}
{"start": 21, "end": 26, "label": "DATE_TIME", "text": "today", "score": 0.85}
{"start": 41, "end": 48, "label": "PRODUCT", "text": "Textual", "score": 0.85}
{"start": 80, "end": 85, "label": "ORGANIZATION", "text": "Tonic", "score": 0.85}

Redact JSON Data

Pass a JSON string or Python dict to the redact method to redact sensitive information from the object

from tonic_textual.redact_api import TonicTextual
import json

textual = TonicTextual("<TONIC-TEXTUAL-URL>")

d=dict()
d['person']={'first':'John','last':'OReilly'}
d['address']={'city': 'Memphis', 'state':'TN', 'street': '847 Rocky Top', 'zip':1234}
d['description'] = 'John is a man that lives in Memphis.  He is 37 years old and is married to Cynthia'

json_redaction = textual.redact_json(d, {"LOCATION_ZIP":"Synthesis"})

print(json.dumps(json.loads(json_redaction.redacted_text), indent=2))

This produces the following output:

{
"person": {
    "first": "[NAME_GIVEN_WpFV4]",
    "last": "[NAME_FAMILY_orTxwj3I]"
},
"address": {
    "city": "[LOCATION_CITY_UtpIl2tL]",
    "state": "[LOCATION_STATE_n24]",
    "street": "[LOCATION_ADDRESS_KwZ3MdDLSrzNhwB]",
    "zip": 0
},
"description": "[NAME_GIVEN_WpFV4] is a man that lives in [LOCATION_CITY_UtpIl2tL].  He is [DATE_TIME_LLr6L3gpNcOcl3] and is married to [NAME_GIVEN_yWfthDa6]"
}