Skip to content

Commit 4973351

Browse files
authored
Merge pull request #76 from gkumbhat/add_text_contents_response
🧑‍💻 Add text to contents analysis detectors response API
2 parents af57f66 + 702f73e commit 4973351

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/api/openapi_detector_api.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ paths:
4444
- start: 15
4545
end: 25
4646
detection_type: pii
47+
text: foo@bar.com
4748
detection: EmailAddress
4849
score: 0.99
4950
- start: 105
5051
end: 116
52+
text: 123-456-7890
5153
detection_type: pii
5254
detection: SocialSecurity
5355
score: 0.99
@@ -539,6 +541,10 @@ components:
539541
type: integer
540542
title: End
541543
example: 26
544+
text:
545+
type: string
546+
title: Text
547+
example: foo@bar.com
542548
detection:
543549
type: string
544550
title: Detection

src/clients/detector.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ pub struct ContentAnalysisResponse {
9696
pub start: usize,
9797
/// End index of detection
9898
pub end: usize,
99+
/// Text corresponding to detection
100+
pub text: String,
99101
/// Relevant detection class
100102
pub detection: String,
101103
/// Detection type or aggregate detection label
@@ -112,7 +114,7 @@ impl From<ContentAnalysisResponse> for crate::models::TokenClassificationResult
112114
Self {
113115
start: value.start as u32,
114116
end: value.end as u32,
115-
word: "".to_string(), // TODO: fill in when provided in the detector API in the next iteration
117+
word: value.text,
116118
entity: value.detection,
117119
entity_group: value.detection_type,
118120
score: value.score,

0 commit comments

Comments
 (0)