次の方法で共有


TextAnalysisClient class

Azure Cognitive Language Service のテキスト分析機能を操作するためのクライアント。

クライアントには、言語リソースのエンドポイントと、API キーや AAD などの認証方法が必要です。 API キーとエンドポイントは、Azure portal の [言語リソース] ページにあります。 リソースの [キーとエンドポイント] ページの [リソース管理] に表示されます。

認証の例:

API キー

import { TextAnalysisClient, AzureKeyCredential } from "@azure/ai-language-text";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new AzureKeyCredential("<api key>");

const client = new TextAnalysisClient(endpoint, credential);

Azure Active Directory

Azure Active Directory での認証の詳細については、@azure/identity パッケージを参照してください。

import { TextAnalysisClient } from "@azure/ai-language-text";
import { DefaultAzureCredential } from "@azure/identity";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new DefaultAzureCredential();

const client = new TextAnalysisClient(endpoint, credential);

コンストラクター

TextAnalysisClient(string, KeyCredential, TextAnalysisClientOptions)

言語リソースのエンドポイントと、API キーや AAD などの認証方法を使用して TextAnalysisClient のインスタンスを作成します。

API キーとエンドポイントは、Azure portal の [言語リソース] ページにあります。 リソースの [キーとエンドポイント] ページの [リソース管理] に表示されます。

import { TextAnalysisClient, AzureKeyCredential } from "@azure/ai-language-text";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new AzureKeyCredential("<api key>");

const client = new TextAnalysisClient(endpoint, credential);
TextAnalysisClient(string, TokenCredential, TextAnalysisClientOptions)

言語リソースのエンドポイントと、API キーや AAD などの認証方法を使用して TextAnalysisClient のインスタンスを作成します。

API キーとエンドポイントは、Azure portal の [言語リソース] ページにあります。 リソースの [キーとエンドポイント] ページの [リソース管理] に表示されます。

Azure Active Directory での認証の詳細については、@azure/identity パッケージを参照してください。

import { TextAnalysisClient } from "@azure/ai-language-text";
import { DefaultAzureCredential } from "@azure/identity";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new DefaultAzureCredential();

const client = new TextAnalysisClient(endpoint, credential);

メソッド

analyze<ActionName>(ActionName, LanguageDetectionInput[], AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions)

予測モデルを実行して、渡された入力文字列が書き込まれる言語を特定し、検出された言語ごとに検出された言語と、推論された言語が正しいというモデルの信頼度を示すスコアを返します。 1 に近いスコアは、結果の高い確実性を示します。 120 の言語がサポートされています。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

言語検出

const documents = [<input strings>];
const countryHint = "us";
const results = await client.analyze("LanguageDetection", documents, countryHint);

for (let i = 0; i < results.length; i++) {
  const result = results[i];
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { name, confidenceScore, iso6391Name } = result.primaryLanguage;
  }
}

言語検出の詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/language-detection/overview を参照してください。

analyze<ActionName>(ActionName, string[], string, AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions)

予測モデルを実行して、渡された入力文字列が書き込まれる言語を特定し、検出された言語ごとに検出された言語と、推論された言語が正しいというモデルの信頼度を示すスコアを返します。 1 に近いスコアは、結果の高い確実性を示します。 120 の言語がサポートされています。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

言語検出

const documents = [<input strings>];
const countryHint = "us";
const results = await client.analyze("LanguageDetection", documents, countryHint);

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { name, confidenceScore, iso6391Name } = result.primaryLanguage;
  }
}

言語検出の詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/language-detection/overview を参照してください。

analyze<ActionName>(ActionName, string[], string, AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions)

予測モデルを実行して、入力文字列に対して選択したアクションを実行します。 サポートされているアクションの一覧については、「$AnalyzeActionName」を参照してください。

結果配列内の各項目のレイアウトは、選択したアクションによって異なります。 たとえば、各 PIIEntityRecognition ドキュメントの結果は、entitiesredactedText の両方で構成されます。前者はテキスト内のすべての Pii エンティティのリストであり、後者は、そのような Pii エンティティがすべて編集された後の元のテキストです。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

