azure.ai.language.questionanswering.models package

class azure.ai.language.questionanswering.models.AnswerSpan(*, text: Optional[str] = None, confidence: Optional[float] = None, offset: Optional[int] = None, length: Optional[int] = None, **kwargs)[source]

Answer span object of QnA.

Variables
  • text (str) – Predicted text of answer span.

  • confidence (float) – Predicted score of answer span, value ranges from 0 to 1.

  • offset (int) – The answer span offset from the start of answer.

  • length (int) – The length of the answer span.

Keyword Arguments
  • text (str) – Predicted text of answer span.

  • confidence (float) – Predicted score of answer span, value ranges from 0 to 1.

  • offset (int) – The answer span offset from the start of answer.

  • length (int) – The length of the answer span.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.AnswersFromTextOptions(*, question: str, text_documents: List[Union[str, azure.ai.language.questionanswering.models._models.TextDocument]], language: Optional[str] = None, **kwargs)[source]

The question and text record parameters to answer.

All required parameters must be populated in order to send to Azure.

Variables
  • question (str) – Required. User question to query against the given text records.

  • text_documents (list[str or TextDocument]) – Required. Text records to be searched for given question.

  • language (str) – Language of the text records. This is BCP-47 representation of a language. For example, use “en” for English; “es” for Spanish etc. If not set, use “en” for English as default.

Keyword Arguments
  • question (str) – Required. User question to query against the given text records.

  • text_documents (list[str or TextDocument]) – Required. Text records to be searched for given question.

  • language (str) – Language of the text records. This is BCP-47 representation of a language. For example, use “en” for English; “es” for Spanish etc. If not set, use “en” for English as default.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.AnswersFromTextResult(*, answers: Optional[List[_models.TextAnswer]] = None, **kwargs)[source]

Represents the answer results.

Variables

answers (list[TextAnswer]) – Represents the answer results.

Keyword Arguments

answers (list[TextAnswer]) – Represents the answer results.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.AnswersOptions(*, qna_id: Optional[int] = None, question: Optional[str] = None, top: Optional[int] = None, user_id: Optional[str] = None, confidence_threshold: Optional[float] = None, answer_context: Optional[_models.KnowledgeBaseAnswerContext] = None, ranker_kind: Optional[str] = None, filters: Optional[_models.QueryFilters] = None, short_answer_options: Optional[_models.ShortAnswerOptions] = None, include_unstructured_sources: Optional[bool] = None, **kwargs)[source]

Parameters to query a knowledge base.

Variables
  • qna_id (int) – Exact QnA ID to fetch from the knowledge base, this field takes priority over question.

  • question (str) – User question to query against the knowledge base.

  • top (int) – Max number of answers to be returned for the question.

  • user_id (str) – Unique identifier for the user.

  • confidence_threshold (float) – Minimum threshold score for answers, value ranges from 0 to 1.

  • answer_context (KnowledgeBaseAnswerContext) – Context object with previous QnA’s information.

  • ranker_kind (str) – Type of ranker to be used.

  • filters (QueryFilters) – Filter QnAs based on given metadata list and knowledge base sources.

  • short_answer_options (ShortAnswerOptions) – To configure Answer span prediction feature.

  • include_unstructured_sources (bool) – (Optional) Flag to enable Query over Unstructured Sources.

Keyword Arguments
  • qna_id (int) – Exact QnA ID to fetch from the knowledge base, this field takes priority over question.

  • question (str) – User question to query against the knowledge base.

  • top (int) – Max number of answers to be returned for the question.

  • user_id (str) – Unique identifier for the user.

  • confidence_threshold (float) – Minimum threshold score for answers, value ranges from 0 to 1.

  • answer_context (KnowledgeBaseAnswerContext) – Context object with previous QnA’s information.

  • ranker_kind (str) – Type of ranker to be used.

  • filters (QueryFilters) – Filter QnAs based on given metadata list and knowledge base sources.

  • short_answer_options (ShortAnswerOptions) – To configure Answer span prediction feature.

  • include_unstructured_sources (bool) – (Optional) Flag to enable Query over Unstructured Sources.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.AnswersResult(*, answers: Optional[List[_models.KnowledgeBaseAnswer]] = None, **kwargs)[source]

