次の方法で共有


Question Answering - Get Answers From Text

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

POST {Endpoint}/language/:query-text?api-version=2021-10-01

URI パラメーター

名前 / 必須 説明
Endpoint
path True

string

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

api-version
query True

string

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

要求ヘッダー

名前 必須 説明
Ocp-Apim-Subscription-Key True

string

要求本文

名前 必須 説明
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

エラー応答。

セキュリティ

Ocp-Apim-Subscription-Key

型: apiKey
/: header

Successful query

要求のサンプル

POST {Endpoint}/language/:query-text?api-version=2021-10-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"
}

応答のサンプル

{
  "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

エラー オブジェクト。

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 (double)

minimum: 0
maximum: 1

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

length

integer (int32)

回答スパンの長さ。

offset

integer (int32)

回答の開始からの回答スパン オフセット。

text

string

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

Error

エラー オブジェクト。

名前 説明
code

ErrorCode

サーバー定義の一連のエラー コードの 1 つ。

details

Error[]

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

innererror

InnerErrorModel

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

message

string

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

target

string

エラーのターゲット。

ErrorCode

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

説明
AzureCognitiveSearchIndexLimitReached
AzureCognitiveSearchIndexNotFound
AzureCognitiveSearchNotFound
AzureCognitiveSearchThrottling
Forbidden
InternalServerError
InvalidArgument
InvalidRequest
NotFound
OperationNotFound
ProjectNotFound
ServiceUnavailable
TooManyRequests
Unauthorized

ErrorResponse

エラー応答。

名前 説明
error

Error

エラー オブジェクト。

InnerErrorCode

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

説明
AzureCognitiveSearchNotFound
AzureCognitiveSearchThrottling
ExtractionFailure
InvalidParameterValue
InvalidRequest
KnowledgeBaseNotFound

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

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

UnicodeCodePoint

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

Utf16CodeUnit

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

TextAnswer

回答の結果を表します。

名前 説明
answer

string

答える。

answerSpan

AnswerSpan

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

confidenceScore

number (double)

minimum: 0
maximum: 1

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

id

string

レコード ID。

length

integer (int32)

文の長さ。

offset

integer (int32)

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

TextDocument

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

名前 説明
id

string

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

text

string

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