-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support auto record ID * Fix knowledge base casing * Updated changelog * Remove chardet
- Loading branch information
Showing
21 changed files
with
422 additions
and
317 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...anguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------- | ||
|
||
import six | ||
|
||
from .models import TextRecord | ||
|
||
|
||
def _validate_text_records(records): | ||
if not records: | ||
raise ValueError("Input records can not be empty or None") | ||
|
||
if isinstance(records, six.string_types): | ||
raise TypeError("Input records cannot be a string.") | ||
|
||
if isinstance(records, dict): | ||
raise TypeError("Input records cannot be a dict") | ||
|
||
if not all(isinstance(x, six.string_types) for x in records): | ||
if not all( | ||
isinstance(x, (dict, TextRecord)) | ||
for x in records | ||
): | ||
raise TypeError( | ||
"Mixing string and dictionary/object record input unsupported." | ||
) | ||
|
||
request_batch = [] | ||
for idx, doc in enumerate(records): | ||
if isinstance(doc, six.string_types): | ||
record = {"id": str(idx), "text": doc} | ||
request_batch.append(record) | ||
else: | ||
request_batch.append(doc) | ||
return request_batch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.