Represents List of Question Answers.

Variables

answers (list[KnowledgeBaseAnswer]) – Represents Answer Result list.

Keyword Arguments

answers (list[KnowledgeBaseAnswer]) – Represents Answer Result list.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.Error(*, code: Union[str, _models.ErrorCode], message: str, target: Optional[str] = None, details: Optional[List[_models.Error]] = None, innererror: Optional[_models.InnerErrorModel] = None, **kwargs)[source]

The error object.

All required parameters must be populated in order to send to Azure.

Variables
  • code (str or ErrorCode) – One of a server-defined set of error codes. Required. Known values are: “InvalidRequest”, “InvalidArgument”, “Unauthorized”, “Forbidden”, “NotFound”, “ProjectNotFound”, “OperationNotFound”, “AzureCognitiveSearchNotFound”, “AzureCognitiveSearchIndexNotFound”, “TooManyRequests”, “AzureCognitiveSearchThrottling”, “AzureCognitiveSearchIndexLimitReached”, “InternalServerError”, and “ServiceUnavailable”.

  • message (str) – A human-readable representation of the error. Required.

  • target (str) – The target of the error.

  • details (list[Error]) – An array of details about specific errors that led to this reported error.

  • innererror (InnerErrorModel) – An object containing more specific information than the current object about the error.

Keyword Arguments
  • code (str or ErrorCode) – One of a server-defined set of error codes. Required. Known values are: “InvalidRequest”, “InvalidArgument”, “Unauthorized”, “Forbidden”, “NotFound”, “ProjectNotFound”, “OperationNotFound”, “AzureCognitiveSearchNotFound”, “AzureCognitiveSearchIndexNotFound”, “TooManyRequests”, “AzureCognitiveSearchThrottling”, “AzureCognitiveSearchIndexLimitReached”, “InternalServerError”, and “ServiceUnavailable”.

  • message (str) – A human-readable representation of the error. Required.

  • target (str) – The target of the error.

  • details (list[Error]) – An array of details about specific errors that led to this reported error.

  • innererror (InnerErrorModel) – An object containing more specific information than the current object about the error.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.ErrorCode(value)[source]

Human-readable error code.

AZURE_COGNITIVE_SEARCH_INDEX_LIMIT_REACHED = 'AzureCognitiveSearchIndexLimitReached'
AZURE_COGNITIVE_SEARCH_INDEX_NOT_FOUND = 'AzureCognitiveSearchIndexNotFound'
AZURE_COGNITIVE_SEARCH_NOT_FOUND = 'AzureCognitiveSearchNotFound'
AZURE_COGNITIVE_SEARCH_THROTTLING = 'AzureCognitiveSearchThrottling'
FORBIDDEN = 'Forbidden'
INTERNAL_SERVER_ERROR = 'InternalServerError'
INVALID_ARGUMENT = 'InvalidArgument'
INVALID_REQUEST = 'InvalidRequest'
NOT_FOUND = 'NotFound'
OPERATION_NOT_FOUND = 'OperationNotFound'
PROJECT_NOT_FOUND = 'ProjectNotFound'
SERVICE_UNAVAILABLE = 'ServiceUnavailable'
TOO_MANY_REQUESTS = 'TooManyRequests'
UNAUTHORIZED = 'Unauthorized'
class azure.ai.language.questionanswering.models.ErrorResponse(*, error: Optional[_models.Error] = None, **kwargs)[source]

Error response.

Variables

error (Error) – The error object.

Keyword Arguments

error (Error) – The error object.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.InnerErrorCode(value)[source]

Human-readable error code.

AZURE_COGNITIVE_SEARCH_NOT_FOUND = 'AzureCognitiveSearchNotFound'
AZURE_COGNITIVE_SEARCH_THROTTLING = 'AzureCognitiveSearchThrottling'
EXTRACTION_FAILURE = 'ExtractionFailure'
INVALID_PARAMETER_VALUE = 'InvalidParameterValue'
INVALID_REQUEST = 'InvalidRequest'
KNOWLEDGE_BASE_NOT_FOUND = 'KnowledgeBaseNotFound'
class azure.ai.language.questionanswering.models.InnerErrorModel(*, code: Union[str, _models.InnerErrorCode], message: str, details: Optional[Dict[str, str]] = None, target: Optional[str] = None, innererror: Optional[_models.InnerErrorModel] = None, **kwargs)[source]