オピニオン マイニング

const documents = ["The food and service aren't the best"];
const results = await client.analyze("SentimentAnalysis", documents, {
  includeOpinionMining: true,
});

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { sentiment, confidenceScores, sentences } = result;
    for (const { sentiment, confidenceScores, opinions } of sentences) {
      for (const { target, assessments } of opinions) {
        const { text, sentiment, confidenceScores } = target;
        for (const { text, sentiment } of assessments) {
          // Do something
        }
      }
    }
  }
}

オピニオン マイニングの詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview を参照してください。

個人を特定できる情報

const documents = [<input strings>];
const languageCode = "en";
const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];
const domainFilter = KnownPiiDomain.Phi;
const results = await client.analyze("PiiEntityRecognition", documents, languageCode, {
  domainFilter, categoriesFilter
});

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { entities, redactedText } = result;
    for (const { text, category, confidenceScore, length, offset } of entities) {
      // Do something
    }
  }
}

個人を特定できる情報の詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/personally-identifiable-information/overview を参照してください。

analyze<ActionName>(ActionName, TextDocumentInput[], AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions)

予測モデルを実行して、入力ドキュメントに対して選択したアクションを実行します。 サポートされているアクションの一覧については、「$AnalyzeActionName」を参照してください。

結果配列内の各項目のレイアウトは、選択したアクションによって異なります。 たとえば、各 PIIEntityRecognition ドキュメントの結果は、entitiesredactedText の両方で構成されます。前者はテキスト内のすべての Pii エンティティのリストであり、後者は、そのような Pii エンティティがすべて編集された後の元のテキストです。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

オピニオン マイニング

const documents = [{
 id: "1",
 text: "The food and service aren't the best",
 language: "en"
}];
const results = await client.analyze("SentimentAnalysis", documents, {
  includeOpinionMining: true,
});

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { sentiment, confidenceScores, sentences } = result;
    for (const { sentiment, confidenceScores, opinions } of sentences) {
      for (const { target, assessments } of opinions) {
        const { text, sentiment, confidenceScores } = target;
        for (const { text, sentiment } of assessments) {
          // Do something
        }
      }
    }
  }
}

オピニオン マイニングの詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview を参照してください。

個人を特定できる情報

const documents = [<input documents>];
const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];
const domainFilter = KnownPiiDomain.Phi;
const results = await client.analyze("PiiEntityRecognition", documents, {
  domainFilter, categoriesFilter
});

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { entities, redactedText } = result;
    for (const { text, category, confidenceScore, length, offset } of entities) {
      // Do something
    }
  }
}

個人を特定できる情報の詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/personally-identifiable-information/overview を参照してください。

beginAnalyzeBatch(AnalyzeBatchAction[], string[], string, BeginAnalyzeBatchOptions)

入力ドキュメントに対してアクションの配列 (バッチ) を実行します。 各アクションには、アクションの性質を指定する kind フィールドがあります。 サポートされているアクションの一覧については、「$AnalyzeBatchActionNames」を参照してください。 kindに加えて、アクションには、disableServiceLogsmodelVersionなどの他のパラメーターを含めることもできます。

結果配列には、各項目に結果の種類を指定する kind フィールドも含まれる入力アクションの結果が含まれています。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

キー フレーズ抽出と Pii エンティティ認識

const poller = await client.beginAnalyzeBatch(
 [{ kind: "KeyPhraseExtraction" }, { kind: "PiiEntityRecognition" }],
 documents
);
const actionResults = await poller.pollUntilDone();

for await (const actionResult of actionResults) {
 if (actionResult.error) {
   throw new Error(`Unexpected error`);
 }
 switch (actionResult.kind) {
   case "KeyPhraseExtraction": {
     for (const doc of actionResult.results) {
       // do something
     }
     break;
   }
   case "PiiEntityRecognition": {
     for (const doc of actionResult.results) {
       // do something
     }
     break;
   }
 }
}
beginAnalyzeBatch(AnalyzeBatchAction[], TextDocumentInput[], BeginAnalyzeBatchOptions)

