Learn about advanced options and features available in the Spro SDK.
The secure method in the Spro SDK offers several advanced options to customize the masking process according to your specific requirements. These options allow you to fine-tune the masking behavior and achieve the desired level of data protection.
Mask Options
The secure method offers several customizable options to fit your requirements.
label: Replaces entities with labels (e.g., [PERSON]).
enhanced: Masks entities in markdown format (e.g., PERSON).
Default: char
mask_char (str) (optional)
The character used for masking.
Default: *
Example: Setting mask_char to # will replace text with ####.
entities (list) (optional)
A list of specific entities to mask.
Default: All Entities
Example: ["PERSON", "EMAIL"] to mask only names and email addresses.
Example
from spro import Spro
# Initialize Sprospro = Spro()# Define the inputtext ="My name is John Doe, and my email is john.doe@example.com."# Apply masking with advanced optionsresult = spro.secure( prompt=text, mask_type="enhanced", entities=["PERSON","EMAIL"])print(result["redacted_text"])
Output
{"status":"success","redacted_text":"My name is **[PERSON]**, and my email is **[EMAIL]**","redacted_entities":[{"original":"John Doe","redacted":"**[PERSON]**","label":"PERSON","start":11,"end":19},{"original":"john.doe@example.com","redacted":"**[EMAIL]**","label":"EMAIL","start":37,"end":57}],"metadata":{"mask_char":"*","mask_type":"enhanced","detected_entities":2,"redacted_entities":2,"confidence":100.0,"processing_time":0.007374},"credits":{"remaining_credits":13.846095,"redacted_cost":5e-05},"request_id":"ec27d1df-4ced-4270-995c-0e69c3d2c032"}
With these advanced options, you can tailor the masking process to suit your specific use case and ensure that sensitive information is protected effectively.