Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[text analytics] add redacted_text to samples #13521

Merged
merged 1 commit into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions sdk/textanalytics/azure-ai-textanalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,15 @@ documents = [
]
response = text_analytics_client.recognize_pii_entities(documents, language="en")
result = [doc for doc in response if not doc.is_error]
for doc in result:
for idx, doc in enumerate(result):
print("Document text: {}".format(documents[idx]))
print("Redacted document text: {}".format(doc.redacted_text))
for entity in doc.entities:
print("Entity: {}".format(entity.text))
print("...Category: {}".format(entity.category))
print("...Confidence Score: {}".format(entity.confidence_score))
print("...Offset: {}".format(entity.offset))
print("...Length: {}".format(entity.length))
print("...Entity: {}".format(entity.text))
print("......Category: {}".format(entity.category))
print("......Confidence Score: {}".format(entity.confidence_score))
print("......Offset: {}".format(entity.offset))
print("......Length: {}".format(entity.length))
```

The returned response is a heterogeneous list of result and error objects: list[[RecognizePiiEntitiesResult][recognize_pii_entities_result], [DocumentError][document_error]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ async def recognize_pii_entities_async(self):

for idx, doc in enumerate(docs):
print("Document text: {}".format(documents[idx]))
print("Redacted document text: {}".format(doc.redacted_text))
for entity in doc.entities:
print("Entity: {}".format(entity.text))
print("Category: {}".format(entity.category))
print("Confidence Score: {}\n".format(entity.confidence_score))
print("...Entity: {}".format(entity.text))
print("......Category: {}".format(entity.category))
print("......Confidence Score: {}\n".format(entity.confidence_score))
# [END recognize_pii_entities_async]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ def recognize_pii_entities(self):

for idx, doc in enumerate(docs):
print("Document text: {}".format(documents[idx]))
print("Redacted document text: {}".format(doc.redacted_text))
for entity in doc.entities:
print("Entity: {}".format(entity.text))
print("Category: {}".format(entity.category))
print("Confidence Score: {}\n".format(entity.confidence_score))
print("...Entity: {}".format(entity.text))
print("......Category: {}".format(entity.category))
print("......Confidence Score: {}\n".format(entity.confidence_score))
# [END recognize_pii_entities]


Expand Down