次の方法で共有


Question Answering - Get Answers From Text

本文で指定されたテキストを使用して、指定された質問に回答します。

POST {Endpoint}/language/:query-text?api-version=2023-04-01

URI パラメーター

名前 / 必須 説明
Endpoint
path True

string

サポートされている Cognitive Services エンドポイント (例: https://.api.cognitiveservices.azure.com).

api-version
query True

string

クライアント API バージョン。

要求本文

名前 必須 説明
question True

string

指定されたテキスト レコードに対してクエリを実行するユーザーの質問。

records True

TextDocument[]

特定の質問を検索するテキスト レコード。

language

string

テキスト レコードの言語。 これは、言語の BCP-47 表現です。 たとえば、英語の場合は "en" を使用します。スペイン語などの "es"設定されていない場合は、既定で英語に "en" を使用します。

stringIndexType

StringIndexType

文字列オフセットの解釈に使用するメソッドを指定します。 既定では、Unicode v8.0.0 に従って Text 要素 (Graphemes) が使用されます。 詳細については、https://aka.ms/text-analytics-offsets のトピックを参照してください。

応答

名前 説明
200 OK

AnswersFromTextResult

入力テキストから回答を取得するための応答が成功しました。

Other Status Codes

ErrorResponse

エラー応答。

セキュリティ

AADToken

これらは Azure Active Directory OAuth2 フローです。 Azure ロールベースのアクセス制御と組み合わせて使用すると、Azure Maps REST API へのアクセスを制御できます。 Azure ロールベースのアクセス制御は、1 つ以上のAzure Mapsリソース アカウントまたはサブリソースへのアクセスを指定するために使用されます。 REST API をAzure Mapsするための 1 つ以上のアクセス許可で構成される組み込みロールまたはカスタム ロールを使用して、ユーザー、グループ、またはサービス プリンシパルにアクセス権を付与できます。

シナリオを実装するには、 認証の概念を表示することをお勧めします。 要約すると、このセキュリティ定義は、特定の API とスコープに対するアクセス制御が可能なオブジェクトを使用してアプリケーションをモデル化するためのソリューションを提供します。

メモ

  • このセキュリティ定義では、 ヘッダーを使用して、x-ms-client-idアプリケーションがアクセスを要求しているリソースAzure Maps示す必要があります。 これは、 Maps 管理 API から取得できます。

Authorization URL 、Azure パブリック クラウド インスタンスに固有です。 ソブリン クラウドには、一意の承認 URL と Azure Active Directory 構成があります。 * Azure ロールベースのアクセス制御は、Azure portal、PowerShell、CLI、Azure SDK、または REST API を介して Azure 管理プレーンから構成されます。 * Azure Maps Web SDK を使用すると、複数のユース ケースに対してアプリケーションを構成ベースで設定できます。

  • 現在、Azure Active Directory v1.0 または v2.0 では、職場、学校、ゲストはサポートされていますが、個人用アカウントはサポートされていません。

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名前 説明
https://cognitiveservices.azure.com/.default https://cognitiveservices.azure.com/.default

Ocp-Apim-Subscription-Key

言語サービス リソースのサブスクリプション キー。

Type: apiKey
In: header

Successful query

Sample Request

POST {Endpoint}/language/:query-text?api-version=2023-04-01

{
  "question": "how long it takes to charge surface?",
  "records": [
    {
      "id": "1",
      "text": "Power and charging. It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you’re using your Surface for power-intensive activities like gaming or video streaming while you’re charging it."
    },
    {
      "id": "2",
      "text": "You can use the USB port on your Surface Pro 4 power supply to charge other devices, like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB port on your Surface."
    }
  ],
  "language": "en"
}

Sample Response

{
  "answers": [
    {
      "answer": "Power and charging. It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you’re using your Surface for power-intensive activities like gaming or video streaming while you’re charging it.",
      "confidenceScore": 0.93,
      "id": "1",
      "answerSpan": {
        "text": "two to four hours",
        "confidenceScore": 0,
        "offset": 28,
        "length": 45
      },
      "offset": 0,
      "length": 224
    },
    {
      "answer": "It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you’re using your Surface for power-intensive activities like gaming or video streaming while you’re charging it.",
      "confidenceScore": 0.92,
      "id": "1",
      "answerSpan": {
        "text": "two to four hours",
        "confidenceScore": 0,
        "offset": 8,
        "length": 25
      },
      "offset": 20,
      "length": 224
    },
    {
      "answer": "It can take longer if you’re using your Surface for power-intensive activities like gaming or video streaming while you’re charging it.",
      "confidenceScore": 0.05,
      "id": "1",
      "answerSpan": null,
      "offset": 110,
      "length": 244
    }
  ]
}

定義

名前 説明
AnswersFromTextOptions

回答する質問とテキストレコードのパラメーター。

AnswersFromTextResult

回答結果を表します。

AnswerSpan

QnA の応答スパン オブジェクト。

Error

error オブジェクト。

ErrorCode

人間が判読できるエラー コード。

ErrorResponse

エラー応答。

InnerErrorCode

人間が判読できるエラー コード。

InnerErrorModel

エラーに関するより具体的な情報を含むオブジェクト。 Microsoft One API のガイドラインに従って - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

StringIndexType

文字列オフセットの解釈に使用するメソッドを指定します。 既定では、Unicode v8.0.0 に従って Text 要素 (Graphemes) が使用されます。 詳細については、https://aka.ms/text-analytics-offsets のトピックを参照してください。

TextAnswer

回答結果を表します。

TextDocument

クエリを実行する入力テキスト レコードを表します。

AnswersFromTextOptions

回答する質問とテキストレコードのパラメーター。

名前 既定値 説明
language

string

テキスト レコードの言語。 これは、言語の BCP-47 表現です。 たとえば、英語の場合は "en" を使用します。スペイン語などの "es"設定されていない場合は、既定で英語に "en" を使用します。

question

string

指定されたテキスト レコードに対してクエリを実行するユーザーの質問。

records

TextDocument[]

特定の質問を検索するテキスト レコード。

stringIndexType

StringIndexType

TextElements_v8

文字列オフセットの解釈に使用するメソッドを指定します。 既定では、Unicode v8.0.0 に従って Text 要素 (Graphemes) が使用されます。 詳細については、https://aka.ms/text-analytics-offsets のトピックを参照してください。

AnswersFromTextResult

回答結果を表します。

名前 説明
answers

TextAnswer[]

回答結果を表します。

AnswerSpan

QnA の応答スパン オブジェクト。

名前 説明
confidenceScore

number

回答スパンの予測スコア。値の範囲は 0 から 1 です。

length

integer

回答スパンの長さ。

offset

integer

回答範囲は、回答の先頭からオフセットされます。

text

string

回答スパンの予測テキスト。

Error

error オブジェクト。

名前 説明
code

ErrorCode

サーバー定義のエラー コードのセットの 1 つ。

details

Error[]

この報告されたエラーの原因となった特定のエラーに関する詳細の配列。

innererror

InnerErrorModel

エラーに関する現在のオブジェクトよりも具体的な情報を含む オブジェクト。

message

string

エラーの人間が判読できる表現。

target

string

エラーのターゲット。

ErrorCode

人間が判読できるエラー コード。

名前 説明
AzureCognitiveSearchIndexLimitReached

string

AzureCognitiveSearchIndexNotFound

string

AzureCognitiveSearchNotFound

string

AzureCognitiveSearchThrottling

string

Conflict

string

Forbidden

string

InternalServerError

string

InvalidArgument

string

InvalidRequest

string

NotFound

string

OperationNotFound

string

ProjectNotFound

string

QuotaExceeded

string

ServiceUnavailable

string

Timeout

string

TooManyRequests

string

Unauthorized

string

Warning

string

ErrorResponse

エラー応答。

名前 説明
error

Error

error オブジェクト。

InnerErrorCode

人間が判読できるエラー コード。

名前 説明
AzureCognitiveSearchNotFound

string

AzureCognitiveSearchThrottling

string

EmptyRequest

string

ExtractionFailure

string

InvalidCountryHint

string

InvalidDocument

string

InvalidDocumentBatch

string

InvalidParameterValue

string

InvalidRequest

string

InvalidRequestBodyFormat

string

KnowledgeBaseNotFound

string

MissingInputDocuments

string

ModelVersionIncorrect

string

UnsupportedLanguageCode

string

InnerErrorModel

エラーに関するより具体的な情報を含むオブジェクト。 Microsoft One API のガイドラインに従って - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

名前 説明
code

InnerErrorCode

サーバー定義のエラー コードのセットの 1 つ。

details

object

エラーの詳細。

innererror

InnerErrorModel

エラーに関する現在のオブジェクトよりも具体的な情報を含む オブジェクト。

message

string

エラー メッセージ。

target

string

エラーターゲット。

StringIndexType

文字列オフセットの解釈に使用するメソッドを指定します。 既定では、Unicode v8.0.0 に従って Text 要素 (Graphemes) が使用されます。 詳細については、https://aka.ms/text-analytics-offsets のトピックを参照してください。

名前 説明
TextElements_v8

string

返されるオフセットと長さの値は、Unicode 8.0.0 標準を確認する TextElements (Graphemes および Grapheme クラスター) に対応します。 アプリケーションが .Net Framework または.Net Coreで記述されていて、StringInfo を使用する場合は、このオプションを使用します。

UnicodeCodePoint

string

返されるオフセットと長さの値は、Unicode コード ポイントに対応します。 アプリケーションが Unicode (Python など) をサポートする言語で記述されている場合は、このオプションを使用します。

Utf16CodeUnit

string

返されるオフセットと長さの値は、UTF-16 コード単位に対応します。 アプリケーションが Unicode (Java、JavaScript など) をサポートする言語で記述されている場合は、このオプションを使用します。

TextAnswer

回答結果を表します。

名前 説明
answer

string

回答

answerSpan

AnswerSpan

ユーザーの質問に関して span オブジェクトに回答します。

confidenceScore

number

回答の信頼度スコア、値の範囲は 0 から 1 です。

id

string

レコード ID。

length

integer

文の長さ。

offset

integer

文書の先頭からの文のオフセット。

TextDocument

クエリを実行する入力テキスト レコードを表します。

名前 説明
id

string

テキスト レコードの一意識別子。

text

string

レコードのテキストの内容。