An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.

All required parameters must be populated in order to send to Azure.

Variables
  • code (str or InnerErrorCode) – One of a server-defined set of error codes. Required. Known values are: “InvalidRequest”, “InvalidParameterValue”, “KnowledgeBaseNotFound”, “AzureCognitiveSearchNotFound”, “AzureCognitiveSearchThrottling”, and “ExtractionFailure”.

  • message (str) – Error message. Required.

  • details (dict[str, str]) – Error details.

  • target (str) – Error target.

  • innererror (InnerErrorModel) – An object containing more specific information than the current object about the error.

Keyword Arguments
  • code (str or InnerErrorCode) – One of a server-defined set of error codes. Required. Known values are: “InvalidRequest”, “InvalidParameterValue”, “KnowledgeBaseNotFound”, “AzureCognitiveSearchNotFound”, “AzureCognitiveSearchThrottling”, and “ExtractionFailure”.

  • message (str) – Error message. Required.

  • details (dict[str, str]) – Error details.

  • target (str) – Error target.

  • innererror (InnerErrorModel) – An object containing more specific information than the current object about the error.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.KnowledgeBaseAnswer(*, questions: Optional[List[str]] = None, answer: Optional[str] = None, confidence: Optional[float] = None, qna_id: Optional[int] = None, source: Optional[str] = None, metadata: Optional[Dict[str, str]] = None, dialog: Optional[_models.KnowledgeBaseAnswerDialog] = None, short_answer: Optional[_models.AnswerSpan] = None, **kwargs)[source]

Represents knowledge base answer.

Variables
  • questions (list[str]) – List of questions associated with the answer.

  • answer (str) – Answer text.

  • confidence (float) – Answer confidence score, value ranges from 0 to 1.

  • qna_id (int) – ID of the QnA result.

  • source (str) – Source of QnA result.

  • metadata (dict[str, str]) – Metadata associated with the answer, useful to categorize or filter question answers.

  • dialog (KnowledgeBaseAnswerDialog) – Dialog associated with Answer.

  • short_answer (AnswerSpan) – Answer span object of QnA with respect to user’s question.

Keyword Arguments
  • questions (list[str]) – List of questions associated with the answer.

  • answer (str) – Answer text.

  • confidence (float) – Answer confidence score, value ranges from 0 to 1.

  • qna_id (int) – ID of the QnA result.

  • source (str) – Source of QnA result.

  • metadata (dict[str, str]) – Metadata associated with the answer, useful to categorize or filter question answers.

  • dialog (KnowledgeBaseAnswerDialog) – Dialog associated with Answer.

  • short_answer (AnswerSpan) – Answer span object of QnA with respect to user’s question.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.KnowledgeBaseAnswerContext(*, previous_qna_id: int, previous_question: Optional[str] = None, **kwargs)[source]

Context object with previous QnA’s information.

All required parameters must be populated in order to send to Azure.

Variables
  • previous_qna_id (int) – Previous turn top answer result QnA ID. Required.

  • previous_question (str) – Previous user query.

Keyword Arguments
  • previous_qna_id (int) – Previous turn top answer result QnA ID. Required.

  • previous_question (str) – Previous user query.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog(*, is_context_only: Optional[bool] = None, prompts: Optional[List[_models.KnowledgeBaseAnswerPrompt]] = None, **kwargs)[source]

Dialog associated with Answer.

Variables
  • is_context_only (bool) – To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as search result for queries without context; otherwise, if false, ignores context and includes this QnA in search result.

  • prompts (list[KnowledgeBaseAnswerPrompt]) – List of prompts associated with the answer.

Keyword Arguments
  • is_context_only (bool) – To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as search result for queries without context; otherwise, if false, ignores context and includes this QnA in search result.

  • prompts (list[KnowledgeBaseAnswerPrompt]) – List of prompts associated with the answer.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.KnowledgeBaseAnswerPrompt(*, display_order: Optional[int] = None, qna_id: Optional[int] = None, display_text: Optional[str] = None, **kwargs)[source]

