Compartilhar via


TextAnalysisClient.AnalyzeText Method

Definition

Overloads

AnalyzeText(AnalyzeTextInput, Nullable<Boolean>, CancellationToken)

Request text analysis over a collection of documents.

AnalyzeText(RequestContent, Nullable<Boolean>, RequestContext)

[Protocol Method] Request text analysis over a collection of documents.

AnalyzeText(AnalyzeTextInput, Nullable<Boolean>, CancellationToken)

Source:
TextAnalysisClient.cs

Request text analysis over a collection of documents.

public virtual Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult> AnalyzeText (Azure.AI.Language.Text.AnalyzeTextInput analyzeTextInput, bool? showStatistics = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AnalyzeText : Azure.AI.Language.Text.AnalyzeTextInput * Nullable<bool> * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult>
override this.AnalyzeText : Azure.AI.Language.Text.AnalyzeTextInput * Nullable<bool> * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult>
Public Overridable Function AnalyzeText (analyzeTextInput As AnalyzeTextInput, Optional showStatistics As Nullable(Of Boolean) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of AnalyzeTextResult)

Parameters

analyzeTextInput
AnalyzeTextInput

The input documents to analyze.

showStatistics
Nullable<Boolean>

(Optional) if set to true, response will contain request and document level statistics.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

analyzeTextInput is null.

Examples

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextEntityLinkingInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("1", "Microsoft was founded by Bill Gates and Paul Allen.")
        {
            Language = "en",
        }, new MultiLanguageInput("2", "Pike place market is my favorite Seattle attraction.")
        {
            Language = "en",
        }},
    },
    ActionContent = new EntityLinkingActionContent
    {
        ModelVersion = "latest",
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextEntityRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("2", "When I was 5 years old I had $90.00 dollars to my name.")
        {
            Language = "en",
        }, new MultiLanguageInput("3", "When we flew from LAX it seemed like we were moving at 10 meters per second. I was lucky to see Amsterdam, Effile Tower, and the Nile.")
        {
            Language = "en",
        }},
    },
    ActionContent = new EntitiesActionContent
    {
        ModelVersion = "latest",
        Exclusions = { EntityCategory.Numeric },
        OverlapPolicy = new AllowOverlapEntityPolicyType(),
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextEntityRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("2", "When I was 5 years old I had $90.00 dollars to my name.")
        {
            Language = "en",
        }, new MultiLanguageInput("3", "When we flew from LAX it seemed like we were moving at 10 meters per second. I was lucky to see Amsterdam, Effile Tower, and the Nile.")
        {
            Language = "en",
        }},
    },
    ActionContent = new EntitiesActionContent
    {
        ModelVersion = "latest",
        Inclusions = { EntityCategory.Location },
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextEntityRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("1", "When I was 5 years old I had $90.00 dollars to my name.")
        {
            Language = "en",
        }},
    },
    ActionContent = new EntitiesActionContent
    {
        ModelVersion = "latest",
        InferenceOptions = new EntityInferenceConfig
        {
            ExcludeNormalizedValues = true,
        },
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextEntityRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("4", "25th April Meeting was an intresting one. At least we gont to experience the WorldCup")
        {
            Language = "en",
        }},
    },
    ActionContent = new EntitiesActionContent
    {
        ModelVersion = "latest",
        OverlapPolicy = new MatchLongestEntityPolicyType(),
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextEntityRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("2", "When I was 5 years old I had $90.00 dollars to my name.")
        {
            Language = "en",
        }, new MultiLanguageInput("3", "When we flew from LAX it seemed like we were moving at 10 meters per second. I was lucky to see Amsterdam, Effile Tower, and the Nile.")
        {
            Language = "en",
        }, new MultiLanguageInput("4", "25th April Meeting was an intresting one. At least we gont to experience the WorldCup")
        {
            Language = "en",
        }, new MultiLanguageInput("5", "My IP is 127.12.1.1 and my phone   number is 5555555555")
        {
            Language = "en",
        }},
    },
    ActionContent = new EntitiesActionContent
    {
        ModelVersion = "latest",
        OverlapPolicy = new AllowOverlapEntityPolicyType(),
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextKeyPhraseExtractionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("1", "Microsoft was founded by Bill Gates and Paul Allen.")
        {
            Language = "en",
        }, new MultiLanguageInput("2", "Text Analytics is one of the Azure Cognitive Services.")
        {
            Language = "en",
        }, new MultiLanguageInput("3", "My cat might need to see a veterinarian.")
        {
            Language = "en",
        }},
    },
    ActionContent = new KeyPhraseActionContent
    {
        ModelVersion = "latest",
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextLanguageDetectionInput
{
    TextInput = new LanguageDetectionTextInput
    {
        LanguageInputs = { new LanguageInput("1", "Hello world"), new LanguageInput("2", "Bonjour tout le monde"), new LanguageInput("3", "Hola mundo"), new LanguageInput("4", "Tumhara naam kya hai?") },
    },
    ActionContent = new LanguageDetectionActionContent
    {
        ModelVersion = "latest",
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextPiiEntitiesRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("1", "My SSN is 859-98-0987")
        {
            Language = "en",
        }, new MultiLanguageInput("2", "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.")
        {
            Language = "en",
        }, new MultiLanguageInput("3", "Is 998.214.865-68 your Brazilian CPF number?")
        {
            Language = "en",
        }},
    },
    ActionContent = new PiiActionContent
    {
        ModelVersion = "latest",
        ExcludePiiCategories = { PiiCategoriesExclude.UsSocialSecurityNumber },
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextPiiEntitiesRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("1", "My name is John Doe My phone number is 424 878 9192")
        {
            Language = "en",
        }},
    },
    ActionContent = new PiiActionContent
    {
        ModelVersion = "latest",
        RedactionPolicy = new EntityMaskPolicyType(),
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextPiiEntitiesRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("1", "My SSN is 859-98-0987")
        {
            Language = "en",
        }, new MultiLanguageInput("2", "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.")
        {
            Language = "en",
        }, new MultiLanguageInput("3", "Is 998.214.865-68 your Brazilian CPF number?")
        {
            Language = "en",
        }},
    },
    ActionContent = new PiiActionContent
    {
        ModelVersion = "latest",
        RedactionPolicy = new CharacterMaskPolicyType
        {
            RedactionCharacter = RedactionCharacter.Minus,
        },
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextPiiEntitiesRecognitionInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("1", "My SSN is 859-98-0987")
        {
            Language = "en",
        }, new MultiLanguageInput("2", "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.")
        {
            Language = "en",
        }, new MultiLanguageInput("3", "Is 998.214.865-68 your Brazilian CPF number?")
        {
            Language = "en",
        }},
    },
    ActionContent = new PiiActionContent
    {
        ModelVersion = "latest",
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

AnalyzeTextInput analyzeTextInput = new TextSentimentAnalysisInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("1", "Great atmosphere. Close to plenty of restaurants, hotels, and transit! Staff are friendly and helpful.")
        {
            Language = "en",
        }},
    },
    ActionContent = new SentimentAnalysisActionContent
    {
        ModelVersion = "latest",
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

Applies to

AnalyzeText(RequestContent, Nullable<Boolean>, RequestContext)

Source:
TextAnalysisClient.cs

[Protocol Method] Request text analysis over a collection of documents.

public virtual Azure.Response AnalyzeText (Azure.Core.RequestContent content, bool? showStatistics = default, Azure.RequestContext context = default);
abstract member AnalyzeText : Azure.Core.RequestContent * Nullable<bool> * Azure.RequestContext -> Azure.Response
override this.AnalyzeText : Azure.Core.RequestContent * Nullable<bool> * Azure.RequestContext -> Azure.Response
Public Overridable Function AnalyzeText (content As RequestContent, Optional showStatistics As Nullable(Of Boolean) = Nothing, Optional context As RequestContext = Nothing) As Response

Parameters

content
RequestContent

The content to send as the body of the request.

showStatistics
Nullable<Boolean>

(Optional) if set to true, response will contain request and document level statistics.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "EntityLinking",
    parameters = new
    {
        modelVersion = "latest",
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                language = "en",
                text = "Microsoft was founded by Bill Gates and Paul Allen.",
            },
            new
            {
                id = "2",
                language = "en",
                text = "Pike place market is my favorite Seattle attraction.",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "EntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
        exclusionList = new object[]
        {
            "Numeric"
        },
        overlapPolicy = new
        {
            policyKind = "allowOverlap",
        },
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "2",
                language = "en",
                text = "When I was 5 years old I had $90.00 dollars to my name.",
            },
            new
            {
                id = "3",
                language = "en",
                text = "When we flew from LAX it seemed like we were moving at 10 meters per second. I was lucky to see Amsterdam, Effile Tower, and the Nile.",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "EntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
        inclusionList = new object[]
        {
            "Location"
        },
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "2",
                language = "en",
                text = "When I was 5 years old I had $90.00 dollars to my name.",
            },
            new
            {
                id = "3",
                language = "en",
                text = "When we flew from LAX it seemed like we were moving at 10 meters per second. I was lucky to see Amsterdam, Effile Tower, and the Nile.",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "EntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
        inferenceOptions = new
        {
            excludeNormalizedValues = true,
        },
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                language = "en",
                text = "When I was 5 years old I had $90.00 dollars to my name.",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "EntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
        overlapPolicy = new
        {
            policyKind = "matchLongest",
        },
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "4",
                language = "en",
                text = "25th April Meeting was an intresting one. At least we gont to experience the WorldCup",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "EntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
        overlapPolicy = new
        {
            policyKind = "allowOverlap",
        },
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "2",
                language = "en",
                text = "When I was 5 years old I had $90.00 dollars to my name.",
            },
            new
            {
                id = "3",
                language = "en",
                text = "When we flew from LAX it seemed like we were moving at 10 meters per second. I was lucky to see Amsterdam, Effile Tower, and the Nile.",
            },
            new
            {
                id = "4",
                language = "en",
                text = "25th April Meeting was an intresting one. At least we gont to experience the WorldCup",
            },
            new
            {
                id = "5",
                language = "en",
                text = "My IP is 127.12.1.1 and my phone   number is 5555555555",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "KeyPhraseExtraction",
    parameters = new
    {
        modelVersion = "latest",
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                language = "en",
                text = "Microsoft was founded by Bill Gates and Paul Allen.",
            },
            new
            {
                id = "2",
                language = "en",
                text = "Text Analytics is one of the Azure Cognitive Services.",
            },
            new
            {
                id = "3",
                language = "en",
                text = "My cat might need to see a veterinarian.",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "LanguageDetection",
    parameters = new
    {
        modelVersion = "latest",
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                text = "Hello world",
            },
            new
            {
                id = "2",
                text = "Bonjour tout le monde",
            },
            new
            {
                id = "3",
                text = "Hola mundo",
            },
            new
            {
                id = "4",
                text = "Tumhara naam kya hai?",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "PiiEntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
        excludePiiCategories = new object[]
        {
            "USSocialSecurityNumber"
        },
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                language = "en",
                text = "My SSN is 859-98-0987",
            },
            new
            {
                id = "2",
                language = "en",
                text = "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.",
            },
            new
            {
                id = "3",
                language = "en",
                text = "Is 998.214.865-68 your Brazilian CPF number?",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "PiiEntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
        redactionPolicy = new
        {
            policyKind = "entityMask",
        },
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                language = "en",
                text = "My name is John Doe My phone number is 424 878 9192",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "PiiEntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
        redactionPolicy = new
        {
            policyKind = "characterMask",
            redactionCharacter = "-",
        },
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                language = "en",
                text = "My SSN is 859-98-0987",
            },
            new
            {
                id = "2",
                language = "en",
                text = "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.",
            },
            new
            {
                id = "3",
                language = "en",
                text = "Is 998.214.865-68 your Brazilian CPF number?",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "PiiEntityRecognition",
    parameters = new
    {
        modelVersion = "latest",
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                language = "en",
                text = "My SSN is 859-98-0987",
            },
            new
            {
                id = "2",
                language = "en",
                text = "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check.",
            },
            new
            {
                id = "3",
                language = "en",
                text = "Is 998.214.865-68 your Brazilian CPF number?",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
TextAnalysisClient client = new TextAnalysisClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    kind = "SentimentAnalysis",
    parameters = new
    {
        modelVersion = "latest",
    },
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "1",
                language = "en",
                text = "Great atmosphere. Close to plenty of restaurants, hotels, and transit! Staff are friendly and helpful.",
            }
        },
    },
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

Applies to