Analyze textv1.0.0 · JSON Schema
Detects PII entities in one text string or a batch, returning entity types, text offsets, confidence scores, and optional analysis explanations.
1. Detect PII Entities in Customer Input via Refit
Chat API or Rating API invokes IPresidioAnalyzer.AnalyzeAsync through BookWorm.Chassis before anonymizing user-supplied text.
Payload details
text: Input text string (or batch of strings) to scan for PII.language: Two-character ISO 639-1 language code ("en"by default inAnalyzerRequest).entities: Optional allowlist of Presidio entity labels (e.g.,PERSON,EMAIL_ADDRESS).score_threshold: Optional minimum confidence score (0.0–1.0).
Example payload
{ "text": "Please contact Minh Nguyen at minh.nguyen@bookworm.dev regarding order 01960a1b.", "language": "en", "entities": ["PERSON", "EMAIL_ADDRESS"], "score_threshold": 0.6}Using this example
Returns 200 OK with an array of AnalyzerResponse detections containing entity_type, start, end, and score.
using BookWorm.Chassis.AI.Presidio;using BookWorm.Chassis.AI.Presidio.Clients;
// 1. DI registration via BookWorm.Chassis (PresidioExtensions.AddPresidio)builder.AddPresidio();
// 2. Typed Refit invocation (IPresidioAnalyzer)AnalyzerResponse[] detections = await analyzer.AnalyzeAsync( new AnalyzerRequest( "Please contact Minh Nguyen at minh.nguyen@bookworm.dev regarding order 01960a1b.", Language: "en" ), cancellationToken);
foreach (var detection in detections){ Console.WriteLine( $"{detection.EntityType}: {detection.Start}-{detection.End} (score {detection.Score:F2})" );}1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "AnalyzeText",
4 "description": "Request to detect PII in one or more text strings.",
5 "type": "object",
6 "required": ["text", "language"],
7 "properties": {
8 "text": {
9 "description": "Text to analyze, as a single string or a batch of strings.",
10 "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
11 },
12 "language": {
13 "type": "string",
14 "description": "Two-character ISO 639-1 language code.",
15 "examples": ["en"]
16 },
17 "correlation_id": { "type": "string" },
18 "score_threshold": {
19 "type": "number",
20 "description": "Minimum detection confidence score."
21 },
22 "entities": {
23 "type": "array",
24 "items": { "type": "string" },
25 "description": "PII entity types to analyze."
26 },
27 "return_decision_process": {
28 "type": "boolean",
29 "description": "Whether to include analysis explanations in the response."
30 },
31 "ad_hoc_recognizers": {
32 "type": "array",
33 "items": { "type": "object" },
34 "description": "Request-specific recognizers."
35 },
36 "context": {
37 "type": "array",
38 "items": { "type": "string" },
39 "description": "Context words that can improve recognition confidence."
40 }
41 }
42}
43