Skip to content

Commit

Permalink
[textanalytics] update code snippets in md files from samples source …
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
nsalem95 committed Feb 9, 2021
1 parent 82f27ed commit ca6a1ad
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
41 changes: 30 additions & 11 deletions sdk/textanalytics/Azure.AI.TextAnalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,16 +485,29 @@ Text Analytics for health is a containerized service that extracts and labels re
The Analyze functionality allows to choose which of the supported Text Analytics features to execute in the same set of documents. Currently the supported features are: entity recognition, key phrase extraction, and Personally Identifiable Information (PII) Recognition. For more information see [How to: Use Text Analytics for analyze operation][analyze_operation_howto].

```C# Snippet:AnalyzeOperationBatchConvenience
string document = @"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!";

var batchDocuments = new List<string> { document };
string documentA = @"We love this trail and make the trip every year. The views are breathtaking and well
worth the hike! Yesterday was foggy though, so we missed the spectacular views.
We tried again today and it was amazing. Everyone in my family liked the trail although
it was too challenging for the less athletic among us.
Not necessarily recommended for small children.
A hotel close to the trail offers services for childcare in case you want that.";

string documentB = @"Last week we stayed at Hotel Foo to celebrate our anniversary. The staff knew about
our anniversary so they helped me organize a little surprise for my partner.
The room was clean and with the decoration I requested. It was perfect!";

string documentC = @"That was the best day of my life! We went on a 4 day trip where we stayed at Hotel Foo.
They had great amenities that included an indoor pool, a spa, and a bar.
The spa offered couples massages which were really good.
The spa was clean and felt very peaceful. Overall the whole experience was great.
We will definitely come back.";

var batchDocuments = new List<string>
{
documentA,
documentB,
documentC
};

TextAnalyticsActions batchActions = new TextAnalyticsActions()
{
Expand All @@ -506,7 +519,13 @@ The Analyze functionality allows to choose which of the supported Text Analytics

AnalyzeBatchActionsOperation operation = client.StartAnalyzeBatchActions(batchDocuments, batchActions);

await operation.WaitForCompletionAsync();
TimeSpan pollingInterval = new TimeSpan(1000);

while (!operation.HasCompleted)
{
Thread.Sleep(pollingInterval);
operation.UpdateStatus();
}

foreach (AnalyzeBatchActionsResult documentsInPage in operation.GetValues())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ To run analyze operation in multiple documents, call `StartAnalyzeOperationBatch

AnalyzeBatchActionsOperation operation = client.StartAnalyzeBatchActions(batchDocuments, batchActions);

await operation.WaitForCompletionAsync();
TimeSpan pollingInterval = new TimeSpan(1000);

while (!operation.HasCompleted)
{
Thread.Sleep(pollingInterval);
operation.UpdateStatus();
}

foreach (AnalyzeBatchActionsResult documentsInPage in operation.GetValues())
{
Expand Down

0 comments on commit ca6a1ad

Please sign in to comment.