Skip to content

Commit

Permalink
readme updates (#7019)
Browse files Browse the repository at this point in the history
* readme uodates

* update correct link for API doc

* key concept

* update sample links

* sample fixes
  • Loading branch information
mssfang authored Dec 28, 2019
1 parent 8b5531c commit 1fef465
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 21 deletions.
48 changes: 42 additions & 6 deletions sdk/textanalytics/azure-ai-textanalytics/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Azure Text Analytics client library for Java
Text Analytics is a cloud-based service that provides advanced natural language processing over raw text,
and includes four main functions:
and includes six main functions:

- Sentiment Analysis
- Named Entity Recognition
- Language Detection
- Sentiment Analysis
- Key Phrase Extraction
- Named Entity Recognition
- Recognition of Personally Identifiable Information
- Linked Entity Recognition

[Source code][source_code] | [API reference documentation][api_reference_doc] | [Product Documentation][product_documentation] | [Samples][samples_readme]

## Getting started

Expand Down Expand Up @@ -177,6 +181,28 @@ TextAnalyticsClient client = new TextAnalyticsClientBuilder()

## Key concepts

### Text Input
A text input, sometimes called a `document`, is a single unit of input to be analyzed by the predictive models
in the Text Analytics service. Operations on Text Analytics client may take a single text input or a collection
of inputs to be analyzed as a batch.

### Operation Result
An operation result, such as `AnalyzeSentimentResult`, is the result of a Text Analytics operation, containing a
prediction or predictions about a single text input. An operation's result type also may optionally include information
about the input document and how it was processed.
### Operation Result Collection
An operation result collection, such as `DocumentResultCollection<AnalyzeSentimentResult>`, which is the collection of
the result of a Text Analytics analyzing sentiment operation. `DocumentResultCollection` includes the model version of
the operation and statistics of the batch documents. Since `DocumentResultCollection<T>` extends `IterableStream<T>`,
the list of item can be retrieved by streaming or iterating the list.
### Operation Overloads
For each supported operation, the Text Analytics client provides method overloads to take a single text input, a batch
of text inputs as strings, or a batch of either `TextDocumentInput` or `DetectLanguageInput` objects. The overload
taking the `TextDocumentInput` or `DetectLanguageInput` batch allows callers to give each document a unique ID, or
indicate that the documents in the batch are written in different languages.
The following are types of text analysis that the service offers:
1. [Sentiment Analysis](https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-sentiment-analysis)
Expand Down Expand Up @@ -210,24 +236,31 @@ The following are types of text analysis that the service offers:
See [Language and regional support](https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support) for what is currently available for each operation.
## Examples
The following sections provide several code snippets covering some of the most common text analytics tasks, including:
### Text Analytics Client
Text analytics support both synchronous and asynchronous client creation by using
`TextAnalyticsClientBuilder`,
``` java
// An example of creating a synchronous client
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("subscription-key")
.endpoint("https://servicename.cognitiveservices.azure.com/")
.buildClient();
```
``` java
// An example of creating an asynchronous client
TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("subscription-key")
.endpoint("https://servicename.cognitiveservices.azure.com/")
.buildAsyncClient();
```
## Examples
The following sections provide several code snippets covering some of the most common text analytics tasks, including:

### Detect language
Detect language in a batch of documents.
Expand All @@ -248,6 +281,7 @@ for(DetectedLanguage detectedLanguage : client.detectLanguage(text, "US").getDet
```
### Recognize entity
```java
TextAnalyticsClient client = new TextAnalyticsClientBuilder()
.subscriptionKey("subscription-key")
Expand Down Expand Up @@ -338,10 +372,12 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
<!-- LINKS -->
[azure_subscription]: https://azure.microsoft.com/free
[api_reference_doc]: https://azure.github.io/azure-sdk-for-java/cognitiveservices.html
[cla]: https://cla.microsoft.com
[coc]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
[coc_contact]: mailto:[email protected]
[product_documentation]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview
[samples_readme]: src/samples/README.md
[source_code]: src
Expand Down
24 changes: 12 additions & 12 deletions sdk/textanalytics/azure-ai-textanalytics/src/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ Guidelines](../../CONTRIBUTING.md) for more information.
[SDK_README_DEPENDENCY]: ../../README.md#adding-the-package-to-your-product
[SDK_README_NEXT_STEPS]: ../../README.md#next-steps

[sample_hello_world]: java/com/azure/cs/textanalytics/HelloWorld.java
[sample_entities]: java/com/azure/cs/textanalytics/RecognizeEntities.java
[sample_pii_entities]: java/com/azure/cs/textanalytics/RecognizePII.java
[sample_linked_entities]: java/com/azure/cs/textanalytics/RecognizeLinkedEntities.java
[sample_key_phrases]: java/com/azure/cs/textanalytics/RecognizeKeyPhrases.java
[sample_sentiment]: java/com/azure/cs/textanalytics/DetectSentiment.java
[sample_hello_world]: java/com/azure/ai/textanalytics/HelloWorld.java
[sample_entities]: java/com/azure/ai/textanalytics/RecognizeEntities.java
[sample_pii_entities]: java/com/azure/ai/textanalytics/RecognizePii.java
[sample_linked_entities]: java/com/azure/ai/textanalytics/RecognizeLinkedEntities.java
[sample_key_phrases]: java/com/azure/ai/textanalytics/ExtractKeyPhrases.java
[sample_sentiment]: java/com/azure/ai/textanalytics/AnalyzeSentiment.java

[sample_language_batch]: java/com/azure/cs/textanalytics/batch/DetectLanguageBatchDocuments.java
[sample_entities_batch]: java/com/azure/cs/textanalytics/batch/RecognizeEntitiesBatchDocuments.java
[sample_pii_entities_batch]: java/com/azure/cs/textanalytics/batch/RecognizePiiBatchDocuments.java
[sample_linked_entities_batch]: java/com/azure/cs/textanalytics/batch/RecognizeLinkedEntitiesBatchDocuments.java
[sample_key_phrases_batch]: java/com/azure/cs/textanalytics/batch/RecognizeKeyPhrasesBatchDocuments.java
[sample_sentiment_batch]: java/com/azure/cs/textanalytics/batch/DetectSentimentBatchDocuments.java
[sample_language_batch]: java/com/azure/ai/textanalytics/batch/DetectLanguageBatchDocuments.java
[sample_entities_batch]: java/com/azure/ai/textanalytics/batch/RecognizeEntitiesBatchDocuments.java
[sample_pii_entities_batch]: java/com/azure/ai/textanalytics/batch/RecognizePiiBatchDocuments.java
[sample_linked_entities_batch]: java/com/azure/ai/textanalytics/batch/RecognizeLinkedEntitiesBatchDocuments.java
[sample_key_phrases_batch]: java/com/azure/ai/textanalytics/batch/ExtractKeyPhrasesBatchDocuments.java
[sample_sentiment_batch]: java/com/azure/ai/textanalytics/batch/AnalyzeSentimentBatchDocuments.java

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Ftextanalytics%2Fazure-ai-textanalytics%2FREADME.png)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void main(String[] args) {
"Recognized NamedEntity: %s, NamedEntity Type: %s, NamedEntity Subtype: %s, Offset: %s, Length: %s, Score: %s.%n",
entity.getText(),
entity.getType(),
entity.getSubtype(),
entity.getSubtype() == null || entity.getSubtype().isEmpty() ? "N/A" : entity.getSubtype(),
entity.getOffset(),
entity.getLength(),
entity.getScore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public static void main(String[] args) {
System.out.printf(
"Recognized PII Entity: %s, Entity Type: %s, Entity Subtype: %s, Offset: %s, Length: %s, Score: %s.%n",
entity.getText(),
entity.getType(),
entity.getSubtype(),
entity.getType() ,
entity.getSubtype() == null || entity.getSubtype().isEmpty() ? "N/A" : entity.getSubtype(),
entity.getOffset(),
entity.getLength(),
entity.getScore());
}
}
Expand Down

0 comments on commit 1fef465

Please sign in to comment.