入力ドキュメントに対してアクションの配列 (バッチ) を実行します。 各アクションには、アクションの性質を指定する kind フィールドがあります。 サポートされているアクションの一覧については、「$AnalyzeBatchActionNames」を参照してください。 kindに加えて、アクションには、disableServiceLogsmodelVersionなどの他のパラメーターを含めることもできます。

結果配列には、各項目に結果の種類を指定する kind フィールドも含まれる入力アクションの結果が含まれています。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

キーフレーズ抽出と Pii エンティティ認識

const poller = await client.beginAnalyzeBatch(
 [{ kind: "KeyPhraseExtraction" }, { kind: "PiiEntityRecognition" }],
 documents
);
const actionResults = await poller.pollUntilDone();

for await (const actionResult of actionResults) {
 if (actionResult.error) {
   throw new Error(`Unexpected error`);
 }
 switch (actionResult.kind) {
   case "KeyPhraseExtraction": {
     for (const doc of actionResult.results) {
       // do something
     }
     break;
   }
   case "PiiEntityRecognition": {
     for (const doc of actionResult.results) {
       // do something
     }
     break;
   }
 }
}
restoreAnalyzeBatchPoller(string, RestoreAnalyzeBatchPollerOptions)

別のポーラーのシリアル化された状態からポーリングャーを作成します。 これは、別のホストに投票者を作成する場合や、元のホストがスコープ内にない後にポーリングャーを構築する必要がある場合に便利です。

コンストラクターの詳細

TextAnalysisClient(string, KeyCredential, TextAnalysisClientOptions)

言語リソースのエンドポイントと、API キーや AAD などの認証方法を使用して TextAnalysisClient のインスタンスを作成します。

API キーとエンドポイントは、Azure portal の [言語リソース] ページにあります。 リソースの [キーとエンドポイント] ページの [リソース管理] に表示されます。

import { TextAnalysisClient, AzureKeyCredential } from "@azure/ai-language-text";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new AzureKeyCredential("<api key>");

const client = new TextAnalysisClient(endpoint, credential);
new TextAnalysisClient(endpointUrl: string, credential: KeyCredential, options?: TextAnalysisClientOptions)

パラメーター

endpointUrl

string

Cognitive Language Service リソースのエンドポイントへの URL

credential
KeyCredential

サービスへの要求を認証するために使用されるキー資格情報。

options
TextAnalysisClientOptions

TextAnalytics クライアントの構成に使用されます。

TextAnalysisClient(string, TokenCredential, TextAnalysisClientOptions)

言語リソースのエンドポイントと、API キーや AAD などの認証方法を使用して TextAnalysisClient のインスタンスを作成します。

API キーとエンドポイントは、Azure portal の [言語リソース] ページにあります。 リソースの [キーとエンドポイント] ページの [リソース管理] に表示されます。

Azure Active Directory での認証の詳細については、@azure/identity パッケージを参照してください。

import { TextAnalysisClient } from "@azure/ai-language-text";
import { DefaultAzureCredential } from "@azure/identity";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new DefaultAzureCredential();

const client = new TextAnalysisClient(endpoint, credential);
new TextAnalysisClient(endpointUrl: string, credential: TokenCredential, options?: TextAnalysisClientOptions)

パラメーター

endpointUrl

string

Cognitive Language Service リソースのエンドポイントへの URL

credential
TokenCredential

サービスへの要求を認証するために使用されるトークン資格情報。

options
TextAnalysisClientOptions

TextAnalytics クライアントの構成に使用されます。

メソッドの詳細

analyze<ActionName>(ActionName, LanguageDetectionInput[], AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions)

予測モデルを実行して、渡された入力文字列が書き込まれる言語を特定し、検出された言語ごとに検出された言語と、推論された言語が正しいというモデルの信頼度を示すスコアを返します。 1 に近いスコアは、結果の高い確実性を示します。 120 の言語がサポートされています。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

言語検出

const documents = [<input strings>];
const countryHint = "us";
const results = await client.analyze("LanguageDetection", documents, countryHint);