Prompt for an answer.

Variables
  • display_order (int) – Index of the prompt - used in ordering of the prompts.

  • qna_id (int) – QnA ID corresponding to the prompt.

  • display_text (str) – Text displayed to represent a follow up question prompt.

Keyword Arguments
  • display_order (int) – Index of the prompt - used in ordering of the prompts.

  • qna_id (int) – QnA ID corresponding to the prompt.

  • display_text (str) – Text displayed to represent a follow up question prompt.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.MetadataFilter(*, metadata: Optional[List[Tuple[str, str]]] = None, logical_operation: Optional[str] = None, **kwargs)[source]

Find QnAs that are associated with the given list of metadata.

Variables
  • metadata (list[tuple[str, str]]) –

  • logical_operation (str) – Operation used to join metadata filters. Possible values include: “AND”, “OR”.

Keyword Arguments
  • metadata (list[tuple[str, str]]) –

  • logical_operation (str) – Operation used to join metadata filters. Possible values include: “AND”, “OR”.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.QueryFilters(*, metadata_filter: Optional[_models.MetadataFilter] = None, source_filter: Optional[List[str]] = None, logical_operation: Optional[str] = None, **kwargs)[source]

filters over knowledge base.

Variables
  • metadata_filter (MetadataFilter) – Find QnAs that are associated with the given list of metadata.

  • source_filter (list[str]) – Find QnAs that are associated with any of the given list of sources in knowledge base.

  • logical_operation (str) – Logical operation used to join metadata filter with source filter.

Keyword Arguments
  • metadata_filter (MetadataFilter) – Find QnAs that are associated with the given list of metadata.

  • source_filter (list[str]) – Find QnAs that are associated with any of the given list of sources in knowledge base.

  • logical_operation (str) – Logical operation used to join metadata filter with source filter.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.ShortAnswerOptions(*, confidence_threshold: Optional[float] = None, top: Optional[int] = None, **kwargs)[source]

To configure Answer span prediction feature.

Variables are only populated by the server, and will be ignored when sending a request.

All required parameters must be populated in order to send to Azure.

Variables
  • enable (bool) – Enable or disable Answer Span prediction. Required. Default value is True.

  • confidence_threshold (float) – Minimum threshold score required to include an answer span, value ranges from 0 to 1.

  • top (int) – Number of Top answers to be considered for span prediction from 1 to 10.

Keyword Arguments
  • confidence_threshold (float) – Minimum threshold score required to include an answer span, value ranges from 0 to 1.

  • top (int) – Number of Top answers to be considered for span prediction from 1 to 10.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

enable = True
class azure.ai.language.questionanswering.models.TextAnswer(*, answer: Optional[str] = None, confidence: Optional[float] = None, id: Optional[str] = None, short_answer: Optional[_models.AnswerSpan] = None, offset: Optional[int] = None, length: Optional[int] = None, **kwargs)[source]

Represents answer result.

Variables
  • answer (str) – Answer.

  • confidence (float) – answer confidence score, value ranges from 0 to 1.

  • id (str) – record ID.

  • short_answer (AnswerSpan) – Answer span object with respect to user’s question.

  • offset (int) – The sentence offset from the start of the document.

  • length (int) – The length of the sentence.

Keyword Arguments
  • answer (str) – Answer.

  • confidence (float) – answer confidence score, value ranges from 0 to 1.

  • id (str) – record ID.

  • short_answer (AnswerSpan) – Answer span object with respect to user’s question.

  • offset (int) – The sentence offset from the start of the document.

  • length (int) – The length of the sentence.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

class azure.ai.language.questionanswering.models.TextDocument(*, id: str, text: str, **kwargs)[source]

Represent input text record to be queried.

All required parameters must be populated in order to send to Azure.

Variables
  • id (str) – Unique identifier for the text record. Required.

  • text (str) – Text contents of the record. Required.

Keyword Arguments
  • id (str) – Unique identifier for the text record. Required.

  • text (str) – Text contents of the record. Required.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict