I am new to Azure. I want to use Azure AI’s language detection service, which I have set up using the following code on my local machine:
import os
from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential
language_key = os.environ.get('LANGUAGE_KEY')
language_endpoint = os.environ.get('LANGUAGE_ENDPOINT')
def authenticate_client():
ta_credential = AzureKeyCredential(language_key)
text_analytics_client = TextAnalyticsClient(
endpoint=language_endpoint,
credential=ta_credential)
return text_analytics_client
client = authenticate_client()
def pii_recognition_example(client):
documents = [
"The employee's SSN is 859-98-0987. My name is John."
]
response = client.recognize_pii_entities(documents) #, language="en"
result = [doc for doc in response if not doc.is_error]
for doc in result:
print("Redacted Text: {}".format(doc.redacted_text))
for entity in doc.entities:
print("Entity: {}".format(entity.text))
print("tCategory: {}".format(entity.category))
print("tConfidence Score: {}".format(entity.confidence_score))
print("tOffset: {}".format(entity.offset))
print("tLength: {}".format(entity.length))
pii_recognition_example(client)
Now, I want to adjust the code to use textSplitMode=”sentences” to detect the language of each sentence instead of each paragraph. I have tried various methods to implement this using the textSplitMode parameter, but it hasn’t been successful. I understand that I could create a custom function for this purpose, but I prefer to utilize Azure services for now.
For reference, here is the documentation path to the Text Split cognitive skill in Azure:
[text](Now, I want to adjust the code to use textSplitMode=”sentences” to detect the language of each sentence instead of each paragraph. I have tried various methods to implement this using the textSplitMode parameter, but it hasn’t been successful. I understand that I could create a custom function for this purpose, but I prefer to utilize Azure services for now.
For reference, here is the documentation path to the Text Split cognitive skill in Azure:Now, I want to adjust the code to use textSplitMode=”sentences” to detect the language of each sentence instead of each paragraph. I have tried various methods to implement this using the textSplitMode parameter, but it hasn’t been successful. I understand that I could create a custom function for this purpose, but I prefer to utilize Azure services for now.
For reference, here is the documentation path to the Text Split cognitive skill in Azure:)
Ibrar Babar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.