for (let i = 0; i < results.length; i++) {
  const result = results[i];
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { name, confidenceScore, iso6391Name } = result.primaryLanguage;
  }
}

言語検出の詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/language-detection/overview を参照してください。

function analyze<ActionName>(actionName: ActionName, documents: LanguageDetectionInput[], options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions): Promise<AnalyzeResult<ActionName>>

パラメーター

actionName

ActionName

入力ドキュメントに対して実行するアクションの名前については、$AnalyzeActionName を参照してください。

documents

LanguageDetectionInput[]

分析する入力ドキュメント

options

AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions

操作のオプションのアクション パラメーターと設定

戻り値

Promise<AnalyzeResult<ActionName>>

各要素が対応する入力ドキュメントのプライマリ言語を含む結果の配列。

analyze<ActionName>(ActionName, string[], string, AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions)

予測モデルを実行して、渡された入力文字列が書き込まれる言語を特定し、検出された言語ごとに検出された言語と、推論された言語が正しいというモデルの信頼度を示すスコアを返します。 1 に近いスコアは、結果の高い確実性を示します。 120 の言語がサポートされています。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

言語検出

const documents = [<input strings>];
const countryHint = "us";
const results = await client.analyze("LanguageDetection", documents, countryHint);

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { name, confidenceScore, iso6391Name } = result.primaryLanguage;
  }
}

言語検出の詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/language-detection/overview を参照してください。

function analyze<ActionName>(actionName: ActionName, documents: string[], countryHint?: string, options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions): Promise<AnalyzeResult<ActionName>>

パラメーター

actionName

ActionName

入力ドキュメントに対して実行するアクションの名前については、$AnalyzeActionName を参照してください。

documents

string[]

分析する入力ドキュメント

countryHint

string

モデルが記述されている言語を予測するのに役立つ、すべての入力文字列の原産国を示します。 指定しない場合、この値は TextAnalysisClientOptionsの既定の国ヒントに設定されます。 空の文字列または文字列 "none" に設定されている場合、サービスは国が明示的に設定されていないモデルを適用します。 入力コレクション内のすべての文字列に同じ国ヒントが適用されます。

options

AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions

操作のオプションのアクション パラメーターと設定

戻り値

Promise<AnalyzeResult<ActionName>>

各要素が対応する入力ドキュメントのプライマリ言語を含む結果の配列。

analyze<ActionName>(ActionName, string[], string, AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions)

予測モデルを実行して、入力文字列に対して選択したアクションを実行します。 サポートされているアクションの一覧については、「$AnalyzeActionName」を参照してください。

結果配列内の各項目のレイアウトは、選択したアクションによって異なります。 たとえば、各 PIIEntityRecognition ドキュメントの結果は、entitiesredactedText の両方で構成されます。前者はテキスト内のすべての Pii エンティティのリストであり、後者は、そのような Pii エンティティがすべて編集された後の元のテキストです。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

オピニオン マイニング

const documents = ["The food and service aren't the best"];
const results = await client.analyze("SentimentAnalysis", documents, {
  includeOpinionMining: true,
});

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { sentiment, confidenceScores, sentences } = result;
    for (const { sentiment, confidenceScores, opinions } of sentences) {
      for (const { target, assessments } of opinions) {
        const { text, sentiment, confidenceScores } = target;
        for (const { text, sentiment } of assessments) {
          // Do something
        }
      }
    }
  }
}

オピニオン マイニングの詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview を参照してください。

個人を特定できる情報

const documents = [<input strings>];
const languageCode = "en";
const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];
const domainFilter = KnownPiiDomain.Phi;
const results = await client.analyze("PiiEntityRecognition", documents, languageCode, {
  domainFilter, categoriesFilter
});

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { entities, redactedText } = result;
    for (const { text, category, confidenceScore, length, offset } of entities) {
      // Do something
    }
  }
}

個人を特定できる情報の詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/personally-identifiable-information/overview を参照してください。

function analyze<ActionName>(actionName: ActionName, documents: string[], languageCode?: string, options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions): Promise<AnalyzeResult<ActionName>>

パラメーター

actionName

ActionName

