From 5c90ac126be1544e3f75492744d41704b6093753 Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Mon, 20 Nov 2017 12:56:48 -0800 Subject: [PATCH] Initial version of SpellCheck --- .../HISTORY.rst | 9 + .../MANIFEST.in | 2 + .../README.rst | 41 ++ .../azure/__init__.py | 1 + .../azure/cognitiveservices/__init__.py | 1 + .../cognitiveservices/language/__init__.py | 1 + .../language/spellcheck/__init__.py | 18 + .../language/spellcheck/build.json | 339 +++++++++++ .../language/spellcheck/models/__init__.py | 44 ++ .../language/spellcheck/models/answer.py | 41 ++ .../language/spellcheck/models/error.py | 69 +++ .../spellcheck/models/error_response.py | 59 ++ .../spellcheck/models/identifiable.py | 47 ++ .../language/spellcheck/models/response.py | 42 ++ .../spellcheck/models/response_base.py | 38 ++ .../language/spellcheck/models/spell_check.py | 45 ++ .../models/spell_check_client_enums.py | 55 ++ .../models/spelling_flagged_token.py | 57 ++ .../models/spelling_token_suggestion.py | 44 ++ .../language/spellcheck/spell_check_client.py | 372 ++++++++++++ .../language/spellcheck/version.py | 13 + .../azure_bdist_wheel.py | 533 ++++++++++++++++++ .../setup.cfg | 3 + .../setup.py | 85 +++ .../tests/recordings/test_spell_check.yaml | 41 ++ .../tests/test_spell_check.py | 56 ++ swagger_to_sdk_config.json | 12 + 27 files changed, 2068 insertions(+) create mode 100644 azure-cognitiveservices-language-spellcheck/HISTORY.rst create mode 100644 azure-cognitiveservices-language-spellcheck/MANIFEST.in create mode 100644 azure-cognitiveservices-language-spellcheck/README.rst create mode 100644 azure-cognitiveservices-language-spellcheck/azure/__init__.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/__init__.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/__init__.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/__init__.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/build.json create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/__init__.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/answer.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/error.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/error_response.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/identifiable.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/response.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/response_base.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spell_check.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spell_check_client_enums.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spelling_flagged_token.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spelling_token_suggestion.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/spell_check_client.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/version.py create mode 100644 azure-cognitiveservices-language-spellcheck/azure_bdist_wheel.py create mode 100644 azure-cognitiveservices-language-spellcheck/setup.cfg create mode 100644 azure-cognitiveservices-language-spellcheck/setup.py create mode 100644 azure-cognitiveservices-language-spellcheck/tests/recordings/test_spell_check.yaml create mode 100644 azure-cognitiveservices-language-spellcheck/tests/test_spell_check.py diff --git a/azure-cognitiveservices-language-spellcheck/HISTORY.rst b/azure-cognitiveservices-language-spellcheck/HISTORY.rst new file mode 100644 index 000000000000..8924d5d6c445 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/HISTORY.rst @@ -0,0 +1,9 @@ +.. :changelog: + +Release History +=============== + +0.1.0 (1970-01-01) +++++++++++++++++++ + +* Initial Release diff --git a/azure-cognitiveservices-language-spellcheck/MANIFEST.in b/azure-cognitiveservices-language-spellcheck/MANIFEST.in new file mode 100644 index 000000000000..9ecaeb15de50 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/MANIFEST.in @@ -0,0 +1,2 @@ +include *.rst +include azure_bdist_wheel.py \ No newline at end of file diff --git a/azure-cognitiveservices-language-spellcheck/README.rst b/azure-cognitiveservices-language-spellcheck/README.rst new file mode 100644 index 000000000000..69b98f7eef43 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/README.rst @@ -0,0 +1,41 @@ +Microsoft Azure SDK for Python +============================== + +This is the Microsoft Azure Cognitive Services Bing Spell Check Client Library. + +Azure Resource Manager (ARM) is the next generation of management APIs that +replace the old Azure Service Management (ASM). + +This package has been tested with Python 2.7, 3.3, 3.4, 3.5 and 3.6. + +For the older Azure Service Management (ASM) libraries, see +`azure-servicemanagement-legacy `__ library. + +For a more complete set of Azure libraries, see the `azure `__ bundle package. + + +Compatibility +============= + +**IMPORTANT**: If you have an earlier version of the azure package +(version < 1.0), you should uninstall it before installing this package. + +You can check the version using pip: + +.. code:: shell + + pip freeze + +If you see azure==0.11.0 (or any version below 1.0), uninstall it first: + +.. code:: shell + + pip uninstall azure + + +Provide Feedback +================ + +If you encounter any bugs or have suggestions, please file an issue in the +`Issues `__ +section of the project. diff --git a/azure-cognitiveservices-language-spellcheck/azure/__init__.py b/azure-cognitiveservices-language-spellcheck/azure/__init__.py new file mode 100644 index 000000000000..849489fca33c --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/__init__.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/__init__.py new file mode 100644 index 000000000000..849489fca33c --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/__init__.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/__init__.py new file mode 100644 index 000000000000..849489fca33c --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/__init__.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/__init__.py new file mode 100644 index 000000000000..e3021f39512a --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/__init__.py @@ -0,0 +1,18 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .spell_check_client import SpellCheckClient +from .version import VERSION + +__all__ = ['SpellCheckClient'] + +__version__ = VERSION + diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/build.json b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/build.json new file mode 100644 index 000000000000..c63116cab7c0 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/build.json @@ -0,0 +1,339 @@ +{ + "autorest": [ + { + "resolvedInfo": null, + "packageMetadata": { + "name": "@microsoft.azure/autorest-core", + "version": "2.0.4168", + "engines": { + "node": ">=7.10.0" + }, + "dependencies": {}, + "optionalDependencies": {}, + "devDependencies": { + "@microsoft.azure/async-io": "~1.0.22", + "@microsoft.azure/extension": "~1.2.12", + "@types/commonmark": "^0.27.0", + "@types/jsonpath": "^0.1.29", + "@types/node": "^8.0.28", + "@types/pify": "0.0.28", + "@types/source-map": "^0.5.0", + "@types/yargs": "^8.0.2", + "commonmark": "^0.27.0", + "file-url": "^2.0.2", + "get-uri": "^2.0.0", + "jsonpath": "^0.2.11", + "linq-es2015": "^2.4.25", + "mocha": "3.4.2", + "mocha-typescript": "1.1.5", + "pify": "^3.0.0", + "safe-eval": "^0.3.0", + "shx": "^0.2.2", + "source-map": "^0.5.6", + "source-map-support": "^0.4.15", + "strip-bom": "^3.0.0", + "typescript": "2.5.3", + "untildify": "^3.0.2", + "urijs": "^1.18.10", + "vscode-jsonrpc": "^3.3.1", + "yaml-ast-parser": "https://github.com/olydis/yaml-ast-parser/releases/download/0.0.34/yaml-ast-parser-0.0.34.tgz", + "yargs": "^8.0.2" + }, + "bundleDependencies": false, + "peerDependencies": {}, + "deprecated": false, + "_resolved": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest-core@2.0.4168/node_modules/@microsoft.azure/autorest-core", + "_shasum": "33813111fc9bfa488bd600fbba48bc53cc9182c7", + "_shrinkwrap": null, + "bin": null, + "_id": "@microsoft.azure/autorest-core@2.0.4168", + "_from": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest-core@2.0.4168/node_modules/@microsoft.azure/autorest-core", + "_requested": { + "type": "directory", + "where": "D:\\VSProjects\\swagger-to-sdk", + "raw": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest-core@2.0.4168\\node_modules\\@microsoft.azure\\autorest-core", + "rawSpec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest-core@2.0.4168\\node_modules\\@microsoft.azure\\autorest-core", + "saveSpec": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest-core@2.0.4168/node_modules/@microsoft.azure/autorest-core", + "fetchSpec": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest-core@2.0.4168/node_modules/@microsoft.azure/autorest-core" + }, + "_spec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest-core@2.0.4168\\node_modules\\@microsoft.azure\\autorest-core", + "_where": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest-core@2.0.4168\\node_modules\\@microsoft.azure\\autorest-core" + }, + "extensionManager": { + "installationPath": "C:\\Users\\lmazuel\\.autorest", + "dotnetPath": "C:\\Users\\lmazuel\\.dotnet" + }, + "installationPath": "C:\\Users\\lmazuel\\.autorest" + }, + { + "resolvedInfo": null, + "packageMetadata": { + "name": "@microsoft.azure/autorest.go", + "version": "2.0.24", + "dependencies": { + "dotnet-2.0.0": "^1.1.0" + }, + "optionalDependencies": {}, + "devDependencies": { + "@microsoft.azure/autorest.testserver": "^1.9.0", + "autorest": "^2.0.0", + "coffee-script": "^1.11.1", + "dotnet-sdk-2.0.0": "^1.1.1", + "gulp": "^3.9.1", + "gulp-filter": "^5.0.0", + "gulp-line-ending-corrector": "^1.0.1", + "iced-coffee-script": "^108.0.11", + "marked": "^0.3.6", + "marked-terminal": "^2.0.0", + "moment": "^2.17.1", + "run-sequence": "*", + "shx": "^0.2.2", + "through2-parallel": "^0.1.3", + "yargs": "^8.0.2", + "yarn": "^1.0.2" + }, + "bundleDependencies": false, + "peerDependencies": {}, + "deprecated": false, + "_resolved": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.go@2.0.24/node_modules/@microsoft.azure/autorest.go", + "_shasum": "409a4a9a21708a7aea58fadb0b064ea487a90fea", + "_shrinkwrap": null, + "bin": null, + "_id": "@microsoft.azure/autorest.go@2.0.24", + "_from": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.go@2.0.24/node_modules/@microsoft.azure/autorest.go", + "_requested": { + "type": "directory", + "where": "D:\\VSProjects\\swagger-to-sdk", + "raw": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.go@2.0.24\\node_modules\\@microsoft.azure\\autorest.go", + "rawSpec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.go@2.0.24\\node_modules\\@microsoft.azure\\autorest.go", + "saveSpec": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.go@2.0.24/node_modules/@microsoft.azure/autorest.go", + "fetchSpec": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.go@2.0.24/node_modules/@microsoft.azure/autorest.go" + }, + "_spec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.go@2.0.24\\node_modules\\@microsoft.azure\\autorest.go", + "_where": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.go@2.0.24\\node_modules\\@microsoft.azure\\autorest.go" + }, + "extensionManager": { + "installationPath": "C:\\Users\\lmazuel\\.autorest", + "dotnetPath": "C:\\Users\\lmazuel\\.dotnet" + }, + "installationPath": "C:\\Users\\lmazuel\\.autorest" + }, + { + "resolvedInfo": null, + "packageMetadata": { + "name": "@microsoft.azure/autorest.modeler", + "version": "2.0.18", + "dependencies": { + "dotnet-2.0.0": "^1.1.0" + }, + "optionalDependencies": {}, + "devDependencies": { + "coffee-script": "^1.11.1", + "dotnet-sdk-2.0.0": "^1.1.1", + "gulp": "^3.9.1", + "gulp-filter": "^5.0.0", + "gulp-line-ending-corrector": "^1.0.1", + "iced-coffee-script": "^108.0.11", + "marked": "^0.3.6", + "marked-terminal": "^2.0.0", + "moment": "^2.17.1", + "run-sequence": "*", + "shx": "^0.2.2", + "through2-parallel": "^0.1.3", + "yargs": "^8.0.2", + "yarn": "^1.0.2" + }, + "bundleDependencies": false, + "peerDependencies": {}, + "deprecated": false, + "_resolved": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.modeler@2.0.18/node_modules/@microsoft.azure/autorest.modeler", + "_shasum": "b8e853f83b99b2a37ad534cb8463da5de4b11418", + "_shrinkwrap": null, + "bin": null, + "_id": "@microsoft.azure/autorest.modeler@2.0.18", + "_from": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.modeler@2.0.18/node_modules/@microsoft.azure/autorest.modeler", + "_requested": { + "type": "directory", + "where": "D:\\VSProjects\\swagger-to-sdk", + "raw": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.modeler@2.0.18\\node_modules\\@microsoft.azure\\autorest.modeler", + "rawSpec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.modeler@2.0.18\\node_modules\\@microsoft.azure\\autorest.modeler", + "saveSpec": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.modeler@2.0.18/node_modules/@microsoft.azure/autorest.modeler", + "fetchSpec": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.modeler@2.0.18/node_modules/@microsoft.azure/autorest.modeler" + }, + "_spec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.modeler@2.0.18\\node_modules\\@microsoft.azure\\autorest.modeler", + "_where": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.modeler@2.0.18\\node_modules\\@microsoft.azure\\autorest.modeler" + }, + "extensionManager": { + "installationPath": "C:\\Users\\lmazuel\\.autorest", + "dotnetPath": "C:\\Users\\lmazuel\\.dotnet" + }, + "installationPath": "C:\\Users\\lmazuel\\.autorest" + }, + { + "resolvedInfo": null, + "packageMetadata": { + "name": "@microsoft.azure/autorest.modeler", + "version": "2.1.22", + "dependencies": { + "dotnet-2.0.0": "^1.4.4" + }, + "optionalDependencies": {}, + "devDependencies": { + "coffee-script": "^1.11.1", + "dotnet-sdk-2.0.0": "^1.4.4", + "gulp": "^3.9.1", + "gulp-filter": "^5.0.0", + "gulp-line-ending-corrector": "^1.0.1", + "iced-coffee-script": "^108.0.11", + "marked": "^0.3.6", + "marked-terminal": "^2.0.0", + "moment": "^2.17.1", + "run-sequence": "*", + "shx": "^0.2.2", + "through2-parallel": "^0.1.3", + "yargs": "^8.0.2", + "yarn": "^1.0.2" + }, + "bundleDependencies": false, + "peerDependencies": {}, + "deprecated": false, + "_resolved": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.modeler@2.1.22/node_modules/@microsoft.azure/autorest.modeler", + "_shasum": "ca425289fa38a210d279729048a4a91673f09c67", + "_shrinkwrap": null, + "bin": null, + "_id": "@microsoft.azure/autorest.modeler@2.1.22", + "_from": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.modeler@2.1.22/node_modules/@microsoft.azure/autorest.modeler", + "_requested": { + "type": "directory", + "where": "D:\\VSProjects\\swagger-to-sdk", + "raw": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.modeler@2.1.22\\node_modules\\@microsoft.azure\\autorest.modeler", + "rawSpec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.modeler@2.1.22\\node_modules\\@microsoft.azure\\autorest.modeler", + "saveSpec": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.modeler@2.1.22/node_modules/@microsoft.azure/autorest.modeler", + "fetchSpec": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.modeler@2.1.22/node_modules/@microsoft.azure/autorest.modeler" + }, + "_spec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.modeler@2.1.22\\node_modules\\@microsoft.azure\\autorest.modeler", + "_where": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.modeler@2.1.22\\node_modules\\@microsoft.azure\\autorest.modeler" + }, + "extensionManager": { + "installationPath": "C:\\Users\\lmazuel\\.autorest", + "dotnetPath": "C:\\Users\\lmazuel\\.dotnet" + }, + "installationPath": "C:\\Users\\lmazuel\\.autorest" + }, + { + "resolvedInfo": null, + "packageMetadata": { + "name": "@microsoft.azure/autorest.python", + "version": "2.0.13", + "dependencies": { + "dotnet-2.0.0": "^1.1.0" + }, + "optionalDependencies": {}, + "devDependencies": { + "@microsoft.azure/autorest.testserver": "^1.9.0", + "autorest": "^2.0.0", + "coffee-script": "^1.11.1", + "dotnet-sdk-2.0.0": "^1.1.1", + "gulp": "^3.9.1", + "gulp-filter": "^5.0.0", + "gulp-line-ending-corrector": "^1.0.1", + "iced-coffee-script": "^108.0.11", + "marked": "^0.3.6", + "marked-terminal": "^2.0.0", + "moment": "^2.17.1", + "run-sequence": "*", + "shx": "^0.2.2", + "through2-parallel": "^0.1.3", + "yargs": "^8.0.2", + "yarn": "^1.0.2" + }, + "bundleDependencies": false, + "peerDependencies": {}, + "deprecated": false, + "_resolved": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.python@2.0.13/node_modules/@microsoft.azure/autorest.python", + "_shasum": "ddbbf3e3f1f90ae4132b687cfa8450425ab4ffcd", + "_shrinkwrap": null, + "bin": null, + "_id": "@microsoft.azure/autorest.python@2.0.13", + "_from": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.python@2.0.13/node_modules/@microsoft.azure/autorest.python", + "_requested": { + "type": "directory", + "where": "D:\\VSProjects\\swagger-to-sdk", + "raw": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.python@2.0.13\\node_modules\\@microsoft.azure\\autorest.python", + "rawSpec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.python@2.0.13\\node_modules\\@microsoft.azure\\autorest.python", + "saveSpec": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.python@2.0.13/node_modules/@microsoft.azure/autorest.python", + "fetchSpec": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.python@2.0.13/node_modules/@microsoft.azure/autorest.python" + }, + "_spec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.python@2.0.13\\node_modules\\@microsoft.azure\\autorest.python", + "_where": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.python@2.0.13\\node_modules\\@microsoft.azure\\autorest.python" + }, + "extensionManager": { + "installationPath": "C:\\Users\\lmazuel\\.autorest", + "dotnetPath": "C:\\Users\\lmazuel\\.dotnet" + }, + "installationPath": "C:\\Users\\lmazuel\\.autorest" + }, + { + "resolvedInfo": null, + "packageMetadata": { + "name": "@microsoft.azure/autorest.python", + "version": "2.0.19", + "dependencies": { + "dotnet-2.0.0": "^1.4.4" + }, + "optionalDependencies": {}, + "devDependencies": { + "@microsoft.azure/autorest.testserver": "^1.9.0", + "autorest": "^2.0.0", + "coffee-script": "^1.11.1", + "dotnet-sdk-2.0.0": "^1.4.4", + "gulp": "^3.9.1", + "gulp-filter": "^5.0.0", + "gulp-line-ending-corrector": "^1.0.1", + "iced-coffee-script": "^108.0.11", + "marked": "^0.3.6", + "marked-terminal": "^2.0.0", + "moment": "^2.17.1", + "run-sequence": "*", + "shx": "^0.2.2", + "through2-parallel": "^0.1.3", + "yargs": "^8.0.2", + "yarn": "^1.0.2" + }, + "bundleDependencies": false, + "peerDependencies": {}, + "deprecated": false, + "_resolved": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.python@2.0.19/node_modules/@microsoft.azure/autorest.python", + "_shasum": "e069166c16fd903c8e1fdf9395b433f3043cb6e3", + "_shrinkwrap": null, + "bin": null, + "_id": "@microsoft.azure/autorest.python@2.0.19", + "_from": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.python@2.0.19/node_modules/@microsoft.azure/autorest.python", + "_requested": { + "type": "directory", + "where": "D:\\VSProjects\\swagger-to-sdk", + "raw": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.python@2.0.19\\node_modules\\@microsoft.azure\\autorest.python", + "rawSpec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.python@2.0.19\\node_modules\\@microsoft.azure\\autorest.python", + "saveSpec": "file:C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.python@2.0.19/node_modules/@microsoft.azure/autorest.python", + "fetchSpec": "C:/Users/lmazuel/.autorest/@microsoft.azure_autorest.python@2.0.19/node_modules/@microsoft.azure/autorest.python" + }, + "_spec": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.python@2.0.19\\node_modules\\@microsoft.azure\\autorest.python", + "_where": "C:\\Users\\lmazuel\\.autorest\\@microsoft.azure_autorest.python@2.0.19\\node_modules\\@microsoft.azure\\autorest.python" + }, + "extensionManager": { + "installationPath": "C:\\Users\\lmazuel\\.autorest", + "dotnetPath": "C:\\Users\\lmazuel\\.dotnet" + }, + "installationPath": "C:\\Users\\lmazuel\\.autorest" + } + ], + "autorest_bootstrap": { + "dependencies": { + "autorest": { + "version": "2.0.4166", + "from": "autorest@latest", + "resolved": "https://registry.npmjs.org/autorest/-/autorest-2.0.4166.tgz" + } + } + } +} \ No newline at end of file diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/__init__.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/__init__.py new file mode 100644 index 000000000000..21f86dc04fdd --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/__init__.py @@ -0,0 +1,44 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .spelling_token_suggestion import SpellingTokenSuggestion +from .spelling_flagged_token import SpellingFlaggedToken +from .spell_check import SpellCheck +from .answer import Answer +from .response import Response +from .identifiable import Identifiable +from .error import Error +from .error_response import ErrorResponse, ErrorResponseException +from .response_base import ResponseBase +from .spell_check_client_enums import ( + ErrorType, + ErrorCode, + ErrorSubCode, + ActionType, + Mode, +) + +__all__ = [ + 'SpellingTokenSuggestion', + 'SpellingFlaggedToken', + 'SpellCheck', + 'Answer', + 'Response', + 'Identifiable', + 'Error', + 'ErrorResponse', 'ErrorResponseException', + 'ResponseBase', + 'ErrorType', + 'ErrorCode', + 'ErrorSubCode', + 'ActionType', + 'Mode', +] diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/answer.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/answer.py new file mode 100644 index 000000000000..f24affbefdb9 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/answer.py @@ -0,0 +1,41 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .response import Response + + +class Answer(Response): + """Answer. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: SpellCheck + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param _type: Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + } + + _subtype_map = { + '_type': {'SpellCheck': 'SpellCheck'} + } + + def __init__(self): + super(Answer, self).__init__() + self._type = 'Answer' diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/error.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/error.py new file mode 100644 index 000000000000..c073cbafa525 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/error.py @@ -0,0 +1,69 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Error(Model): + """Defines the error that occurred. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param code: The error code that identifies the category of error. + Possible values include: 'None', 'ServerError', 'InvalidRequest', + 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'. + Default value: "None" . + :type code: str or + ~azure.cognitiveservices.language.spellcheck.models.ErrorCode + :ivar sub_code: The error code that further helps to identify the error. + Possible values include: 'UnexpectedError', 'ResourceError', + 'NotImplemented', 'ParameterMissing', 'ParameterInvalidValue', + 'HttpNotAllowed', 'Blocked', 'AuthorizationMissing', + 'AuthorizationRedundancy', 'AuthorizationDisabled', 'AuthorizationExpired' + :vartype sub_code: str or + ~azure.cognitiveservices.language.spellcheck.models.ErrorSubCode + :param message: A description of the error. + :type message: str + :ivar more_details: A description that provides additional information + about the error. + :vartype more_details: str + :ivar parameter: The parameter in the request that caused the error. + :vartype parameter: str + :ivar value: The parameter's value in the request that was not valid. + :vartype value: str + """ + + _validation = { + 'code': {'required': True}, + 'sub_code': {'readonly': True}, + 'message': {'required': True}, + 'more_details': {'readonly': True}, + 'parameter': {'readonly': True}, + 'value': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'sub_code': {'key': 'subCode', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'more_details': {'key': 'moreDetails', 'type': 'str'}, + 'parameter': {'key': 'parameter', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, message, code="None"): + self.code = code + self.sub_code = None + self.message = message + self.more_details = None + self.parameter = None + self.value = None diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/error_response.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/error_response.py new file mode 100644 index 000000000000..803ea329ee79 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/error_response.py @@ -0,0 +1,59 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .response import Response +from msrest.exceptions import HttpOperationError + + +class ErrorResponse(Response): + """The top-level response that represents a failed request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param _type: Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :param errors: A list of errors that describe the reasons why the request + failed. + :type errors: + list[~azure.cognitiveservices.language.spellcheck.models.Error] + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'errors': {'required': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'errors': {'key': 'errors', 'type': '[Error]'}, + } + + def __init__(self, errors): + super(ErrorResponse, self).__init__() + self.errors = errors + self._type = 'ErrorResponse' + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/identifiable.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/identifiable.py new file mode 100644 index 000000000000..133e93fa8f94 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/identifiable.py @@ -0,0 +1,47 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .response_base import ResponseBase + + +class Identifiable(ResponseBase): + """Defines the identity of a resource. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: Response + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param _type: Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + } + + _subtype_map = { + '_type': {'Response': 'Response'} + } + + def __init__(self): + super(Identifiable, self).__init__() + self.id = None + self._type = 'Identifiable' diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/response.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/response.py new file mode 100644 index 000000000000..7e0fd792b145 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/response.py @@ -0,0 +1,42 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .identifiable import Identifiable + + +class Response(Identifiable): + """Defines a response. All schemas that could be returned at the root of a + response should inherit from this. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: Answer, ErrorResponse + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param _type: Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + } + + _subtype_map = { + '_type': {'Answer': 'Answer', 'ErrorResponse': 'ErrorResponse'} + } + + def __init__(self): + super(Response, self).__init__() + self._type = 'Response' diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/response_base.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/response_base.py new file mode 100644 index 000000000000..8e0c08a7c46a --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/response_base.py @@ -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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ResponseBase(Model): + """ResponseBase. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: Identifiable + + :param _type: Constant filled by server. + :type _type: str + """ + + _validation = { + '_type': {'required': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + } + + _subtype_map = { + '_type': {'Identifiable': 'Identifiable'} + } + + def __init__(self): + self._type = None diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spell_check.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spell_check.py new file mode 100644 index 000000000000..2060e708de97 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spell_check.py @@ -0,0 +1,45 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .answer import Answer + + +class SpellCheck(Answer): + """SpellCheck. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param _type: Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :param flagged_tokens: + :type flagged_tokens: + list[~azure.cognitiveservices.language.spellcheck.models.SpellingFlaggedToken] + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'flagged_tokens': {'required': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'flagged_tokens': {'key': 'flaggedTokens', 'type': '[SpellingFlaggedToken]'}, + } + + def __init__(self, flagged_tokens): + super(SpellCheck, self).__init__() + self.flagged_tokens = flagged_tokens + self._type = 'SpellCheck' diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spell_check_client_enums.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spell_check_client_enums.py new file mode 100644 index 000000000000..92c8761b7d39 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spell_check_client_enums.py @@ -0,0 +1,55 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class ErrorType(Enum): + + unknown_token = "UnknownToken" + repeated_token = "RepeatedToken" + + +class ErrorCode(Enum): + + none = "None" + server_error = "ServerError" + invalid_request = "InvalidRequest" + rate_limit_exceeded = "RateLimitExceeded" + invalid_authorization = "InvalidAuthorization" + insufficient_authorization = "InsufficientAuthorization" + + +class ErrorSubCode(Enum): + + unexpected_error = "UnexpectedError" + resource_error = "ResourceError" + not_implemented = "NotImplemented" + parameter_missing = "ParameterMissing" + parameter_invalid_value = "ParameterInvalidValue" + http_not_allowed = "HttpNotAllowed" + blocked = "Blocked" + authorization_missing = "AuthorizationMissing" + authorization_redundancy = "AuthorizationRedundancy" + authorization_disabled = "AuthorizationDisabled" + authorization_expired = "AuthorizationExpired" + + +class ActionType(Enum): + + edit = "Edit" + load = "Load" + + +class Mode(Enum): + + proof = "Proof" + spell = "Spell" diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spelling_flagged_token.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spelling_flagged_token.py new file mode 100644 index 000000000000..3d5289b852eb --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spelling_flagged_token.py @@ -0,0 +1,57 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SpellingFlaggedToken(Model): + """SpellingFlaggedToken. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param offset: + :type offset: int + :param token: + :type token: str + :param type: Possible values include: 'UnknownToken', 'RepeatedToken'. + Default value: "UnknownToken" . + :type type: str or + ~azure.cognitiveservices.language.spellcheck.models.ErrorType + :ivar suggestions: + :vartype suggestions: + list[~azure.cognitiveservices.language.spellcheck.models.SpellingTokenSuggestion] + :ivar ping_url_suffix: + :vartype ping_url_suffix: str + """ + + _validation = { + 'offset': {'required': True}, + 'token': {'required': True}, + 'type': {'required': True}, + 'suggestions': {'readonly': True}, + 'ping_url_suffix': {'readonly': True}, + } + + _attribute_map = { + 'offset': {'key': 'offset', 'type': 'int'}, + 'token': {'key': 'token', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'suggestions': {'key': 'suggestions', 'type': '[SpellingTokenSuggestion]'}, + 'ping_url_suffix': {'key': 'pingUrlSuffix', 'type': 'str'}, + } + + def __init__(self, offset, token, type="UnknownToken"): + self.offset = offset + self.token = token + self.type = type + self.suggestions = None + self.ping_url_suffix = None diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spelling_token_suggestion.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spelling_token_suggestion.py new file mode 100644 index 000000000000..459f7b356167 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/models/spelling_token_suggestion.py @@ -0,0 +1,44 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SpellingTokenSuggestion(Model): + """SpellingTokenSuggestion. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param suggestion: + :type suggestion: str + :ivar score: + :vartype score: float + :ivar ping_url_suffix: + :vartype ping_url_suffix: str + """ + + _validation = { + 'suggestion': {'required': True}, + 'score': {'readonly': True}, + 'ping_url_suffix': {'readonly': True}, + } + + _attribute_map = { + 'suggestion': {'key': 'suggestion', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + 'ping_url_suffix': {'key': 'pingUrlSuffix', 'type': 'str'}, + } + + def __init__(self, suggestion): + self.suggestion = suggestion + self.score = None + self.ping_url_suffix = None diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/spell_check_client.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/spell_check_client.py new file mode 100644 index 000000000000..25411c3e017c --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/spell_check_client.py @@ -0,0 +1,372 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import ServiceClient +from msrest import Configuration, Serializer, Deserializer +from .version import VERSION +from msrest.pipeline import ClientRawResponse +from . import models + + +class SpellCheckClientConfiguration(Configuration): + """Configuration for SpellCheckClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if not base_url: + base_url = 'https://api.cognitive.microsoft.com/bing/v7.0' + + super(SpellCheckClientConfiguration, self).__init__(base_url) + + self.add_user_agent('spellcheckclient/{}'.format(VERSION)) + + self.credentials = credentials + + +class SpellCheckClient(object): + """The Spell Check API lets you check a text string for spelling and grammar errors. + + :ivar config: Configuration for client. + :vartype config: SpellCheckClientConfiguration + + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + self.config = SpellCheckClientConfiguration(credentials, base_url) + self._client = ServiceClient(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '1.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + + def spell_check_method( + self, text, accept_language=None, pragma=None, user_agent=None, client_id=None, client_ip=None, location=None, action_type=None, app_name=None, country_code=None, client_machine_name=None, doc_id=None, market=None, session_id=None, set_lang=None, user_id=None, mode=None, pre_context_text=None, post_context_text=None, custom_headers=None, raw=False, **operation_config): + """The Bing Spell Check API lets you perform contextual grammar and spell + checking. Bing has developed a web-based spell-checker that leverages + machine learning and statistical machine translation to dynamically + train a constantly evolving and highly contextual algorithm. The + spell-checker is based on a massive corpus of web searches and + documents. + + :param text: The text string to check for spelling and grammar errors. + The combined length of the text string, preContextText string, and + postContextText string may not exceed 10,000 characters. You may + specify this parameter in the query string of a GET request or in the + body of a POST request. Because of the query string length limit, + you'll typically use a POST request unless you're checking only short + strings. + :type text: str + :param accept_language: A comma-delimited list of one or more + languages to use for user interface strings. The list is in decreasing + order of preference. For additional information, including expected + format, see + [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + This header and the setLang query parameter are mutually exclusive; do + not specify both. If you set this header, you must also specify the cc + query parameter. Bing will use the first supported language it finds + from the list, and combine that language with the cc parameter value + to determine the market to return results for. If the list does not + include a supported language, Bing will find the closest language and + market that supports the request, and may use an aggregated or default + market for the results instead of a specified one. You should use this + header and the cc query parameter only if you specify multiple + languages; otherwise, you should use the mkt and setLang query + parameters. A user interface string is a string that's used as a label + in a user interface. There are very few user interface strings in the + JSON response objects. Any links in the response objects to Bing.com + properties will apply the specified language. + :type accept_language: str + :param pragma: By default, Bing returns cached content, if available. + To prevent Bing from returning cached content, set the Pragma header + to no-cache (for example, Pragma: no-cache). + :type pragma: str + :param user_agent: The user agent originating the request. Bing uses + the user agent to provide mobile users with an optimized experience. + Although optional, you are strongly encouraged to always specify this + header. The user-agent should be the same string that any commonly + used browser would send. For information about user agents, see [RFC + 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + :type user_agent: str + :param client_id: Bing uses this header to provide users with + consistent behavior across Bing API calls. Bing often flights new + features and improvements, and it uses the client ID as a key for + assigning traffic on different flights. If you do not use the same + client ID for a user across multiple requests, then Bing may assign + the user to multiple conflicting flights. Being assigned to multiple + conflicting flights can lead to an inconsistent user experience. For + example, if the second request has a different flight assignment than + the first, the experience may be unexpected. Also, Bing can use the + client ID to tailor web results to that client ID’s search history, + providing a richer experience for the user. Bing also uses this header + to help improve result rankings by analyzing the activity generated by + a client ID. The relevance improvements help with better quality of + results delivered by Bing APIs and in turn enables higher + click-through rates for the API consumer. IMPORTANT: Although + optional, you should consider this header required. Persisting the + client ID across multiple requests for the same end user and device + combination enables 1) the API consumer to receive a consistent user + experience, and 2) higher click-through rates via better quality of + results from the Bing APIs. Each user that uses your application on + the device must have a unique, Bing generated client ID. If you do not + include this header in the request, Bing generates an ID and returns + it in the X-MSEdge-ClientID response header. The only time that you + should NOT include this header in a request is the first time the user + uses your app on that device. Use the client ID for each Bing API + request that your app makes for this user on the device. Persist the + client ID. To persist the ID in a browser app, use a persistent HTTP + cookie to ensure the ID is used across all sessions. Do not use a + session cookie. For other apps such as mobile apps, use the device's + persistent storage to persist the ID. The next time the user uses your + app on that device, get the client ID that you persisted. Bing + responses may or may not include this header. If the response includes + this header, capture the client ID and use it for all subsequent Bing + requests for the user on that device. If you include the + X-MSEdge-ClientID, you must not include cookies in the request. + :type client_id: str + :param client_ip: The IPv4 or IPv6 address of the client device. The + IP address is used to discover the user's location. Bing uses the + location information to determine safe search behavior. Although + optional, you are encouraged to always specify this header and the + X-Search-Location header. Do not obfuscate the address (for example, + by changing the last octet to 0). Obfuscating the address results in + the location not being anywhere near the device's actual location, + which may result in Bing serving erroneous results. + :type client_ip: str + :param location: A semicolon-delimited list of key/value pairs that + describe the client's geographical location. Bing uses the location + information to determine safe search behavior and to return relevant + local content. Specify the key/value pair as :. The + following are the keys that you use to specify the user's location. + lat (required): The latitude of the client's location, in degrees. The + latitude must be greater than or equal to -90.0 and less than or equal + to +90.0. Negative values indicate southern latitudes and positive + values indicate northern latitudes. long (required): The longitude of + the client's location, in degrees. The longitude must be greater than + or equal to -180.0 and less than or equal to +180.0. Negative values + indicate western longitudes and positive values indicate eastern + longitudes. re (required): The radius, in meters, which specifies the + horizontal accuracy of the coordinates. Pass the value returned by the + device's location service. Typical values might be 22m for GPS/Wi-Fi, + 380m for cell tower triangulation, and 18,000m for reverse IP lookup. + ts (optional): The UTC UNIX timestamp of when the client was at the + location. (The UNIX timestamp is the number of seconds since January + 1, 1970.) head (optional): The client's relative heading or direction + of travel. Specify the direction of travel as degrees from 0 through + 360, counting clockwise relative to true north. Specify this key only + if the sp key is nonzero. sp (optional): The horizontal velocity + (speed), in meters per second, that the client device is traveling. + alt (optional): The altitude of the client device, in meters. are + (optional): The radius, in meters, that specifies the vertical + accuracy of the coordinates. Specify this key only if you specify the + alt key. Although many of the keys are optional, the more information + that you provide, the more accurate the location results are. Although + optional, you are encouraged to always specify the user's geographical + location. Providing the location is especially important if the + client's IP address does not accurately reflect the user's physical + location (for example, if the client uses VPN). For optimal results, + you should include this header and the X-Search-ClientIP header, but + at a minimum, you should include this header. + :type location: str + :param action_type: A string that's used by logging to determine + whether the request is coming from an interactive session or a page + load. The following are the possible values. 1) Edit—The request is + from an interactive session 2) Load—The request is from a page load. + Possible values include: 'Edit', 'Load' + :type action_type: str or + ~azure.cognitiveservices.language.spellcheck.models.ActionType + :param app_name: The unique name of your app. The name must be known + by Bing. Do not include this parameter unless you have previously + contacted Bing to get a unique app name. To get a unique name, contact + your Bing Business Development manager. + :type app_name: str + :param country_code: A 2-character country code of the country where + the results come from. This API supports only the United States + market. If you specify this query parameter, it must be set to us. If + you set this parameter, you must also specify the Accept-Language + header. Bing uses the first supported language it finds from the + languages list, and combine that language with the country code that + you specify to determine the market to return results for. If the + languages list does not include a supported language, Bing finds the + closest language and market that supports the request, or it may use + an aggregated or default market for the results instead of a specified + one. You should use this query parameter and the Accept-Language query + parameter only if you specify multiple languages; otherwise, you + should use the mkt and setLang query parameters. This parameter and + the mkt query parameter are mutually exclusive—do not specify both. + :type country_code: str + :param client_machine_name: A unique name of the device that the + request is being made from. Generate a unique value for each device + (the value is unimportant). The service uses the ID to help debug + issues and improve the quality of corrections. + :type client_machine_name: str + :param doc_id: A unique ID that identifies the document that the text + belongs to. Generate a unique value for each document (the value is + unimportant). The service uses the ID to help debug issues and improve + the quality of corrections. + :type doc_id: str + :param market: The market where the results come from. You are + strongly encouraged to always specify the market, if known. Specifying + the market helps Bing route the request and return an appropriate and + optimal response. This parameter and the cc query parameter are + mutually exclusive—do not specify both. + :type market: str + :param session_id: A unique ID that identifies this user session. + Generate a unique value for each user session (the value is + unimportant). The service uses the ID to help debug issues and improve + the quality of corrections + :type session_id: str + :param set_lang: The language to use for user interface strings. + Specify the language using the ISO 639-1 2-letter language code. For + example, the language code for English is EN. The default is EN + (English). Although optional, you should always specify the language. + Typically, you set setLang to the same language specified by mkt + unless the user wants the user interface strings displayed in a + different language. This parameter and the Accept-Language header are + mutually exclusive—do not specify both. A user interface string is a + string that's used as a label in a user interface. There are few user + interface strings in the JSON response objects. Also, any links to + Bing.com properties in the response objects apply the specified + language. + :type set_lang: str + :param user_id: A unique ID that identifies the user. Generate a + unique value for each user (the value is unimportant). The service + uses the ID to help debug issues and improve the quality of + corrections. + :type user_id: str + :param mode: The type of spelling and grammar checks to perform. The + following are the possible values (the values are case insensitive). + The default is Proof. 1) Proof—Finds most spelling and grammar + mistakes. 2) Spell—Finds most spelling mistakes but does not find some + of the grammar errors that Proof catches (for example, capitalization + and repeated words). Possible values include: 'Proof', 'Spell' + :type mode: str or + ~azure.cognitiveservices.language.spellcheck.models.Mode + :param pre_context_text: A string that gives context to the text + string. For example, the text string petal is valid. However, if you + set preContextText to bike, the context changes and the text string + becomes not valid. In this case, the API suggests that you change + petal to pedal (as in bike pedal). This text is not checked for + grammar or spelling errors. The combined length of the text string, + preContextText string, and postContextText string may not exceed + 10,000 characters. You may specify this parameter in the query string + of a GET request or in the body of a POST request. + :type pre_context_text: str + :param post_context_text: A string that gives context to the text + string. For example, the text string read is valid. However, if you + set postContextText to carpet, the context changes and the text string + becomes not valid. In this case, the API suggests that you change read + to red (as in red carpet). This text is not checked for grammar or + spelling errors. The combined length of the text string, + preContextText string, and postContextText string may not exceed + 10,000 characters. You may specify this parameter in the query string + of a GET request or in the body of a POST request. + :type post_context_text: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SpellCheck or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.language.spellcheck.models.SpellCheck + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + x_bing_apis_sdk = "true" + + # Construct URL + url = '/spellcheck' + + # Construct parameters + query_parameters = {} + if action_type is not None: + query_parameters['ActionType'] = self._serialize.query("action_type", action_type, 'str') + if app_name is not None: + query_parameters['AppName'] = self._serialize.query("app_name", app_name, 'str') + if country_code is not None: + query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str') + if client_machine_name is not None: + query_parameters['ClientMachineName'] = self._serialize.query("client_machine_name", client_machine_name, 'str') + if doc_id is not None: + query_parameters['DocId'] = self._serialize.query("doc_id", doc_id, 'str') + if market is not None: + query_parameters['mkt'] = self._serialize.query("market", market, 'str') + if session_id is not None: + query_parameters['SessionId'] = self._serialize.query("session_id", session_id, 'str') + if set_lang is not None: + query_parameters['SetLang'] = self._serialize.query("set_lang", set_lang, 'str') + if user_id is not None: + query_parameters['UserId'] = self._serialize.query("user_id", user_id, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/x-www-form-urlencoded' + if custom_headers: + header_parameters.update(custom_headers) + header_parameters['X-BingApis-SDK'] = self._serialize.header("x_bing_apis_sdk", x_bing_apis_sdk, 'str') + if accept_language is not None: + header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str') + if pragma is not None: + header_parameters['Pragma'] = self._serialize.header("pragma", pragma, 'str') + if user_agent is not None: + header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str') + if client_id is not None: + header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str') + if client_ip is not None: + header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str') + if location is not None: + header_parameters['X-Search-Location'] = self._serialize.header("location", location, 'str') + + # Construct form data + form_data_content = { + 'Text': text, + 'Mode': mode, + 'PreContextText': pre_context_text, + 'PostContextText': post_context_text, + } + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send_formdata( + request, header_parameters, form_data_content, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SpellCheck', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized diff --git a/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/version.py b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/version.py new file mode 100644 index 000000000000..63d89bfb54fa --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/version.py @@ -0,0 +1,13 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0" + diff --git a/azure-cognitiveservices-language-spellcheck/azure_bdist_wheel.py b/azure-cognitiveservices-language-spellcheck/azure_bdist_wheel.py new file mode 100644 index 000000000000..61ec571a9743 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/azure_bdist_wheel.py @@ -0,0 +1,533 @@ +""" +"wheel" copyright (c) 2012-2017 Daniel Holth and +contributors. + +The MIT License + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Create a Azure wheel (.whl) distribution (a wheel is a built archive format). + +This file is a copy of the official bdist_wheel file from wheel 0.30.0a0, enhanced +of the bottom with some Microsoft extension for Azure SDK for Python + +""" + +import csv +import hashlib +import os +import subprocess +import warnings +import shutil +import json +import sys + +try: + import sysconfig +except ImportError: # pragma nocover + # Python < 2.7 + import distutils.sysconfig as sysconfig + +import pkg_resources + +safe_name = pkg_resources.safe_name +safe_version = pkg_resources.safe_version + +from shutil import rmtree +from email.generator import Generator + +from distutils.core import Command +from distutils.sysconfig import get_python_version + +from distutils import log as logger + +from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag, get_platform +from wheel.util import native, open_for_csv +from wheel.archive import archive_wheelfile +from wheel.pkginfo import read_pkg_info, write_pkg_info +from wheel.metadata import pkginfo_to_dict +from wheel import pep425tags, metadata +from wheel import __version__ as wheel_version + +def safer_name(name): + return safe_name(name).replace('-', '_') + +def safer_version(version): + return safe_version(version).replace('-', '_') + +class bdist_wheel(Command): + + description = 'create a wheel distribution' + + user_options = [('bdist-dir=', 'b', + "temporary directory for creating the distribution"), + ('plat-name=', 'p', + "platform name to embed in generated filenames " + "(default: %s)" % get_platform()), + ('keep-temp', 'k', + "keep the pseudo-installation tree around after " + + "creating the distribution archive"), + ('dist-dir=', 'd', + "directory to put final built distributions in"), + ('skip-build', None, + "skip rebuilding everything (for testing/debugging)"), + ('relative', None, + "build the archive using relative paths" + "(default: false)"), + ('owner=', 'u', + "Owner name used when creating a tar file" + " [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file" + " [default: current group]"), + ('universal', None, + "make a universal wheel" + " (default: false)"), + ('python-tag=', None, + "Python implementation compatibility tag" + " (default: py%s)" % get_impl_ver()[0]), + ] + + boolean_options = ['keep-temp', 'skip-build', 'relative', 'universal'] + + def initialize_options(self): + self.bdist_dir = None + self.data_dir = None + self.plat_name = None + self.plat_tag = None + self.format = 'zip' + self.keep_temp = False + self.dist_dir = None + self.distinfo_dir = None + self.egginfo_dir = None + self.root_is_pure = None + self.skip_build = None + self.relative = False + self.owner = None + self.group = None + self.universal = False + self.python_tag = 'py' + get_impl_ver()[0] + self.plat_name_supplied = False + + def finalize_options(self): + if self.bdist_dir is None: + bdist_base = self.get_finalized_command('bdist').bdist_base + self.bdist_dir = os.path.join(bdist_base, 'wheel') + + self.data_dir = self.wheel_dist_name + '.data' + self.plat_name_supplied = self.plat_name is not None + + need_options = ('dist_dir', 'plat_name', 'skip_build') + + self.set_undefined_options('bdist', + *zip(need_options, need_options)) + + self.root_is_pure = not (self.distribution.has_ext_modules() + or self.distribution.has_c_libraries()) + + # Support legacy [wheel] section for setting universal + wheel = self.distribution.get_option_dict('wheel') + if 'universal' in wheel: + # please don't define this in your global configs + val = wheel['universal'][1].strip() + if val.lower() in ('1', 'true', 'yes'): + self.universal = True + + @property + def wheel_dist_name(self): + """Return distribution full name with - replaced with _""" + return '-'.join((safer_name(self.distribution.get_name()), + safer_version(self.distribution.get_version()))) + + def get_tag(self): + # bdist sets self.plat_name if unset, we should only use it for purepy + # wheels if the user supplied it. + if self.plat_name_supplied: + plat_name = self.plat_name + elif self.root_is_pure: + plat_name = 'any' + else: + plat_name = self.plat_name or get_platform() + if plat_name in ('linux-x86_64', 'linux_x86_64') and sys.maxsize == 2147483647: + plat_name = 'linux_i686' + plat_name = plat_name.replace('-', '_').replace('.', '_') + + + if self.root_is_pure: + if self.universal: + impl = 'py2.py3' + else: + impl = self.python_tag + tag = (impl, 'none', plat_name) + else: + impl_name = get_abbr_impl() + impl_ver = get_impl_ver() + # PEP 3149 + abi_tag = str(get_abi_tag()).lower() + tag = (impl_name + impl_ver, abi_tag, plat_name) + supported_tags = pep425tags.get_supported( + supplied_platform=plat_name if self.plat_name_supplied else None) + # XXX switch to this alternate implementation for non-pure: + assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0]) + return tag + + def get_archive_basename(self): + """Return archive name without extension""" + + impl_tag, abi_tag, plat_tag = self.get_tag() + + archive_basename = "%s-%s-%s-%s" % ( + self.wheel_dist_name, + impl_tag, + abi_tag, + plat_tag) + return archive_basename + + def run(self): + build_scripts = self.reinitialize_command('build_scripts') + build_scripts.executable = 'python' + + if not self.skip_build: + self.run_command('build') + + install = self.reinitialize_command('install', + reinit_subcommands=True) + install.root = self.bdist_dir + install.compile = False + install.skip_build = self.skip_build + install.warn_dir = False + + # A wheel without setuptools scripts is more cross-platform. + # Use the (undocumented) `no_ep` option to setuptools' + # install_scripts command to avoid creating entry point scripts. + install_scripts = self.reinitialize_command('install_scripts') + install_scripts.no_ep = True + + # Use a custom scheme for the archive, because we have to decide + # at installation time which scheme to use. + for key in ('headers', 'scripts', 'data', 'purelib', 'platlib'): + setattr(install, + 'install_' + key, + os.path.join(self.data_dir, key)) + + basedir_observed = '' + + if os.name == 'nt': + # win32 barfs if any of these are ''; could be '.'? + # (distutils.command.install:change_roots bug) + basedir_observed = os.path.normpath(os.path.join(self.data_dir, '..')) + self.install_libbase = self.install_lib = basedir_observed + + setattr(install, + 'install_purelib' if self.root_is_pure else 'install_platlib', + basedir_observed) + + logger.info("installing to %s", self.bdist_dir) + + self.run_command('install') + + archive_basename = self.get_archive_basename() + + pseudoinstall_root = os.path.join(self.dist_dir, archive_basename) + if not self.relative: + archive_root = self.bdist_dir + else: + archive_root = os.path.join( + self.bdist_dir, + self._ensure_relative(install.install_base)) + + self.set_undefined_options( + 'install_egg_info', ('target', 'egginfo_dir')) + self.distinfo_dir = os.path.join(self.bdist_dir, + '%s.dist-info' % self.wheel_dist_name) + self.egg2dist(self.egginfo_dir, + self.distinfo_dir) + + self.write_wheelfile(self.distinfo_dir) + + self.write_record(self.bdist_dir, self.distinfo_dir) + + # Make the archive + if not os.path.exists(self.dist_dir): + os.makedirs(self.dist_dir) + wheel_name = archive_wheelfile(pseudoinstall_root, archive_root) + + # Sign the archive + if 'WHEEL_TOOL' in os.environ: + subprocess.call([os.environ['WHEEL_TOOL'], 'sign', wheel_name]) + + # Add to 'Distribution.dist_files' so that the "upload" command works + getattr(self.distribution, 'dist_files', []).append( + ('bdist_wheel', get_python_version(), wheel_name)) + + if not self.keep_temp: + if self.dry_run: + logger.info('removing %s', self.bdist_dir) + else: + rmtree(self.bdist_dir) + + def write_wheelfile(self, wheelfile_base, generator='bdist_wheel (' + wheel_version + ')'): + from email.message import Message + msg = Message() + msg['Wheel-Version'] = '1.0' # of the spec + msg['Generator'] = generator + msg['Root-Is-Purelib'] = str(self.root_is_pure).lower() + + # Doesn't work for bdist_wininst + impl_tag, abi_tag, plat_tag = self.get_tag() + for impl in impl_tag.split('.'): + for abi in abi_tag.split('.'): + for plat in plat_tag.split('.'): + msg['Tag'] = '-'.join((impl, abi, plat)) + + wheelfile_path = os.path.join(wheelfile_base, 'WHEEL') + logger.info('creating %s', wheelfile_path) + with open(wheelfile_path, 'w') as f: + Generator(f, maxheaderlen=0).flatten(msg) + + def _ensure_relative(self, path): + # copied from dir_util, deleted + drive, path = os.path.splitdrive(path) + if path[0:1] == os.sep: + path = drive + path[1:] + return path + + def _pkginfo_to_metadata(self, egg_info_path, pkginfo_path): + return metadata.pkginfo_to_metadata(egg_info_path, pkginfo_path) + + def license_file(self): + """Return license filename from a license-file key in setup.cfg, or None.""" + metadata = self.distribution.get_option_dict('metadata') + if not 'license_file' in metadata: + return None + return metadata['license_file'][1] + + def setupcfg_requirements(self): + """Generate requirements from setup.cfg as + ('Requires-Dist', 'requirement; qualifier') tuples. From a metadata + section in setup.cfg: + + [metadata] + provides-extra = extra1 + extra2 + requires-dist = requirement; qualifier + another; qualifier2 + unqualified + + Yields + + ('Provides-Extra', 'extra1'), + ('Provides-Extra', 'extra2'), + ('Requires-Dist', 'requirement; qualifier'), + ('Requires-Dist', 'another; qualifier2'), + ('Requires-Dist', 'unqualified') + """ + metadata = self.distribution.get_option_dict('metadata') + + # our .ini parser folds - to _ in key names: + for key, title in (('provides_extra', 'Provides-Extra'), + ('requires_dist', 'Requires-Dist')): + if not key in metadata: + continue + field = metadata[key] + for line in field[1].splitlines(): + line = line.strip() + if not line: + continue + yield (title, line) + + def add_requirements(self, metadata_path): + """Add additional requirements from setup.cfg to file metadata_path""" + additional = list(self.setupcfg_requirements()) + if not additional: return + pkg_info = read_pkg_info(metadata_path) + if 'Provides-Extra' in pkg_info or 'Requires-Dist' in pkg_info: + warnings.warn('setup.cfg requirements overwrite values from setup.py') + del pkg_info['Provides-Extra'] + del pkg_info['Requires-Dist'] + for k, v in additional: + pkg_info[k] = v + write_pkg_info(metadata_path, pkg_info) + + def egg2dist(self, egginfo_path, distinfo_path): + """Convert an .egg-info directory into a .dist-info directory""" + def adios(p): + """Appropriately delete directory, file or link.""" + if os.path.exists(p) and not os.path.islink(p) and os.path.isdir(p): + shutil.rmtree(p) + elif os.path.exists(p): + os.unlink(p) + + adios(distinfo_path) + + if not os.path.exists(egginfo_path): + # There is no egg-info. This is probably because the egg-info + # file/directory is not named matching the distribution name used + # to name the archive file. Check for this case and report + # accordingly. + import glob + pat = os.path.join(os.path.dirname(egginfo_path), '*.egg-info') + possible = glob.glob(pat) + err = "Egg metadata expected at %s but not found" % (egginfo_path,) + if possible: + alt = os.path.basename(possible[0]) + err += " (%s found - possible misnamed archive file?)" % (alt,) + + raise ValueError(err) + + if os.path.isfile(egginfo_path): + # .egg-info is a single file + pkginfo_path = egginfo_path + pkg_info = self._pkginfo_to_metadata(egginfo_path, egginfo_path) + os.mkdir(distinfo_path) + else: + # .egg-info is a directory + pkginfo_path = os.path.join(egginfo_path, 'PKG-INFO') + pkg_info = self._pkginfo_to_metadata(egginfo_path, pkginfo_path) + + # ignore common egg metadata that is useless to wheel + shutil.copytree(egginfo_path, distinfo_path, + ignore=lambda x, y: set(('PKG-INFO', + 'requires.txt', + 'SOURCES.txt', + 'not-zip-safe',))) + + # delete dependency_links if it is only whitespace + dependency_links_path = os.path.join(distinfo_path, 'dependency_links.txt') + with open(dependency_links_path, 'r') as dependency_links_file: + dependency_links = dependency_links_file.read().strip() + if not dependency_links: + adios(dependency_links_path) + + write_pkg_info(os.path.join(distinfo_path, 'METADATA'), pkg_info) + + # XXX deprecated. Still useful for current distribute/setuptools. + metadata_path = os.path.join(distinfo_path, 'METADATA') + self.add_requirements(metadata_path) + + # XXX intentionally a different path than the PEP. + metadata_json_path = os.path.join(distinfo_path, 'metadata.json') + pymeta = pkginfo_to_dict(metadata_path, + distribution=self.distribution) + + if 'description' in pymeta: + description_filename = 'DESCRIPTION.rst' + description_text = pymeta.pop('description') + description_path = os.path.join(distinfo_path, + description_filename) + with open(description_path, "wb") as description_file: + description_file.write(description_text.encode('utf-8')) + pymeta['extensions']['python.details']['document_names']['description'] = description_filename + + # XXX heuristically copy any LICENSE/LICENSE.txt? + license = self.license_file() + if license: + license_filename = 'LICENSE.txt' + shutil.copy(license, os.path.join(self.distinfo_dir, license_filename)) + pymeta['extensions']['python.details']['document_names']['license'] = license_filename + + with open(metadata_json_path, "w") as metadata_json: + json.dump(pymeta, metadata_json, sort_keys=True) + + adios(egginfo_path) + + def write_record(self, bdist_dir, distinfo_dir): + from wheel.util import urlsafe_b64encode + + record_path = os.path.join(distinfo_dir, 'RECORD') + record_relpath = os.path.relpath(record_path, bdist_dir) + + def walk(): + for dir, dirs, files in os.walk(bdist_dir): + dirs.sort() + for f in sorted(files): + yield os.path.join(dir, f) + + def skip(path): + """Wheel hashes every possible file.""" + return (path == record_relpath) + + with open_for_csv(record_path, 'w+') as record_file: + writer = csv.writer(record_file) + for path in walk(): + relpath = os.path.relpath(path, bdist_dir) + if skip(relpath): + hash = '' + size = '' + else: + with open(path, 'rb') as f: + data = f.read() + digest = hashlib.sha256(data).digest() + hash = 'sha256=' + native(urlsafe_b64encode(digest)) + size = len(data) + record_path = os.path.relpath( + path, bdist_dir).replace(os.path.sep, '/') + writer.writerow((record_path, hash, size)) + + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +from distutils import log as logger +import os.path + +#from wheel.bdist_wheel import bdist_wheel +class azure_bdist_wheel(bdist_wheel): + + description = "Create an Azure wheel distribution" + + user_options = bdist_wheel.user_options + \ + [('azure-namespace-package=', None, + "Name of the deepest nspkg used")] + + def initialize_options(self): + bdist_wheel.initialize_options(self) + self.azure_namespace_package = None + + def finalize_options(self): + bdist_wheel.finalize_options(self) + if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): + raise ValueError("azure_namespace_package must finish by -nspkg") + + def run(self): + if not self.distribution.install_requires: + self.distribution.install_requires = [] + self.distribution.install_requires.append( + "{}>=2.0.0".format(self.azure_namespace_package)) + bdist_wheel.run(self) + + def write_record(self, bdist_dir, distinfo_dir): + if self.azure_namespace_package: + # Split and remove last part, assuming it's "nspkg" + subparts = self.azure_namespace_package.split('-')[0:-1] + folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] + for azure_sub_package in folder_with_init: + init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') + if os.path.isfile(init_file): + logger.info("manually remove {} while building the wheel".format(init_file)) + os.remove(init_file) + else: + raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) + bdist_wheel.write_record(self, bdist_dir, distinfo_dir) +cmdclass = { + 'bdist_wheel': azure_bdist_wheel, +} diff --git a/azure-cognitiveservices-language-spellcheck/setup.cfg b/azure-cognitiveservices-language-spellcheck/setup.cfg new file mode 100644 index 000000000000..2d986195ea2f --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/setup.cfg @@ -0,0 +1,3 @@ +[bdist_wheel] +universal=1 +azure-namespace-package=azure-cognitiveservices-language-nspkg \ No newline at end of file diff --git a/azure-cognitiveservices-language-spellcheck/setup.py b/azure-cognitiveservices-language-spellcheck/setup.py new file mode 100644 index 000000000000..ef8169030e56 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/setup.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + cmdclass = {} + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-cognitiveservices-language-spellcheck" +PACKAGE_PPRINT_NAME = "Cognitive Services Bing Spell Check" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.rst', encoding='utf-8') as f: + readme = f.read() +with open('HISTORY.rst', encoding='utf-8') as f: + history = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + history, + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=["tests"]), + install_requires=[ + 'msrestazure~=0.4.11', + 'azure-common~=1.1', + ], + cmdclass=cmdclass +) diff --git a/azure-cognitiveservices-language-spellcheck/tests/recordings/test_spell_check.yaml b/azure-cognitiveservices-language-spellcheck/tests/recordings/test_spell_check.yaml new file mode 100644 index 000000000000..af4d4b431329 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/tests/recordings/test_spell_check.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: Text=cognituve+services + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['23'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 + spellcheckclient/1.0] + X-BingApis-SDK: ['true'] + X-BingApis-SDK-Client: [Python-SDK] + method: POST + uri: https://api.cognitive.microsoft.com/bing/v7.0/spellcheck + response: + body: {string: '{"_type": "SpellCheck", "flaggedTokens": [{"_type": "Spelling\/FlaggedToken", + "offset": 0, "token": "cognituve", "type": "UnknownToken", "suggestions": + [{"_type": "Spelling\/TokenSuggestion", "suggestion": "cognitive", "score": + 0.915075214584365}]}]}'} + headers: + apim-request-id: [c4d7b44b-f972-4ec7-bcdc-0dd019b2acbe] + bingapis-market: [en-US] + bingapis-sessionid: [84009F6285D1484086085CD9FD732E90] + bingapis-traceid: [2CF1E3DE37A04721A0ADA6B35CF9E1E8] + cache-control: ['private, max-age=0'] + content-length: ['250'] + content-type: [application/json; charset=utf-8] + date: ['Mon, 20 Nov 2017 20:55:38 GMT'] + expires: ['Mon, 20 Nov 2017 20:54:37 GMT'] + p3p: [CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains; preload] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + x-msapi-userstate: ['3351'] + x-msedge-clientid: [1C7E931A81676C502F9B985A80F06DB7] + x-msedge-ref: ['Ref A: 2CF1E3DE37A04721A0ADA6B35CF9E1E8 Ref B: CO1EDGE0306 Ref + C: 2017-11-20T20:55:37Z'] + status: {code: 200, message: OK} +version: 1 diff --git a/azure-cognitiveservices-language-spellcheck/tests/test_spell_check.py b/azure-cognitiveservices-language-spellcheck/tests/test_spell_check.py new file mode 100644 index 000000000000..db1fa84a8566 --- /dev/null +++ b/azure-cognitiveservices-language-spellcheck/tests/test_spell_check.py @@ -0,0 +1,56 @@ +# 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. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from azure.cognitiveservices.language.spellcheck import SpellCheckClient +from msrest.authentication import CognitiveServicesCredentials + +from azure_devtools.scenario_tests import ReplayableTest, AzureTestError + +from devtools_testutils import mgmt_settings_fake as fake_settings + + +class SpellCheckTest(ReplayableTest): + FILTER_HEADERS = ReplayableTest.FILTER_HEADERS + ['Ocp-Apim-Subscription-Key'] + + def __init__(self, method_name): + self._fake_settings, self._real_settings = self._load_settings() + super(SpellCheckTest, self).__init__(method_name) + + @property + def settings(self): + if self.is_live: + if self._real_settings: + return self._real_settings + else: + raise AzureTestError('Need a mgmt_settings_real.py file to run tests live.') + else: + return self._fake_settings + + def _load_settings(self): + try: + from devtools_testutils import mgmt_settings_real as real_settings + return fake_settings, real_settings + except ImportError: + return fake_settings, None + + def test_spell_check(self): + credentials = CognitiveServicesCredentials( + self.settings.CS_SUBSCRIPTION_KEY + ) + text_analytics = SpellCheckClient(credentials=credentials) + response = text_analytics.spell_check_method( + "cognituve services" + ) + self.assertEquals(response.flagged_tokens[0].token, "cognituve") + self.assertEquals(response.flagged_tokens[0].suggestions[0].suggestion, "cognitive") + + + diff --git a/swagger_to_sdk_config.json b/swagger_to_sdk_config.json index d80c0380eb59..8440cb9e703e 100644 --- a/swagger_to_sdk_config.json +++ b/swagger_to_sdk_config.json @@ -95,6 +95,18 @@ "generated_relative_base_directory": "azure/cognitiveservices/language/textanalytics", "build_dir": "azure-cognitiveservices-language-textanalytics/azure/cognitiveservices/language/textanalytics" }, + "cognitiveservices.language.spellcheck": { + "markdown": "specification/cognitiveservices/data-plane/SpellCheck/readme.md", + "autorest_options": { + "namespace": "azure.cognitiveservices.language.spellcheck", + "add-credentials": true, + "azure-arm": false, + "title": "SpellCheckClient" + }, + "output_dir": "azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck", + "generated_relative_base_directory": "azure/cognitiveservices/language/spellcheck", + "build_dir": "azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck" + }, "cognitiveservices.search.entitysearch": { "markdown": "specification/cognitiveservices/data-plane/EntitySearch/readme.md", "autorest_options": {