TextAnalysisClient.AnalyzeTextAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AnalyzeTextAsync(AnalyzeTextInput, Nullable<Boolean>, CancellationToken) |
Request text analysis over a collection of documents. |
AnalyzeTextAsync(RequestContent, Nullable<Boolean>, RequestContext) |
[Protocol Method] Request text analysis over a collection of documents.
|
AnalyzeTextAsync(AnalyzeTextInput, Nullable<Boolean>, CancellationToken)
- Source:
- TextAnalysisClient.cs
Request text analysis over a collection of documents.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult>> AnalyzeTextAsync (Azure.AI.Language.Text.AnalyzeTextInput analyzeTextInput, bool? showStatistics = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AnalyzeTextAsync : Azure.AI.Language.Text.AnalyzeTextInput * Nullable<bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult>>
override this.AnalyzeTextAsync : Azure.AI.Language.Text.AnalyzeTextInput * Nullable<bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult>>
Public Overridable Function AnalyzeTextAsync (analyzeTextInput As AnalyzeTextInput, Optional showStatistics As Nullable(Of Boolean) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of AnalyzeTextResult))
Parameters
- analyzeTextInput
- AnalyzeTextInput
The input documents to analyze.
(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 AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
This sample shows how to call AnalyzeTextAsync.
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 = await client.AnalyzeTextAsync(analyzeTextInput);
Applies to
AnalyzeTextAsync(RequestContent, Nullable<Boolean>, RequestContext)
- Source:
- TextAnalysisClient.cs
[Protocol Method] Request text analysis over a collection of documents.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler AnalyzeTextAsync(AnalyzeTextInput, Nullable<Boolean>, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> AnalyzeTextAsync (Azure.Core.RequestContent content, bool? showStatistics = default, Azure.RequestContext context = default);
abstract member AnalyzeTextAsync : Azure.Core.RequestContent * Nullable<bool> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.AnalyzeTextAsync : Azure.Core.RequestContent * Nullable<bool> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function AnalyzeTextAsync (content As RequestContent, Optional showStatistics As Nullable(Of Boolean) = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- content
- RequestContent
The content to send as the body of the request.
(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 AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
This sample shows how to call AnalyzeTextAsync 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 = await client.AnalyzeTextAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());