入力ドキュメントに対して実行するアクションの名前については、$AnalyzeActionName を参照してください。

documents

string[]

分析する入力ドキュメント

languageCode

string

すべての入力文字列が書き込まれる言語のコード。 指定しない場合、この値は TextAnalysisClientOptionsの既定の言語に設定されます。 空の文字列に設定すると、サービスは、言語が明示的に "None" に設定されているモデルを適用します。 言語のサポートはアクションによって異なります。たとえば、エンティティ認識アクションでサポートされる言語の詳細については、「https://docs.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support」を参照してください。 "auto" に設定すると、サービスは入力テキストから言語を自動的に推論します。

options

AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions

操作のオプションのアクション パラメーターと設定

戻り値

Promise<AnalyzeResult<ActionName>>

入力ドキュメントに対応する結果の配列

analyze<ActionName>(ActionName, TextDocumentInput[], AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions)

予測モデルを実行して、入力ドキュメントに対して選択したアクションを実行します。 サポートされているアクションの一覧については、「$AnalyzeActionName」を参照してください。

結果配列内の各項目のレイアウトは、選択したアクションによって異なります。 たとえば、各 PIIEntityRecognition ドキュメントの結果は、entitiesredactedText の両方で構成されます。前者はテキスト内のすべての Pii エンティティのリストであり、後者は、そのような Pii エンティティがすべて編集された後の元のテキストです。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

オピニオン マイニング

const documents = [{
 id: "1",
 text: "The food and service aren't the best",
 language: "en"
}];
const results = await client.analyze("SentimentAnalysis", documents, {
  includeOpinionMining: true,
});

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { sentiment, confidenceScores, sentences } = result;
    for (const { sentiment, confidenceScores, opinions } of sentences) {
      for (const { target, assessments } of opinions) {
        const { text, sentiment, confidenceScores } = target;
        for (const { text, sentiment } of assessments) {
          // Do something
        }
      }
    }
  }
}

オピニオン マイニングの詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview を参照してください。

個人を特定できる情報

const documents = [<input documents>];
const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];
const domainFilter = KnownPiiDomain.Phi;
const results = await client.analyze("PiiEntityRecognition", documents, {
  domainFilter, categoriesFilter
});

for (const result of results) {
  if (result.error) {
    // a document has an error instead of results
  } else {
    const { entities, redactedText } = result;
    for (const { text, category, confidenceScore, length, offset } of entities) {
      // Do something
    }
  }
}

個人を特定できる情報の詳細については、https://docs.microsoft.com//azure/cognitive-services/language-service/personally-identifiable-information/overview を参照してください。

function analyze<ActionName>(actionName: ActionName, documents: TextDocumentInput[], options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions): Promise<AnalyzeResult<ActionName>>

パラメーター

actionName

ActionName

入力ドキュメントに対して実行するアクションの名前については、$AnalyzeActionName を参照してください。

documents

TextDocumentInput[]

分析する入力ドキュメント

options

AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions

操作のオプションのアクション パラメーターと設定

戻り値

Promise<AnalyzeResult<ActionName>>

入力ドキュメントに対応する結果の配列

beginAnalyzeBatch(AnalyzeBatchAction[], string[], string, BeginAnalyzeBatchOptions)

入力ドキュメントに対してアクションの配列 (バッチ) を実行します。 各アクションには、アクションの性質を指定する kind フィールドがあります。 サポートされているアクションの一覧については、「$AnalyzeBatchActionNames」を参照してください。 kindに加えて、アクションには、disableServiceLogsmodelVersionなどの他のパラメーターを含めることもできます。

結果配列には、各項目に結果の種類を指定する kind フィールドも含まれる入力アクションの結果が含まれています。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

キー フレーズ抽出と Pii エンティティ認識

const poller = await client.beginAnalyzeBatch(
 [{ kind: "KeyPhraseExtraction" }, { kind: "PiiEntityRecognition" }],
 documents
);
const actionResults = await poller.pollUntilDone();

