azure.ai.textanalytics package¶
-
class
azure.ai.textanalytics.
TextAnalyticsApiVersion
[source]¶ Text Analytics API versions supported by this package
-
V3_0
= 'v3.0'¶
-
V3_1_PREVIEW
= 'v3.1-preview.2'¶ this is the default version
-
V3_1_PREVIEW_3
= 'v3.1-preview.3'¶
-
-
class
azure.ai.textanalytics.
TextAnalyticsClient
(endpoint: str, credential: Union[AzureKeyCredential, TokenCredential], **kwargs: Any)[source]¶ The Text Analytics API is a suite of text analytics web services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, and language detection. No training data is needed to use this API - just bring your text data. This API uses advanced natural language processing techniques to deliver best in class predictions.
Further documentation can be found in https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview
- Parameters
endpoint (str) – Supported Cognitive Services or Text Analytics resource endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).
credential (
AzureKeyCredential
orTokenCredential
) – Credentials needed for the client to connect to Azure. This can be the an instance of AzureKeyCredential if using a cognitive services/text analytics API key or a token credential fromazure.identity
.
- Keyword Arguments
default_country_hint (str) – Sets the default country_hint to use for all operations. Defaults to “US”. If you don’t want to use a country hint, pass the string “none”.
default_language (str) – Sets the default language to use for all operations. Defaults to “en”.
api_version (str or TextAnalyticsApiVersion) – The API version of the service to use for requests. It defaults to the latest service version. Setting to an older version may result in reduced feature compatibility.
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient(endpoint, AzureKeyCredential(key))
from azure.ai.textanalytics import TextAnalyticsClient from azure.identity import DefaultAzureCredential endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] credential = DefaultAzureCredential() text_analytics_client = TextAnalyticsClient(endpoint, credential=credential)
-
analyze_sentiment
(documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]], **kwargs: Any) → List[Union[AnalyzeSentimentResult, DocumentError]][source]¶ Analyze sentiment for a batch of documents. Turn on opinion mining with show_opinion_mining.
Returns a sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and Neutral) for the document and each sentence within it.
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview#data-limits for document length limits, maximum batch size, and supported text encoding.
- Parameters
documents (list[str] or list[TextDocumentInput] or list[dict[str, str]]) – The set of documents to process as part of this batch. If you wish to specify the ID and language on a per-item basis you must use as input a list[
TextDocumentInput
] or a list of dict representations ofTextDocumentInput
, like {“id”: “1”, “language”: “en”, “text”: “hello world”}.- Keyword Arguments
show_opinion_mining (bool) – Whether to mine the opinions of a sentence and conduct more granular analysis around the aspects of a product or service (also known as aspect-based sentiment analysis). If set to true, the returned
SentenceSentiment
objects will have property mined_opinions containing the result of this analysis. Only available for API version v3.1-preview and up.language (str) – The 2 letter ISO 639-1 representation of language for the entire batch. For example, use “en” for English; “es” for Spanish etc. If not set, uses “en” for English as default. Per-document language will take precedence over whole batch language. See https://aka.ms/talangs for supported languages in Text Analytics API.
model_version (str) – This value indicates which model will be used for scoring, e.g. “latest”, “2019-10-01”. If a model-version is not specified, the API will default to the latest, non-preview version.
show_stats (bool) – If set to true, response will contain document level statistics in the statistics field of the document-level response.
New in version v3.1-preview: The show_opinion_mining parameter.
- Returns
The combined list of
AnalyzeSentimentResult
andDocumentError
in the order the original documents were passed in.- Return type
- Raises
HttpResponseError or TypeError or ValueError –
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key)) documents = [ """I had the best day of my life. I decided to go sky-diving and it made me appreciate my whole life so much more. I developed a deep-connection with my instructor as well, and I feel as if I've made a life-long friend in her.""", """This was a waste of my time. All of the views on this drop are extremely boring, all I saw was grass. 0/10 would not recommend to any divers, even first timers.""", """This was pretty good! The sights were ok, and I had fun with my instructors! Can't complain too much about my experience""", """I only have one word for my experience: WOW!!! I can't believe I have had such a wonderful skydiving company right in my backyard this whole time! I will definitely be a repeat customer, and I want to take my grandmother skydiving too, I know she'll love it!""" ] result = text_analytics_client.analyze_sentiment(documents) docs = [doc for doc in result if not doc.is_error] print("Let's visualize the sentiment of each of these documents") for idx, doc in enumerate(docs): print("Document text: {}".format(documents[idx])) print("Overall sentiment: {}".format(doc.sentiment))
-
begin_analyze
(documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]], entities_recognition_tasks: List[EntitiesRecognitionTask] = None, pii_entities_recognition_tasks: List[PiiEntitiesRecognitionTask] = None, key_phrase_extraction_tasks: List[KeyPhraseExtractionTask] = None, **kwargs: Any) → LROPoller[ItemPaged[TextAnalysisResult]][source]¶ Start a long-running operation to perform a variety of text analysis tasks over a batch of documents.
- Parameters
documents (list[str] or list[TextDocumentInput] or list[dict[str, str]]) – The set of documents to process as part of this batch. If you wish to specify the ID and language on a per-item basis you must use as input a list[
TextDocumentInput
] or a list of dict representations ofTextDocumentInput
, like {“id”: “1”, “language”: “en”, “text”: “hello world”}.tasks (list[Union[EntitiesRecognitionTask, PiiEntitiesRecognitionTask, EntityLinkingTask, KeyPhraseExtractionTask, SentimentAnalysisTask]]) – A list of tasks to include in the analysis. Each task object encapsulates the parameters used for the particular task type.
- Keyword Arguments
display_name (str) – An optional display name to set for the requested analysis.
language (str) – The 2 letter ISO 639-1 representation of language for the entire batch. For example, use “en” for English; “es” for Spanish etc. If not set, uses “en” for English as default. Per-document language will take precedence over whole batch language. See https://aka.ms/talangs for supported languages in Text Analytics API.
show_stats (bool) – If set to true, response will contain document level statistics.
polling_interval (int) – Waiting time between two polls for LRO operations if no Retry-After header is present. Defaults to 30 seconds.
- Returns
An instance of an LROPoller. Call result() on the poller object to return an instance of TextAnalysisResult.
- Raises
HttpResponseError or TypeError or ValueError or NotImplementedError –
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient, \ EntitiesRecognitionTask, \ PiiEntitiesRecognitionTask, \ KeyPhraseExtractionTask endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient( endpoint=endpoint, credential=AzureKeyCredential(key), api_version="v3.1-preview.3" ) documents = [ "We went to Contoso Steakhouse located at midtown NYC last week for a dinner party, and we adore the spot! \ They provide marvelous food and they have a great menu. The chief cook happens to be the owner (I think his name is John Doe) \ and he is super nice, coming out of the kitchen and greeted us all. We enjoyed very much dining in the place! \ The Sirloin steak I ordered was tender and juicy, and the place was impeccably clean. You can even pre-order from their \ online menu at www.contososteakhouse.com, call 312-555-0176 or send email to order@contososteakhouse.com! \ The only complaint I have is the food didn't come fast enough. Overall I highly recommend it!" ] poller = text_analytics_client.begin_analyze( documents, display_name="Sample Text Analysis", entities_recognition_tasks=[EntitiesRecognitionTask()], pii_entities_recognition_tasks=[PiiEntitiesRecognitionTask()], key_phrase_extraction_tasks=[KeyPhraseExtractionTask()] ) result = poller.result() for page in result: for task in page.entities_recognition_results: print("Results of Entities Recognition task:") docs = [doc for doc in task.results if not doc.is_error] for idx, doc in enumerate(docs): print("\nDocument text: {}".format(documents[idx])) 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("------------------------------------------") for task in page.pii_entities_recognition_results: print("Results of PII Entities Recognition task:") docs = [doc for doc in task.results if not doc.is_error] for idx, doc in enumerate(docs): print("Document text: {}".format(documents[idx])) for entity in doc.entities: print("Entity: {}".format(entity.text)) print("Category: {}".format(entity.category)) print("Confidence Score: {}\n".format(entity.confidence_score)) print("------------------------------------------") for task in page.key_phrase_extraction_results: print("Results of Key Phrase Extraction task:") docs = [doc for doc in task.results if not doc.is_error] for idx, doc in enumerate(docs): print("Document text: {}\n".format(documents[idx])) print("Key Phrases: {}\n".format(doc.key_phrases)) print("------------------------------------------")
-
begin_analyze_healthcare
(documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]], **kwargs: Any) → LROPoller[ItemPaged[AnalyzeHealthcareResultItem]][source]¶ Analyze healthcare entities and identify relationships between these entities in a batch of documents.
Entities are associated with references that can be found in existing knowledge bases, such as UMLS, CHV, MSH, etc.
Relations are comprised of a pair of entities and a directional relationship.
- Parameters
documents (list[str] or list[TextDocumentInput] or list[dict[str, str]]) – The set of documents to process as part of this batch. If you wish to specify the ID and language on a per-item basis you must use as input a list[
TextDocumentInput
] or a list of dict representations ofTextDocumentInput
, like {“id”: “1”, “language”: “en”, “text”: “hello world”}.- Keyword Arguments
model_version (str) – This value indicates which model will be used for scoring, e.g. “latest”, “2019-10-01”. If a model-version is not specified, the API will default to the latest, non-preview version.
show_stats (bool) – If set to true, response will contain document level statistics.
polling_interval (int) – Waiting time between two polls for LRO operations if no Retry-After header is present. Defaults to 5 seconds.
continuation_token (str) – A continuation token to restart a poller from a saved state.
- Returns
An instance of an LROPoller. Call result() on the poller object to return a list[
AnalyzeHealthcareResultItem
].- Raises
HttpResponseError or TypeError or ValueError or NotImplementedError –
Example:
-
begin_cancel_analyze_healthcare
(poller: LROPoller[ItemPaged[AnalyzeHealthcareResultItem]], **kwargs) → LROPoller[None][source]¶ Cancel an existing health operation.
- Parameters
poller – The LRO poller object associated with the health operation.
- Returns
An instance of an LROPoller that returns None.
- Return type
- Raises
HttpResponseError or TypeError or ValueError or NotImplementedError –
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient( endpoint=endpoint, credential=AzureKeyCredential(key), api_version="v3.1-preview.3") documents = [ "RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | \ CORONARY ARTERY DISEASE | Signed | DIS | Admission Date: 5/22/2001 \ Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: \ CORONARY ARTERY DISEASE. HISTORY OF PRESENT ILLNESS: \ The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \ The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and \ 50% left main disease , with a strong family history of coronary artery disease with a brother dying at \ the age of 52 from a myocardial infarction and another brother who is status post coronary artery bypass grafting. \ The patient had a stress echocardiogram done on July , 2001 , which showed no wall motion abnormalities ,\ but this was a difficult study due to body habitus. The patient went for six minutes with minimal ST depressions \ in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \ increased symptoms and family history and history left main disease with total occasional of his RCA was referred \ for revascularization with open heart surgery." ] poller = text_analytics_client.begin_analyze_healthcare(documents) text_analytics_client.begin_cancel_analyze_healthcare(poller) poller.wait()
-
close
() → None¶ Close sockets opened by the client. Calling this method is unnecessary when using the client as a context manager.
-
detect_language
(documents: Union[List[str], List[DetectLanguageInput], List[Dict[str, str]]], **kwargs: Any) → List[Union[DetectLanguageResult, DocumentError]][source]¶ Detect language for a batch of documents.
Returns the detected language and a numeric score between zero and one. Scores close to one indicate 100% certainty that the identified language is true. See https://aka.ms/talangs for the list of enabled languages.
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview#data-limits for document length limits, maximum batch size, and supported text encoding.
- Parameters
documents (list[str] or list[DetectLanguageInput] or list[dict[str, str]]) – The set of documents to process as part of this batch. If you wish to specify the ID and country_hint on a per-item basis you must use as input a list[
DetectLanguageInput
] or a list of dict representations ofDetectLanguageInput
, like {“id”: “1”, “country_hint”: “us”, “text”: “hello world”}.- Keyword Arguments
country_hint (str) – Country of origin hint for the entire batch. Accepts two letter country codes specified by ISO 3166-1 alpha-2. Per-document country hints will take precedence over whole batch hints. Defaults to “US”. If you don’t want to use a country hint, pass the string “none”.
model_version (str) – Version of the model used on the service side for scoring, e.g. “latest”, “2019-10-01”. If a model version is not specified, the API will default to the latest, non-preview version.
show_stats (bool) – If set to true, response will contain document level statistics in the statistics field of the document-level response.
- Returns
The combined list of
DetectLanguageResult
andDocumentError
in the order the original documents were passed in.- Return type
- Raises
HttpResponseError or TypeError or ValueError –
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key)) documents = [ """ The concierge Paulette was extremely helpful. Sadly when we arrived the elevator was broken, but with Paulette's help we barely noticed this inconvenience. She arranged for our baggage to be brought up to our room with no extra charge and gave us a free meal to refurbish all of the calories we lost from walking up the stairs :). Can't say enough good things about my experience! """, """ 最近由于工作压力太大,我们决定去富酒店度假。那儿的温泉实在太舒服了,我跟我丈夫都完全恢复了工作前的青春精神!加油! """ ] result = text_analytics_client.detect_language(documents) reviewed_docs = [doc for doc in result if not doc.is_error] print("Let's see what language each review is in!") for idx, doc in enumerate(reviewed_docs): print("Review #{} is in '{}', which has ISO639-1 name '{}'\n".format( idx, doc.primary_language.name, doc.primary_language.iso6391_name )) if doc.is_error: print(doc.id, doc.error)
-
extract_key_phrases
(documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]], **kwargs: Any) → List[Union[ExtractKeyPhrasesResult, DocumentError]][source]¶ Extract key phrases from a batch of documents.
Returns a list of strings denoting the key phrases in the input text. For example, for the input text “The food was delicious and there were wonderful staff”, the API returns the main talking points: “food” and “wonderful staff”
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview#data-limits for document length limits, maximum batch size, and supported text encoding.
- Parameters
documents (list[str] or list[TextDocumentInput] or list[dict[str, str]]) – The set of documents to process as part of this batch. If you wish to specify the ID and language on a per-item basis you must use as input a list[
TextDocumentInput
] or a list of dict representations ofTextDocumentInput
, like {“id”: “1”, “language”: “en”, “text”: “hello world”}.- Keyword Arguments
language (str) – The 2 letter ISO 639-1 representation of language for the entire batch. For example, use “en” for English; “es” for Spanish etc. If not set, uses “en” for English as default. Per-document language will take precedence over whole batch language. See https://aka.ms/talangs for supported languages in Text Analytics API.
model_version (str) – This value indicates which model will be used for scoring, e.g. “latest”, “2019-10-01”. If a model-version is not specified, the API will default to the latest, non-preview version.
show_stats (bool) – If set to true, response will contain document level statistics in the statistics field of the document-level response.
- Returns
The combined list of
ExtractKeyPhrasesResult
andDocumentError
in the order the original documents were passed in.- Return type
- Raises
HttpResponseError or TypeError or ValueError –
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key)) articles = [ """ Washington, D.C. Autumn in DC is a uniquely beautiful season. The leaves fall from the trees in a city chockful of forrests, leaving yellow leaves on the ground and a clearer view of the blue sky above... """, """ Redmond, WA. In the past few days, Microsoft has decided to further postpone the start date of its United States workers, due to the pandemic that rages with no end in sight... """, """ Redmond, WA. Employees at Microsoft can be excited about the new coffee shop that will open on campus once workers no longer have to work remotely... """ ] result = text_analytics_client.extract_key_phrases(articles) for idx, doc in enumerate(result): if not doc.is_error: print("Key phrases in article #{}: {}".format( idx + 1, ", ".join(doc.key_phrases) ))
-
recognize_entities
(documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]], **kwargs: Any) → List[Union[RecognizeEntitiesResult, DocumentError]][source]¶ Recognize entities for a batch of documents.
Identifies and categorizes entities in your text as people, places, organizations, date/time, quantities, percentages, currencies, and more. For the list of supported entity types, check: https://aka.ms/taner
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview#data-limits for document length limits, maximum batch size, and supported text encoding.
- Parameters
documents (list[str] or list[TextDocumentInput] or list[dict[str, str]]) – The set of documents to process as part of this batch. If you wish to specify the ID and language on a per-item basis you must use as input a list[
TextDocumentInput
] or a list of dict representations ofTextDocumentInput
, like {“id”: “1”, “language”: “en”, “text”: “hello world”}.- Keyword Arguments
language (str) – The 2 letter ISO 639-1 representation of language for the entire batch. For example, use “en” for English; “es” for Spanish etc. If not set, uses “en” for English as default. Per-document language will take precedence over whole batch language. See https://aka.ms/talangs for supported languages in Text Analytics API.
model_version (str) – This value indicates which model will be used for scoring, e.g. “latest”, “2019-10-01”. If a model-version is not specified, the API will default to the latest, non-preview version.
show_stats (bool) – If set to true, response will contain document level statistics in the statistics field of the document-level response.
- Returns
The combined list of
RecognizeEntitiesResult
andDocumentError
in the order the original documents were passed in.- Return type
- Raises
HttpResponseError or TypeError or ValueError –
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key)) reviews = [ """I work for Foo Company, and we hired Contoso for our annual founding ceremony. The food was amazing and we all can't say enough good words about the quality and the level of service.""", """We at the Foo Company re-hired Contoso after all of our past successes with the company. Though the food was still great, I feel there has been a quality drop since their last time catering for us. Is anyone else running into the same problem?""", """Bar Company is over the moon about the service we received from Contoso, the best sliders ever!!!!""" ] result = text_analytics_client.recognize_entities(reviews) result = [review for review in result if not review.is_error] for idx, review in enumerate(result): for entity in review.entities: print("Entity '{}' has category '{}'".format(entity.text, entity.category))
-
recognize_linked_entities
(documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]], **kwargs: Any) → List[Union[RecognizeLinkedEntitiesResult, DocumentError]][source]¶ Recognize linked entities from a well-known knowledge base for a batch of documents.
Identifies and disambiguates the identity of each entity found in text (for example, determining whether an occurrence of the word Mars refers to the planet, or to the Roman god of war). Recognized entities are associated with URLs to a well-known knowledge base, like Wikipedia.
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview#data-limits for document length limits, maximum batch size, and supported text encoding.
- Parameters
documents (list[str] or list[TextDocumentInput] or list[dict[str, str]]) – The set of documents to process as part of this batch. If you wish to specify the ID and language on a per-item basis you must use as input a list[
TextDocumentInput
] or a list of dict representations ofTextDocumentInput
, like {“id”: “1”, “language”: “en”, “text”: “hello world”}.- Keyword Arguments
language (str) – The 2 letter ISO 639-1 representation of language for the entire batch. For example, use “en” for English; “es” for Spanish etc. If not set, uses “en” for English as default. Per-document language will take precedence over whole batch language. See https://aka.ms/talangs for supported languages in Text Analytics API.
model_version (str) – This value indicates which model will be used for scoring, e.g. “latest”, “2019-10-01”. If a model-version is not specified, the API will default to the latest, non-preview version.
show_stats (bool) – If set to true, response will contain document level statistics in the statistics field of the document-level response.
- Returns
The combined list of
RecognizeLinkedEntitiesResult
andDocumentError
in the order the original documents were passed in.- Return type
- Raises
HttpResponseError or TypeError or ValueError –
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key)) documents = [ """ Microsoft was founded by Bill Gates with some friends he met at Harvard. One of his friends, Steve Ballmer, eventually became CEO after Bill Gates as well. Steve Ballmer eventually stepped down as CEO of Microsoft, and was succeeded by Satya Nadella. Microsoft originally moved its headquarters to Bellevue, Wahsington in Januaray 1979, but is now headquartered in Redmond. """ ] result = text_analytics_client.recognize_linked_entities(documents) docs = [doc for doc in result if not doc.is_error] print( "Let's map each entity to it's Wikipedia article. I also want to see how many times each " "entity is mentioned in a document\n\n" ) entity_to_url = {} for doc in docs: for entity in doc.entities: print("Entity '{}' has been mentioned '{}' time(s)".format( entity.name, len(entity.matches) )) if entity.data_source == "Wikipedia": entity_to_url[entity.name] = entity.url
-
recognize_pii_entities
(documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]], **kwargs: Any) → List[Union[RecognizePiiEntitiesResult, DocumentError]][source]¶ Recognize entities containing personal information for a batch of documents.
Returns a list of personal information entities (“SSN”, “Bank Account”, etc) in the document. For the list of supported entity types, check https://aka.ms/tanerpii
See https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview#data-limits for document length limits, maximum batch size, and supported text encoding.
- Parameters
documents (list[str] or list[TextDocumentInput] or list[dict[str, str]]) – The set of documents to process as part of this batch. If you wish to specify the ID and language on a per-item basis you must use as input a list[
TextDocumentInput
] or a list of dict representations ofTextDocumentInput
, like {“id”: “1”, “language”: “en”, “text”: “hello world”}.- Keyword Arguments
language (str) – The 2 letter ISO 639-1 representation of language for the entire batch. For example, use “en” for English; “es” for Spanish etc. If not set, uses “en” for English as default. Per-document language will take precedence over whole batch language. See https://aka.ms/talangs for supported languages in Text Analytics API.
model_version (str) – This value indicates which model will be used for scoring, e.g. “latest”, “2019-10-01”. If a model-version is not specified, the API will default to the latest, non-preview version.
show_stats (bool) – If set to true, response will contain document level statistics in the statistics field of the document-level response.
domain_filter (str or PiiEntityDomainType) – Filters the response entities to ones only included in the specified domain. I.e., if set to ‘PHI’, will only return entities in the Protected Healthcare Information domain. See https://aka.ms/tanerpii for more information.
- Returns
The combined list of
RecognizePiiEntitiesResult
andDocumentError
in the order the original documents were passed in.- Return type
- Raises
HttpResponseError or TypeError or ValueError –
Example:
from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] text_analytics_client = TextAnalyticsClient( endpoint=endpoint, credential=AzureKeyCredential(key) ) documents = [ """Parker Doe has repaid all of their loans as of 2020-04-25. Their SSN is 859-98-0987. To contact them, use their phone number 555-555-5555. They are originally from Brazil and have Brazilian CPF number 998.214.865-68""" ] result = text_analytics_client.recognize_pii_entities(documents) docs = [doc for doc in result if not doc.is_error] print( "Let's compare the original document with the documents after redaction. " "I also want to comb through all of the entities that got redacted" ) 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 '{}' with category '{}' got redacted".format( entity.text, entity.category ))
-
class
azure.ai.textanalytics.
DetectLanguageInput
(**kwargs)[source]¶ The input document to be analyzed for detecting language.
- Variables
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
class
azure.ai.textanalytics.
TextDocumentInput
(**kwargs)[source]¶ The input document to be analyzed by the service.
- Variables
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
get
(key, default=None)¶
-
has_key
(k)¶
-
classmethod
is_xml_model
()¶
-
items
()¶
-
keys
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
update
(*args, **kwargs)¶
-
validate
()¶ Validate this model recursively and return a list of ValidationError.
- Returns
A list of validation error
- Return type
-
values
()¶
-
class
azure.ai.textanalytics.
DetectedLanguage
(**kwargs)[source]¶ DetectedLanguage contains the predicted language found in text, its confidence score, and its ISO 639-1 representation.
- Variables
name (str) – Long name of a detected language (e.g. English, French).
iso6391_name (str) – A two letter representation of the detected language according to the ISO 639-1 standard (e.g. en, fr).
confidence_score (float) – A confidence score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
RecognizeEntitiesResult
(**kwargs)[source]¶ RecognizeEntitiesResult is a result object which contains the recognized entities from a particular document.
- Variables
id (str) – Unique, non-empty document identifier that matches the document id that was passed in with the request. If not specified in the request, an id is assigned for the document.
entities (list[CategorizedEntity]) – Recognized entities in the document.
warnings (list[TextAnalyticsWarning]) – Warnings encountered while processing document. Results will still be returned if there are warnings, but they may not be fully accurate.
statistics (TextDocumentStatistics) – If show_stats=True was specified in the request this field will contain information about the document payload.
is_error (bool) – Boolean check for error item when iterating over list of results. Always False for an instance of a RecognizeEntitiesResult.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
DetectLanguageResult
(**kwargs)[source]¶ DetectLanguageResult is a result object which contains the detected language of a particular document.
- Variables
id (str) – Unique, non-empty document identifier that matches the document id that was passed in with the request. If not specified in the request, an id is assigned for the document.
primary_language (DetectedLanguage) – The primary language detected in the document.
warnings (list[TextAnalyticsWarning]) – Warnings encountered while processing document. Results will still be returned if there are warnings, but they may not be fully accurate.
statistics (TextDocumentStatistics) – If show_stats=True was specified in the request this field will contain information about the document payload.
is_error (bool) – Boolean check for error item when iterating over list of results. Always False for an instance of a DetectLanguageResult.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
CategorizedEntity
(**kwargs)[source]¶ CategorizedEntity contains information about a particular entity found in text.
- Variables
text (str) – Entity text as appears in the request.
category (str) – Entity category, such as Person/Location/Org/SSN etc
subcategory (str) – Entity subcategory, such as Age/Year/TimeRange etc
offset (int) – The entity text offset from the start of the document. Returned in unicode code points. Only returned for API versions v3.1-preview and up.
confidence_score (float) – Confidence score between 0 and 1 of the extracted entity.
New in version v3.1-preview: The offset property.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
TextAnalyticsError
(**kwargs)[source]¶ TextAnalyticsError contains the error code, message, and other details that explain why the batch or individual document failed to be processed by the service.
- Variables
code (str) – Error code. Possible values include: ‘invalidRequest’, ‘invalidArgument’, ‘internalServerError’, ‘serviceUnavailable’, ‘invalidParameterValue’, ‘invalidRequestBodyFormat’, ‘emptyRequest’, ‘missingInputRecords’, ‘invalidDocument’, ‘modelVersionIncorrect’, ‘invalidDocumentBatch’, ‘unsupportedLanguageCode’, ‘invalidCountryHint’
message (str) – Error message.
target (str) – Error target.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
TextAnalyticsWarning
(**kwargs)[source]¶ TextAnalyticsWarning contains the warning code and message that explains why the response has a warning.
- Variables
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
ExtractKeyPhrasesResult
(**kwargs)[source]¶ ExtractKeyPhrasesResult is a result object which contains the key phrases found in a particular document.
- Variables
id (str) – Unique, non-empty document identifier that matches the document id that was passed in with the request. If not specified in the request, an id is assigned for the document.
key_phrases (list[str]) – A list of representative words or phrases. The number of key phrases returned is proportional to the number of words in the input document.
warnings (list[TextAnalyticsWarning]) – Warnings encountered while processing document. Results will still be returned if there are warnings, but they may not be fully accurate.
statistics (TextDocumentStatistics) – If show_stats=True was specified in the request this field will contain information about the document payload.
is_error (bool) – Boolean check for error item when iterating over list of results. Always False for an instance of a ExtractKeyPhrasesResult.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
RecognizeLinkedEntitiesResult
(**kwargs)[source]¶ RecognizeLinkedEntitiesResult is a result object which contains links to a well-known knowledge base, like for example, Wikipedia or Bing.
- Variables
id (str) – Unique, non-empty document identifier that matches the document id that was passed in with the request. If not specified in the request, an id is assigned for the document.
entities (list[LinkedEntity]) – Recognized well-known entities in the document.
warnings (list[TextAnalyticsWarning]) – Warnings encountered while processing document. Results will still be returned if there are warnings, but they may not be fully accurate.
statistics (TextDocumentStatistics) – If show_stats=True was specified in the request this field will contain information about the document payload.
is_error (bool) – Boolean check for error item when iterating over list of results. Always False for an instance of a RecognizeLinkedEntitiesResult.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
AnalyzeSentimentResult
(**kwargs)[source]¶ AnalyzeSentimentResult is a result object which contains the overall predicted sentiment and confidence scores for your document and a per-sentence sentiment prediction with scores.
- Variables
id (str) – Unique, non-empty document identifier that matches the document id that was passed in with the request. If not specified in the request, an id is assigned for the document.
sentiment (str) – Predicted sentiment for document (Negative, Neutral, Positive, or Mixed). Possible values include: ‘positive’, ‘neutral’, ‘negative’, ‘mixed’
warnings (list[TextAnalyticsWarning]) – Warnings encountered while processing document. Results will still be returned if there are warnings, but they may not be fully accurate.
statistics (TextDocumentStatistics) – If show_stats=True was specified in the request this field will contain information about the document payload.
confidence_scores (SentimentConfidenceScores) – Document level sentiment confidence scores between 0 and 1 for each sentiment label.
sentences (list[SentenceSentiment]) – Sentence level sentiment analysis.
is_error (bool) – Boolean check for error item when iterating over list of results. Always False for an instance of a AnalyzeSentimentResult.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
TextDocumentStatistics
(**kwargs)[source]¶ TextDocumentStatistics contains information about the document payload.
- Variables
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
DocumentError
(**kwargs)[source]¶ DocumentError is an error object which represents an error on the individual document.
- Variables
id (str) – Unique, non-empty document identifier that matches the document id that was passed in with the request. If not specified in the request, an id is assigned for the document.
error (TextAnalyticsError) – The document error.
is_error (bool) – Boolean check for error item when iterating over list of results. Always True for an instance of a DocumentError.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
LinkedEntity
(**kwargs)[source]¶ LinkedEntity contains a link to the well-known recognized entity in text. The link comes from a data source like Wikipedia or Bing. It additionally includes all of the matches of this entity found in the document.
- Variables
name (str) – Entity Linking formal name.
matches (list[LinkedEntityMatch]) – List of instances this entity appears in the text.
language (str) – Language used in the data source.
data_source_entity_id (str) – Unique identifier of the recognized entity from the data source.
url (str) – URL to the entity’s page from the data source.
data_source (str) – Data source used to extract entity linking, such as Wiki/Bing etc.
bing_entity_search_api_id (str) – Bing Entity Search unique identifier of the recognized entity. Use in conjunction with the Bing Entity Search SDK to fetch additional relevant information. Only available for API version v3.1-preview and up.
New in version v3.1-preview: The bing_entity_search_api_id property.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
LinkedEntityMatch
(**kwargs)[source]¶ A match for the linked entity found in text. Provides the confidence score of the prediction and where the entity was found in the text.
- Variables
confidence_score (float) – If a well-known item is recognized, a decimal number denoting the confidence level between 0 and 1 will be returned.
text (str) – Entity text as appears in the request.
offset (int) – The linked entity match text offset from the start of the document. Returned in unicode code points. Only returned for API versions v3.1-preview and up.
New in version v3.1-preview: The offset property.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
TextDocumentBatchStatistics
(**kwargs)[source]¶ TextDocumentBatchStatistics contains information about the request payload. Note: This object is not returned in the response and needs to be retrieved by a response hook.
- Variables
document_count (int) – Number of documents submitted in the request.
valid_document_count (int) – Number of valid documents. This excludes empty, over-size limit or non-supported languages documents.
erroneous_document_count (int) – Number of invalid documents. This includes empty, over-size limit or non-supported languages documents.
transaction_count (long) – Number of transactions for the request.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
SentenceSentiment
(**kwargs)[source]¶ SentenceSentiment contains the predicted sentiment and confidence scores for each individual sentence in the document.
- Variables
text (str) – The sentence text.
sentiment (str) – The predicted Sentiment for the sentence. Possible values include: ‘positive’, ‘neutral’, ‘negative’
confidence_scores (SentimentConfidenceScores) – The sentiment confidence score between 0 and 1 for the sentence for all labels.
offset (int) – The sentence offset from the start of the document. Returned in unicode code points. Only returned for API versions v3.1-preview and up.
mined_opinions (list[MinedOpinion]) – The list of opinions mined from this sentence. For example in the sentence “The food is good, but the service is bad”, we would mine the two opinions “food is good” and “service is bad”. Only returned if show_opinion_mining is set to True in the call to analyze_sentiment and api version is v3.1-preview and up.
New in version v3.1-preview: The offset and mined_opinions properties.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
SentimentConfidenceScores
(**kwargs)[source]¶ The confidence scores (Softmax scores) between 0 and 1. Higher values indicate higher confidence.
- Variables
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
MinedOpinion
(**kwargs)[source]¶ A mined opinion object represents an opinion we’ve extracted from a sentence. It consists of both an aspect that these opinions are about, and the actual opinions themselves.
- Variables
aspect (AspectSentiment) – The aspect of a product/service that this opinion is about
opinions (list[OpinionSentiment]) – The actual opinions of the aspect
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
AspectSentiment
(**kwargs)[source]¶ AspectSentiment contains the related opinions, predicted sentiment, confidence scores and other information about an aspect of a product. An aspect of a product/service is a key component of that product/service. For example in “The food at Hotel Foo is good”, “food” is an aspect of “Hotel Foo”.
- Variables
text (str) – The aspect text.
sentiment (str) – The predicted Sentiment for the aspect. Possible values include ‘positive’, ‘mixed’, and ‘negative’.
confidence_scores (SentimentConfidenceScores) – The sentiment confidence score between 0 and 1 for the aspect for ‘positive’ and ‘negative’ labels. It’s score for ‘neutral’ will always be 0
offset (int) – The aspect offset from the start of the document. Returned in unicode code points.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
OpinionSentiment
(**kwargs)[source]¶ OpinionSentiment contains the predicted sentiment, confidence scores and other information about an opinion of an aspect. For example, in the sentence “The food is good”, the opinion of the aspect ‘food’ is ‘good’.
- Variables
text (str) – The opinion text.
sentiment (str) – The predicted Sentiment for the opinion. Possible values include ‘positive’, ‘mixed’, and ‘negative’.
confidence_scores (SentimentConfidenceScores) – The sentiment confidence score between 0 and 1 for the opinion for ‘positive’ and ‘negative’ labels. It’s score for ‘neutral’ will always be 0
offset (int) – The opinion offset from the start of the document. Returned in unicode code points.
is_negated (bool) – Whether the opinion is negated. For example, in “The food is not good”, the opinion “good” is negated.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
RecognizePiiEntitiesResult
(**kwargs)[source]¶ RecognizePiiEntitiesResult is a result object which contains the recognized Personally Identifiable Information (PII) entities from a particular document.
- Variables
id (str) – Unique, non-empty document identifier that matches the document id that was passed in with the request. If not specified in the request, an id is assigned for the document.
entities (list[PiiEntity]) – Recognized PII entities in the document.
redacted_text (str) – Returns the text of the input document with all of the PII information redacted out. Only returned for API versions v3.1-preview and up.
warnings (list[TextAnalyticsWarning]) – Warnings encountered while processing document. Results will still be returned if there are warnings, but they may not be fully accurate.
statistics (TextDocumentStatistics) – If show_stats=True was specified in the request this field will contain information about the document payload.
is_error (bool) – Boolean check for error item when iterating over list of results. Always False for an instance of a RecognizePiiEntitiesResult.
New in version v3.1-preview: The redacted_text parameter.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
PiiEntity
(**kwargs)[source]¶ PiiEntity contains information about a Personally Identifiable Information (PII) entity found in text.
- Variables
text (str) – Entity text as appears in the request.
category (str) – Entity category, such as Financial Account Identification/Social Security Number/Phone Number, etc.
subcategory (str) – Entity subcategory, such as Credit Card/EU Phone number/ABA Routing Numbers, etc.
offset (int) – The PII entity text offset from the start of the document. Returned in unicode code points.
confidence_score (float) – Confidence score between 0 and 1 of the extracted entity.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
PiiEntityDomainType
[source]¶ The different domains of PII entities that users can filter by
-
PROTECTED_HEALTH_INFORMATION
= 'PHI'¶
-
-
class
azure.ai.textanalytics.
AnalyzeHealthcareResultItem
(**kwargs)[source]¶ AnalyzeHealthcareResultItem contains the Healthcare entities and relations from a particular document.
- Variables
id (str) – Unique, non-empty document identifier that matches the document id that was passed in with the request. If not specified in the request, an id is assigned for the document.
entities (list[HealthcareEntity]) – Identified Healthcare entities in the document.
relations (list[HealthcareRelation]) – A list of detected relations between recognized entities.
warnings (list[TextAnalyticsWarning]) – Warnings encountered while processing document. Results will still be returned if there are warnings, but they may not be fully accurate.
statistics (TextDocumentStatistics) – If show_stats=true was specified in the request this field will contain information about the document payload.
is_error (bool) – Boolean check for error item when iterating over list of results. Always False for an instance of a AnalyzeHealthcareResult.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
AnalyzeHealthcareResult
(*args, **kwargs)[source]¶ Return an iterator of items.
args and kwargs will be passed to the PageIterator constructor directly, except page_iterator_class
-
by_page
(continuation_token: Optional[str] = None) → Iterator[Iterator[ReturnType]]¶ Get an iterator of pages of objects, instead of an iterator of objects.
- Parameters
continuation_token (str) – An opaque continuation token. This value can be retrieved from the continuation_token field of a previous generator object. If specified, this generator will begin returning results from this point.
- Returns
An iterator of pages (themselves iterator of objects)
-
next
()¶ Return the next item from the iterator. When exhausted, raise StopIteration
-
-
class
azure.ai.textanalytics.
HealthcareEntity
(**kwargs)[source]¶ HealthcareEntity contains information about a Healthcare entity found in text.
- Variables
text (str) – Entity text as appears in the request.
category (str) – Entity category, such as Dosage or MedicationName, etc.
subcategory (str) – Entity subcategory. # TODO: add subcategory examples
offset (int) – The Healthcare entity text offset from the start of the document.
confidence_score (float) – Confidence score between 0 and 1 of the extracted entity.
links (list[HealthcareEntityLink]) – A collection of entity references in known data sources.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
HealthcareRelation
(**kwargs)[source]¶ HealthcareRelation contains information describing a relationship between two entities found in text.
- Variables
type (str) – The type of relation, such as DosageOfMedication or FrequencyOfMedication, etc.
is_bidirectional (bool) – Boolean value indicating that the relationship between the two entities is bidirectional. If true the relation between the entities is bidirectional, otherwise directionality is source to target.
source (HealthcareEntity) – A reference to an extracted Healthcare entity representing the source of the relation.
target (HealthcareEntity) – A reference to an extracted Healthcare entity representing the target of the relation.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
HealthcareEntityLink
(**kwargs)[source]¶ HealthcareEntityLink contains information representing an entity reference in a known data source.
- Variables
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
EntitiesRecognitionTask
(**kwargs)[source]¶ EntitiesRecognitionTask encapsulates the parameters for starting a long-running Entities Recognition operation.
- Variables
model_version (str) – The model version to use for the analysis.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
PiiEntitiesRecognitionTask
(**kwargs)[source]¶ PiiEntitiesRecognitionTask encapsulates the parameters for starting a long-running PII Entities Recognition operation.
- Variables
subset of the entity categories. Possible values include ‘PHI’ or None.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
KeyPhraseExtractionTask
(**kwargs)[source]¶ KeyPhraseExtractionTask encapsulates the parameters for starting a long-running Key Phrase Extraction operation.
- Variables
model_version (str) – The model version to use for the analysis.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
TextAnalysisResult
(**kwargs)[source]¶ TextAnalysisResult contains the results of multiple text analyses performed on a batch of documents.
- Variables
entities_recognition_results (list[EntitiesRecognitionTaskResult]) – A list of objects containing results for all Entity Recognition tasks included in the analysis.
pii_entities_recognition_results – A list of objects containing results for all PII Entity Recognition tasks included in the analysis.
key_phrase_extraction_results (list[KeyPhraseExtractionTaskResult]) – A list of objects containing results for all Key Phrase Extraction tasks included in the analysis.
-
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-
class
azure.ai.textanalytics.
RequestStatistics
(**kwargs)[source]¶ -
get
(key, default=None)¶
-
has_key
(k)¶
-
items
()¶
-
keys
()¶
-
update
(*args, **kwargs)¶
-
values
()¶
-