Skip to content

Commit

Permalink
[Language Text] Merge feature branch for v1.1-beta.1 work into main (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
deyaaeldeen authored and mpodwysocki committed Nov 2, 2022
1 parent 30b66fd commit 2dfb4cc
Show file tree
Hide file tree
Showing 496 changed files with 74,519 additions and 38,528 deletions.
11 changes: 10 additions & 1 deletion sdk/cognitivelanguage/ai-language-text/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Release History

## 1.0.1 (Unreleased)
## 1.1.0-beta.1 (Unreleased)

### Features Added

- Supports service version 2022-10-01-preview by default instead of 2022-05-01.
- Adds support for extractive summarization and FHIR.
- Adds support for abstractive summarization.
- Adds support for dynamic classification.
- Adds support for script detection and automatic language detection.
- Adds support for document types in healthcare analysis.
- Adds support for entity resolution in entity recognition.
- Adds support for confidence scores in healthcare relations.

### Breaking Changes

### Bugs Fixed
Expand Down
149 changes: 132 additions & 17 deletions sdk/cognitivelanguage/ai-language-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Azure Cognitive Service for Language](https://azure.microsoft.com/services/cognitive-services/language-service/) is a cloud-based service that provides advanced natural language processing over raw text, and includes the following main features:

**Note:** This SDK targets Azure Cognitive Service for Language API version 2022-05-01.
**Note:** This SDK targets Azure Cognitive Service for Language API version 2022-10-01-preview.

- Language Detection
- Sentiment Analysis
Expand All @@ -11,8 +11,11 @@
- Recognition of Personally Identifiable Information
- Entity Linking
- Healthcare Analysis
- Extractive Summarization
- Abstractive Summarization
- Custom Entity Recognition
- Custom Document Classification
- Dynamic Classification
- Support Multiple Actions Per Document

Use the client library to:
Expand Down Expand Up @@ -389,15 +392,48 @@ async function main() {
main();
```

### Dynamic Classification

On the fly classification of the input documents into one or multiple categories. Assigns either one or multiple categories per document. This type of classification doesn't require model training.

```javascript
const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");

const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));

const documents = [
"The WHO is issuing a warning about Monkey Pox.",
"Mo Salah plays in Liverpool FC in England.",
];

export async function main() {
const results = await client.analyze("DynamicClassification", documents, "en", {
categories: ["Health", "Politics", "Music", "Sports"],
classificationType: "Multi",
});

for (const result of results) {
console.log(`- Document ${result.id}`);
if (!result.error) {
console.log("\tClassifications:");
for (const category of result.classifications) {
console.log(`\t- ${category.category}`);
}
} else {
console.error(" Error:", result.error);
}
}
}

main();
```

### Healthcare Analysis

Healthcare analysis identifies healthcare entities. For example, given input text "Prescribed 100mg ibuprofen, taken twice daily", the service returns "100mg" categorized as Dosage, "ibuprofen" as MedicationName, and "twice daily" as Frequency.

```javascript
const {
AzureKeyCredential,
TextAnalysisClient,
} = require("@azure/ai-language-text");
const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");

const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));

Expand All @@ -414,6 +450,7 @@ async function main() {
];
const poller = await client.beginAnalyzeBatch(actions, documents, "en");
const results = await poller.pollUntilDone();

for await (const actionResult of results) {
if (actionResult.kind !== "Healthcare") {
throw new Error(`Expected a healthcare results but got: ${actionResult.kind}`);
Expand Down Expand Up @@ -445,15 +482,98 @@ async function main() {
main();
```

### Extractive Summarization

Extractive summarization identifies sentences that summarize the article they belong to.

```javascript
const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");
const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
const documents = [
"<long article>"
];
async function main() {
const actions = [
{
kind: "ExtractiveSummarization",
maxSentenceCount: 2,
},
];
const poller = await client.beginAnalyzeBatch(actions, documents, "en");
const results = await poller.pollUntilDone();

for await (const actionResult of results) {
if (actionResult.kind !== "ExtractiveSummarization") {
throw new Error(`Expected extractive summarization results but got: ${actionResult.kind}`);
}
if (actionResult.error) {
const { code, message } = actionResult.error;
throw new Error(`Unexpected error (${code}): ${message}`);
}
for (const result of actionResult.results) {
console.log(`- Document ${result.id}`);
if (result.error) {
const { code, message } = result.error;
throw new Error(`Unexpected error (${code}): ${message}`);
}
console.log("Summary:");
console.log(result.sentences.map((sentence) => sentence.text).join("\n"));
}
}
}
main();
```

### Abstractive Summarization

Abstractive summarization generates a summary for the input articles. Abstractive summarization is different from extractive summarization in that extractive summarization is the strategy of concatenating extracted sentences from the input document into a summary, while abstractive summarization involves paraphrasing the document using novel sentences.

```javascript
const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");
const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
const documents = [
"<long article>"
];
async function main() {
const actions = [
{
kind: "AbstractiveSummarization",
maxSentenceCount: 2,
},
];
const poller = await client.beginAnalyzeBatch(actions, documents, "en");
const results = await poller.pollUntilDone();

for await (const actionResult of results) {
if (actionResult.kind !== "AbstractiveSummarization") {
throw new Error(`Expected abstractive summarization results but got: ${actionResult.kind}`);
}
if (actionResult.error) {
const { code, message } = actionResult.error;
throw new Error(`Unexpected error (${code}): ${message}`);
}
for (const result of actionResult.results) {
console.log(`- Document ${result.id}`);
if (result.error) {
const { code, message } = result.error;
throw new Error(`Unexpected error (${code}): ${message}`);
}
console.log("\t- Summary:");
for (const summary of result.summaries) {
console.log(summary.text);
}
}
}
}
main();
```

### Custom Entity Recognition

Recognize and categorize entities in text as entities using custom entity detection models built using [Azure Language Studio][lang_studio].

```javascript
const {
AzureKeyCredential,
TextAnalysisClient,
} = require("@azure/ai-language-text");
const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");

const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));

Expand Down Expand Up @@ -551,10 +671,7 @@ main();
Classify documents using custom multi-label models built using [Azure Language Studio][lang_studio].

```javascript
const {
AzureKeyCredential,
TextAnalysisClient,
} = require("@azure/ai-language-text");
const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");

const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));

Expand Down Expand Up @@ -605,10 +722,7 @@ main();
Applies multiple actions on each input document in one service request.

```javascript
const {
AzureKeyCredential,
TextAnalysisClient,
} = require("@azure/ai-language-text");
const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");

const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));

Expand Down Expand Up @@ -636,6 +750,7 @@ async function main() {
];
const poller = await client.beginAnalyzeBatch(actions, documents, "en");
const actionResults = await poller.pollUntilDone();

for await (const actionResult of actionResults) {
if (actionResult.error) {
const { code, message } = actionResult.error;
Expand Down
2 changes: 1 addition & 1 deletion sdk/cognitivelanguage/ai-language-text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sdk-type": "client",
"author": "Microsoft Corporation",
"description": "An isomorphic client library for the text analysis features in the Azure Cognitive Language Service.",
"version": "1.0.1",
"version": "1.1.0-beta.1",
"keywords": [
"node",
"azure",
Expand Down
Loading

0 comments on commit 2dfb4cc

Please sign in to comment.