for await (const actionResult of actionResults) {
 if (actionResult.error) {
   throw new Error(`Unexpected error`);
 }
 switch (actionResult.kind) {
   case "KeyPhraseExtraction": {
     for (const doc of actionResult.results) {
       // do something
     }
     break;
   }
   case "PiiEntityRecognition": {
     for (const doc of actionResult.results) {
       // do something
     }
     break;
   }
 }
}
function beginAnalyzeBatch(actions: AnalyzeBatchAction[], documents: string[], languageCode?: string, options?: BeginAnalyzeBatchOptions): Promise<AnalyzeBatchPoller>

パラメーター

actions

AnalyzeBatchAction[]

入力ドキュメントで実行されるアクションの配列

documents

string[]

分析する入力ドキュメント

languageCode

string

すべての入力文字列が書き込まれる言語のコード。 指定しない場合、この値は TextAnalysisClientOptionsの既定の言語に設定されます。 空の文字列に設定すると、サービスは、言語が明示的に "None" に設定されているモデルを適用します。 言語のサポートはアクションによって異なります。たとえば、エンティティ認識アクションでサポートされる言語の詳細については、「https://docs.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support」を参照してください。 "auto" に設定すると、サービスは入力テキストから言語を自動的に推論します。

options
BeginAnalyzeBatchOptions

操作の省略可能な設定

戻り値

入力アクションに対応する結果の配列

beginAnalyzeBatch(AnalyzeBatchAction[], TextDocumentInput[], BeginAnalyzeBatchOptions)

入力ドキュメントに対してアクションの配列 (バッチ) を実行します。 各アクションには、アクションの性質を指定する kind フィールドがあります。 サポートされているアクションの一覧については、「$AnalyzeBatchActionNames」を参照してください。 kindに加えて、アクションには、disableServiceLogsmodelVersionなどの他のパラメーターを含めることもできます。

結果配列には、各項目に結果の種類を指定する kind フィールドも含まれる入力アクションの結果が含まれています。

データ制限については、https://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits を参照してください。

キーフレーズ抽出と Pii エンティティ認識

const poller = await client.beginAnalyzeBatch(
 [{ kind: "KeyPhraseExtraction" }, { kind: "PiiEntityRecognition" }],
 documents
);
const actionResults = await poller.pollUntilDone();

for await (const actionResult of actionResults) {
 if (actionResult.error) {
   throw new Error(`Unexpected error`);
 }
 switch (actionResult.kind) {
   case "KeyPhraseExtraction": {
     for (const doc of actionResult.results) {
       // do something
     }
     break;
   }
   case "PiiEntityRecognition": {
     for (const doc of actionResult.results) {
       // do something
     }
     break;
   }
 }
}
function beginAnalyzeBatch(actions: AnalyzeBatchAction[], documents: TextDocumentInput[], options?: BeginAnalyzeBatchOptions): Promise<AnalyzeBatchPoller>

パラメーター

actions

AnalyzeBatchAction[]

入力ドキュメントで実行されるアクションの配列

documents

TextDocumentInput[]

分析する入力ドキュメント

options
BeginAnalyzeBatchOptions

操作の省略可能な設定

戻り値

入力アクションに対応する結果の配列

restoreAnalyzeBatchPoller(string, RestoreAnalyzeBatchPollerOptions)

別のポーラーのシリアル化された状態からポーリングャーを作成します。 これは、別のホストに投票者を作成する場合や、元のホストがスコープ内にない後にポーリングャーを構築する必要がある場合に便利です。

function restoreAnalyzeBatchPoller(serializedState: string, options?: RestoreAnalyzeBatchPollerOptions): Promise<AnalyzeBatchPoller>

パラメーター

serializedState

string

別のポーラーのシリアル化された状態。 これは、poller.toString() の結果です

options
RestoreAnalyzeBatchPollerOptions

操作の省略可能な設定

client.beginAnalyzeBatch は、投票者に解決される約束を返します。 ポーリングャーの状態をシリアル化し、次のように別の状態を作成するために使用できます。

const serializedState = poller.toString();
const rehydratedPoller = await client.createAnalyzeBatchPoller(serializedState);
const actionResults = await rehydratedPoller.pollUntilDone();

戻り値