azure_cognitiveservices_spellcheck 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck.rb +41 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/action_type.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/answer.rb +60 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/error.rb +116 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/error_code.rb +20 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/error_response.rb +80 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/error_sub_code.rb +25 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/error_type.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/identifiable.rb +62 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/mode.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/response.rb +60 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/response_base.rb +51 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/spell_check.rb +80 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/spelling_flagged_token.rb +104 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/models/spelling_token_suggestion.rb +71 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/module_definition.rb +9 -0
- data/lib/1.0/generated/azure_cognitiveservices_spellcheck/spell_check_client.rb +776 -0
- data/lib/azure_cognitiveservices_spellcheck.rb +6 -0
- data/lib/module_definition.rb +7 -0
- data/lib/profiles/latest/modules/spellcheck_profile_module.rb +113 -0
- data/lib/profiles/latest/spellcheck_latest_profile_client.rb +38 -0
- data/lib/profiles/latest/spellcheck_module_definition.rb +8 -0
- data/lib/version.rb +7 -0
- metadata +143 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::SpellCheck::V1_0
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Defines values for Mode
|
10
|
+
#
|
11
|
+
module Mode
|
12
|
+
Proof = "Proof"
|
13
|
+
Spell = "Spell"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::SpellCheck::V1_0
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Defines a response. All schemas that could be returned at the root of a
|
10
|
+
# response should inherit from this
|
11
|
+
#
|
12
|
+
class Response < Identifiable
|
13
|
+
|
14
|
+
include MsRestAzure
|
15
|
+
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@_type = "Response"
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_accessor :_type
|
22
|
+
|
23
|
+
|
24
|
+
#
|
25
|
+
# Mapper for Response class as Ruby Hash.
|
26
|
+
# This will be used for serialization/deserialization.
|
27
|
+
#
|
28
|
+
def self.mapper()
|
29
|
+
{
|
30
|
+
client_side_validation: true,
|
31
|
+
required: false,
|
32
|
+
serialized_name: 'Response',
|
33
|
+
type: {
|
34
|
+
name: 'Composite',
|
35
|
+
class_name: 'Response',
|
36
|
+
model_properties: {
|
37
|
+
_type: {
|
38
|
+
client_side_validation: true,
|
39
|
+
required: true,
|
40
|
+
serialized_name: '_type',
|
41
|
+
type: {
|
42
|
+
name: 'String'
|
43
|
+
}
|
44
|
+
},
|
45
|
+
id: {
|
46
|
+
client_side_validation: true,
|
47
|
+
required: false,
|
48
|
+
read_only: true,
|
49
|
+
serialized_name: 'id',
|
50
|
+
type: {
|
51
|
+
name: 'String'
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::SpellCheck::V1_0
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Model object.
|
10
|
+
#
|
11
|
+
#
|
12
|
+
class ResponseBase
|
13
|
+
|
14
|
+
include MsRestAzure
|
15
|
+
|
16
|
+
@@discriminatorMap = Hash.new
|
17
|
+
@@discriminatorMap["SpellCheck"] = "SpellCheck"
|
18
|
+
@@discriminatorMap["Answer"] = "Answer"
|
19
|
+
@@discriminatorMap["Response"] = "Response"
|
20
|
+
@@discriminatorMap["Identifiable"] = "Identifiable"
|
21
|
+
@@discriminatorMap["ErrorResponse"] = "ErrorResponse"
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@_type = "ResponseBase"
|
25
|
+
end
|
26
|
+
|
27
|
+
attr_accessor :_type
|
28
|
+
|
29
|
+
|
30
|
+
#
|
31
|
+
# Mapper for ResponseBase class as Ruby Hash.
|
32
|
+
# This will be used for serialization/deserialization.
|
33
|
+
#
|
34
|
+
def self.mapper()
|
35
|
+
{
|
36
|
+
client_side_validation: true,
|
37
|
+
required: false,
|
38
|
+
serialized_name: 'ResponseBase',
|
39
|
+
type: {
|
40
|
+
name: 'Composite',
|
41
|
+
polymorphic_discriminator: '_type',
|
42
|
+
uber_parent: 'ResponseBase',
|
43
|
+
class_name: 'ResponseBase',
|
44
|
+
model_properties: {
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::SpellCheck::V1_0
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Model object.
|
10
|
+
#
|
11
|
+
#
|
12
|
+
class SpellCheck < Answer
|
13
|
+
|
14
|
+
include MsRestAzure
|
15
|
+
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@_type = "SpellCheck"
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_accessor :_type
|
22
|
+
|
23
|
+
# @return [Array<SpellingFlaggedToken>]
|
24
|
+
attr_accessor :flagged_tokens
|
25
|
+
|
26
|
+
|
27
|
+
#
|
28
|
+
# Mapper for SpellCheck class as Ruby Hash.
|
29
|
+
# This will be used for serialization/deserialization.
|
30
|
+
#
|
31
|
+
def self.mapper()
|
32
|
+
{
|
33
|
+
client_side_validation: true,
|
34
|
+
required: false,
|
35
|
+
serialized_name: 'SpellCheck',
|
36
|
+
type: {
|
37
|
+
name: 'Composite',
|
38
|
+
class_name: 'SpellCheck',
|
39
|
+
model_properties: {
|
40
|
+
_type: {
|
41
|
+
client_side_validation: true,
|
42
|
+
required: true,
|
43
|
+
serialized_name: '_type',
|
44
|
+
type: {
|
45
|
+
name: 'String'
|
46
|
+
}
|
47
|
+
},
|
48
|
+
id: {
|
49
|
+
client_side_validation: true,
|
50
|
+
required: false,
|
51
|
+
read_only: true,
|
52
|
+
serialized_name: 'id',
|
53
|
+
type: {
|
54
|
+
name: 'String'
|
55
|
+
}
|
56
|
+
},
|
57
|
+
flagged_tokens: {
|
58
|
+
client_side_validation: true,
|
59
|
+
required: true,
|
60
|
+
serialized_name: 'flaggedTokens',
|
61
|
+
type: {
|
62
|
+
name: 'Sequence',
|
63
|
+
element: {
|
64
|
+
client_side_validation: true,
|
65
|
+
required: false,
|
66
|
+
serialized_name: 'SpellingFlaggedTokenElementType',
|
67
|
+
type: {
|
68
|
+
name: 'Composite',
|
69
|
+
class_name: 'SpellingFlaggedToken'
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::SpellCheck::V1_0
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Model object.
|
10
|
+
#
|
11
|
+
#
|
12
|
+
class SpellingFlaggedToken
|
13
|
+
|
14
|
+
include MsRestAzure
|
15
|
+
|
16
|
+
# @return [Integer]
|
17
|
+
attr_accessor :offset
|
18
|
+
|
19
|
+
# @return [String]
|
20
|
+
attr_accessor :token
|
21
|
+
|
22
|
+
# @return [ErrorType] Possible values include: 'UnknownToken',
|
23
|
+
# 'RepeatedToken'. Default value: 'UnknownToken' .
|
24
|
+
attr_accessor :type
|
25
|
+
|
26
|
+
# @return [Array<SpellingTokenSuggestion>]
|
27
|
+
attr_accessor :suggestions
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
attr_accessor :ping_url_suffix
|
31
|
+
|
32
|
+
|
33
|
+
#
|
34
|
+
# Mapper for SpellingFlaggedToken class as Ruby Hash.
|
35
|
+
# This will be used for serialization/deserialization.
|
36
|
+
#
|
37
|
+
def self.mapper()
|
38
|
+
{
|
39
|
+
client_side_validation: true,
|
40
|
+
required: false,
|
41
|
+
serialized_name: 'Spelling/FlaggedToken',
|
42
|
+
type: {
|
43
|
+
name: 'Composite',
|
44
|
+
class_name: 'SpellingFlaggedToken',
|
45
|
+
model_properties: {
|
46
|
+
offset: {
|
47
|
+
client_side_validation: true,
|
48
|
+
required: true,
|
49
|
+
serialized_name: 'offset',
|
50
|
+
type: {
|
51
|
+
name: 'Number'
|
52
|
+
}
|
53
|
+
},
|
54
|
+
token: {
|
55
|
+
client_side_validation: true,
|
56
|
+
required: true,
|
57
|
+
serialized_name: 'token',
|
58
|
+
type: {
|
59
|
+
name: 'String'
|
60
|
+
}
|
61
|
+
},
|
62
|
+
type: {
|
63
|
+
client_side_validation: true,
|
64
|
+
required: true,
|
65
|
+
serialized_name: 'type',
|
66
|
+
default_value: 'UnknownToken',
|
67
|
+
type: {
|
68
|
+
name: 'String'
|
69
|
+
}
|
70
|
+
},
|
71
|
+
suggestions: {
|
72
|
+
client_side_validation: true,
|
73
|
+
required: false,
|
74
|
+
read_only: true,
|
75
|
+
serialized_name: 'suggestions',
|
76
|
+
type: {
|
77
|
+
name: 'Sequence',
|
78
|
+
element: {
|
79
|
+
client_side_validation: true,
|
80
|
+
required: false,
|
81
|
+
serialized_name: 'SpellingTokenSuggestionElementType',
|
82
|
+
type: {
|
83
|
+
name: 'Composite',
|
84
|
+
class_name: 'SpellingTokenSuggestion'
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
ping_url_suffix: {
|
90
|
+
client_side_validation: true,
|
91
|
+
required: false,
|
92
|
+
read_only: true,
|
93
|
+
serialized_name: 'pingUrlSuffix',
|
94
|
+
type: {
|
95
|
+
name: 'String'
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::SpellCheck::V1_0
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Model object.
|
10
|
+
#
|
11
|
+
#
|
12
|
+
class SpellingTokenSuggestion
|
13
|
+
|
14
|
+
include MsRestAzure
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :suggestion
|
18
|
+
|
19
|
+
# @return [Float]
|
20
|
+
attr_accessor :score
|
21
|
+
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :ping_url_suffix
|
24
|
+
|
25
|
+
|
26
|
+
#
|
27
|
+
# Mapper for SpellingTokenSuggestion class as Ruby Hash.
|
28
|
+
# This will be used for serialization/deserialization.
|
29
|
+
#
|
30
|
+
def self.mapper()
|
31
|
+
{
|
32
|
+
client_side_validation: true,
|
33
|
+
required: false,
|
34
|
+
serialized_name: 'Spelling/TokenSuggestion',
|
35
|
+
type: {
|
36
|
+
name: 'Composite',
|
37
|
+
class_name: 'SpellingTokenSuggestion',
|
38
|
+
model_properties: {
|
39
|
+
suggestion: {
|
40
|
+
client_side_validation: true,
|
41
|
+
required: true,
|
42
|
+
serialized_name: 'suggestion',
|
43
|
+
type: {
|
44
|
+
name: 'String'
|
45
|
+
}
|
46
|
+
},
|
47
|
+
score: {
|
48
|
+
client_side_validation: true,
|
49
|
+
required: false,
|
50
|
+
read_only: true,
|
51
|
+
serialized_name: 'score',
|
52
|
+
type: {
|
53
|
+
name: 'Double'
|
54
|
+
}
|
55
|
+
},
|
56
|
+
ping_url_suffix: {
|
57
|
+
client_side_validation: true,
|
58
|
+
required: false,
|
59
|
+
read_only: true,
|
60
|
+
serialized_name: 'pingUrlSuffix',
|
61
|
+
type: {
|
62
|
+
name: 'String'
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure end
|
7
|
+
module Azure::CognitiveServices end
|
8
|
+
module Azure::CognitiveServices::SpellCheck end
|
9
|
+
module Azure::CognitiveServices::SpellCheck::V1_0 end
|
@@ -0,0 +1,776 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::SpellCheck::V1_0
|
7
|
+
#
|
8
|
+
# A service client - single point of access to the REST API.
|
9
|
+
#
|
10
|
+
class SpellCheckClient < MsRestAzure::AzureServiceClient
|
11
|
+
include MsRestAzure
|
12
|
+
include MsRestAzure::Serialization
|
13
|
+
|
14
|
+
# @return [String] the base URI of the service.
|
15
|
+
attr_accessor :base_url
|
16
|
+
|
17
|
+
# @return Credentials needed for the client to connect to Azure.
|
18
|
+
attr_reader :credentials1
|
19
|
+
|
20
|
+
# @return Subscription credentials which uniquely identify client
|
21
|
+
# subscription.
|
22
|
+
attr_accessor :credentials
|
23
|
+
|
24
|
+
# @return [String] Gets or sets the preferred language for the response.
|
25
|
+
attr_accessor :accept_language
|
26
|
+
|
27
|
+
# @return [Integer] Gets or sets the retry timeout in seconds for Long
|
28
|
+
# Running Operations. Default value is 30.
|
29
|
+
attr_accessor :long_running_operation_retry_timeout
|
30
|
+
|
31
|
+
# @return [Boolean] When set to true a unique x-ms-client-request-id value
|
32
|
+
# is generated and included in each request. Default is true.
|
33
|
+
attr_accessor :generate_client_request_id
|
34
|
+
|
35
|
+
#
|
36
|
+
# Creates initializes a new instance of the SpellCheckClient class.
|
37
|
+
# @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
|
38
|
+
# @param base_url [String] the base URI of the service.
|
39
|
+
# @param options [Array] filters to be applied to the HTTP requests.
|
40
|
+
#
|
41
|
+
def initialize(credentials = nil, base_url = nil, options = nil)
|
42
|
+
super(credentials, options)
|
43
|
+
@base_url = base_url || 'https://api.cognitive.microsoft.com/bing/v7.0'
|
44
|
+
|
45
|
+
fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
|
46
|
+
@credentials = credentials
|
47
|
+
|
48
|
+
@accept_language = 'en-US'
|
49
|
+
@long_running_operation_retry_timeout = 30
|
50
|
+
@generate_client_request_id = true
|
51
|
+
add_telemetry
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Makes a request and returns the body of the response.
|
56
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
57
|
+
# @param path [String] the path, relative to {base_url}.
|
58
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
59
|
+
# @return [Hash{String=>String}] containing the body of the response.
|
60
|
+
# Example:
|
61
|
+
#
|
62
|
+
# request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
|
63
|
+
# path = "/path"
|
64
|
+
# options = {
|
65
|
+
# body: request_content,
|
66
|
+
# query_params: {'api-version' => '2016-02-01'}
|
67
|
+
# }
|
68
|
+
# result = @client.make_request(:put, path, options)
|
69
|
+
#
|
70
|
+
def make_request(method, path, options = {})
|
71
|
+
result = make_request_with_http_info(method, path, options)
|
72
|
+
result.body unless result.nil?
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Makes a request and returns the operation response.
|
77
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
78
|
+
# @param path [String] the path, relative to {base_url}.
|
79
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
80
|
+
# @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
|
81
|
+
#
|
82
|
+
def make_request_with_http_info(method, path, options = {})
|
83
|
+
result = make_request_async(method, path, options).value!
|
84
|
+
result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
|
85
|
+
result
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# Makes a request asynchronously.
|
90
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
91
|
+
# @param path [String] the path, relative to {base_url}.
|
92
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
93
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
94
|
+
#
|
95
|
+
def make_request_async(method, path, options = {})
|
96
|
+
fail ArgumentError, 'method is nil' if method.nil?
|
97
|
+
fail ArgumentError, 'path is nil' if path.nil?
|
98
|
+
|
99
|
+
request_url = options[:base_url] || @base_url
|
100
|
+
if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
|
101
|
+
@request_headers['Content-Type'] = options[:headers]['Content-Type']
|
102
|
+
end
|
103
|
+
|
104
|
+
request_headers = @request_headers
|
105
|
+
request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
|
106
|
+
options.merge!({headers: request_headers.merge(options[:headers] || {})})
|
107
|
+
options.merge!({credentials: @credentials}) unless @credentials.nil?
|
108
|
+
|
109
|
+
super(request_url, method, path, options)
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# The Bing Spell Check API lets you perform contextual grammar and spell
|
114
|
+
# checking. Bing has developed a web-based spell-checker that leverages machine
|
115
|
+
# learning and statistical machine translation to dynamically train a
|
116
|
+
# constantly evolving and highly contextual algorithm. The spell-checker is
|
117
|
+
# based on a massive corpus of web searches and documents.
|
118
|
+
#
|
119
|
+
# @param text [String] The text string to check for spelling and grammar
|
120
|
+
# errors. The combined length of the text string, preContextText string, and
|
121
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
122
|
+
# parameter in the query string of a GET request or in the body of a POST
|
123
|
+
# request. Because of the query string length limit, you'll typically use a
|
124
|
+
# POST request unless you're checking only short strings.
|
125
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
126
|
+
# languages to use for user interface strings. The list is in decreasing order
|
127
|
+
# of preference. For additional information, including expected format, see
|
128
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
129
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
130
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
131
|
+
# Bing will use the first supported language it finds from the list, and
|
132
|
+
# combine that language with the cc parameter value to determine the market to
|
133
|
+
# return results for. If the list does not include a supported language, Bing
|
134
|
+
# will find the closest language and market that supports the request, and may
|
135
|
+
# use an aggregated or default market for the results instead of a specified
|
136
|
+
# one. You should use this header and the cc query parameter only if you
|
137
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
138
|
+
# query parameters. A user interface string is a string that's used as a label
|
139
|
+
# in a user interface. There are very few user interface strings in the JSON
|
140
|
+
# response objects. Any links in the response objects to Bing.com properties
|
141
|
+
# will apply the specified language.
|
142
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
143
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
144
|
+
# no-cache (for example, Pragma: no-cache).
|
145
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
146
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
147
|
+
# optional, you are strongly encouraged to always specify this header. The
|
148
|
+
# user-agent should be the same string that any commonly used browser would
|
149
|
+
# send. For information about user agents, see [RFC
|
150
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
151
|
+
# @param client_id [String] Bing uses this header to provide users with
|
152
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
153
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
154
|
+
# different flights. If you do not use the same client ID for a user across
|
155
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
156
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
157
|
+
# inconsistent user experience. For example, if the second request has a
|
158
|
+
# different flight assignment than the first, the experience may be unexpected.
|
159
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
160
|
+
# search history, providing a richer experience for the user. Bing also uses
|
161
|
+
# this header to help improve result rankings by analyzing the activity
|
162
|
+
# generated by a client ID. The relevance improvements help with better quality
|
163
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
164
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
165
|
+
# this header required. Persisting the client ID across multiple requests for
|
166
|
+
# the same end user and device combination enables 1) the API consumer to
|
167
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
168
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
169
|
+
# application on the device must have a unique, Bing generated client ID. If
|
170
|
+
# you do not include this header in the request, Bing generates an ID and
|
171
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
172
|
+
# should NOT include this header in a request is the first time the user uses
|
173
|
+
# your app on that device. Use the client ID for each Bing API request that
|
174
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
175
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
176
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
177
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
178
|
+
# time the user uses your app on that device, get the client ID that you
|
179
|
+
# persisted. Bing responses may or may not include this header. If the response
|
180
|
+
# includes this header, capture the client ID and use it for all subsequent
|
181
|
+
# Bing requests for the user on that device. If you include the
|
182
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
183
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
184
|
+
# IP address is used to discover the user's location. Bing uses the location
|
185
|
+
# information to determine safe search behavior. Although optional, you are
|
186
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
187
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
188
|
+
# Obfuscating the address results in the location not being anywhere near the
|
189
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
190
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
191
|
+
# describe the client's geographical location. Bing uses the location
|
192
|
+
# information to determine safe search behavior and to return relevant local
|
193
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
194
|
+
# keys that you use to specify the user's location. lat (required): The
|
195
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
196
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
197
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
198
|
+
# long (required): The longitude of the client's location, in degrees. The
|
199
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
200
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
201
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
202
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
203
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
204
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
205
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
206
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
207
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
208
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
209
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
210
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
211
|
+
# client device is traveling. alt (optional): The altitude of the client
|
212
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
213
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
214
|
+
# the alt key. Although many of the keys are optional, the more information
|
215
|
+
# that you provide, the more accurate the location results are. Although
|
216
|
+
# optional, you are encouraged to always specify the user's geographical
|
217
|
+
# location. Providing the location is especially important if the client's IP
|
218
|
+
# address does not accurately reflect the user's physical location (for
|
219
|
+
# example, if the client uses VPN). For optimal results, you should include
|
220
|
+
# this header and the X-Search-ClientIP header, but at a minimum, you should
|
221
|
+
# include this header.
|
222
|
+
# @param action_type [ActionType] A string that's used by logging to determine
|
223
|
+
# whether the request is coming from an interactive session or a page load. The
|
224
|
+
# following are the possible values. 1) Edit—The request is from an interactive
|
225
|
+
# session 2) Load—The request is from a page load. Possible values include:
|
226
|
+
# 'Edit', 'Load'
|
227
|
+
# @param app_name [String] The unique name of your app. The name must be known
|
228
|
+
# by Bing. Do not include this parameter unless you have previously contacted
|
229
|
+
# Bing to get a unique app name. To get a unique name, contact your Bing
|
230
|
+
# Business Development manager.
|
231
|
+
# @param country_code [String] A 2-character country code of the country where
|
232
|
+
# the results come from. This API supports only the United States market. If
|
233
|
+
# you specify this query parameter, it must be set to us. If you set this
|
234
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
235
|
+
# first supported language it finds from the languages list, and combine that
|
236
|
+
# language with the country code that you specify to determine the market to
|
237
|
+
# return results for. If the languages list does not include a supported
|
238
|
+
# language, Bing finds the closest language and market that supports the
|
239
|
+
# request, or it may use an aggregated or default market for the results
|
240
|
+
# instead of a specified one. You should use this query parameter and the
|
241
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
242
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
243
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
244
|
+
# both.
|
245
|
+
# @param client_machine_name [String] A unique name of the device that the
|
246
|
+
# request is being made from. Generate a unique value for each device (the
|
247
|
+
# value is unimportant). The service uses the ID to help debug issues and
|
248
|
+
# improve the quality of corrections.
|
249
|
+
# @param doc_id [String] A unique ID that identifies the document that the text
|
250
|
+
# belongs to. Generate a unique value for each document (the value is
|
251
|
+
# unimportant). The service uses the ID to help debug issues and improve the
|
252
|
+
# quality of corrections.
|
253
|
+
# @param market [String] The market where the results come from. You are
|
254
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
255
|
+
# market helps Bing route the request and return an appropriate and optimal
|
256
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
257
|
+
# not specify both.
|
258
|
+
# @param session_id [String] A unique ID that identifies this user session.
|
259
|
+
# Generate a unique value for each user session (the value is unimportant). The
|
260
|
+
# service uses the ID to help debug issues and improve the quality of
|
261
|
+
# corrections
|
262
|
+
# @param set_lang [String] The language to use for user interface strings.
|
263
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
264
|
+
# the language code for English is EN. The default is EN (English). Although
|
265
|
+
# optional, you should always specify the language. Typically, you set setLang
|
266
|
+
# to the same language specified by mkt unless the user wants the user
|
267
|
+
# interface strings displayed in a different language. This parameter and the
|
268
|
+
# Accept-Language header are mutually exclusive—do not specify both. A user
|
269
|
+
# interface string is a string that's used as a label in a user interface.
|
270
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
271
|
+
# links to Bing.com properties in the response objects apply the specified
|
272
|
+
# language.
|
273
|
+
# @param user_id [String] A unique ID that identifies the user. Generate a
|
274
|
+
# unique value for each user (the value is unimportant). The service uses the
|
275
|
+
# ID to help debug issues and improve the quality of corrections.
|
276
|
+
# @param mode [Mode] The type of spelling and grammar checks to perform. The
|
277
|
+
# following are the possible values (the values are case insensitive). The
|
278
|
+
# default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2)
|
279
|
+
# Spell—Finds most spelling mistakes but does not find some of the grammar
|
280
|
+
# errors that Proof catches (for example, capitalization and repeated words).
|
281
|
+
# Possible values include: 'Proof', 'Spell'
|
282
|
+
# @param pre_context_text [String] A string that gives context to the text
|
283
|
+
# string. For example, the text string petal is valid. However, if you set
|
284
|
+
# preContextText to bike, the context changes and the text string becomes not
|
285
|
+
# valid. In this case, the API suggests that you change petal to pedal (as in
|
286
|
+
# bike pedal). This text is not checked for grammar or spelling errors. The
|
287
|
+
# combined length of the text string, preContextText string, and
|
288
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
289
|
+
# parameter in the query string of a GET request or in the body of a POST
|
290
|
+
# request.
|
291
|
+
# @param post_context_text [String] A string that gives context to the text
|
292
|
+
# string. For example, the text string read is valid. However, if you set
|
293
|
+
# postContextText to carpet, the context changes and the text string becomes
|
294
|
+
# not valid. In this case, the API suggests that you change read to red (as in
|
295
|
+
# red carpet). This text is not checked for grammar or spelling errors. The
|
296
|
+
# combined length of the text string, preContextText string, and
|
297
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
298
|
+
# parameter in the query string of a GET request or in the body of a POST
|
299
|
+
# request.
|
300
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
301
|
+
# will be added to the HTTP request.
|
302
|
+
#
|
303
|
+
# @return [SpellCheck] operation results.
|
304
|
+
#
|
305
|
+
def spell_checker(text, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, action_type:nil, app_name:nil, country_code:nil, client_machine_name:nil, doc_id:nil, market:nil, session_id:nil, set_lang:nil, user_id:nil, mode:nil, pre_context_text:nil, post_context_text:nil, custom_headers:nil)
|
306
|
+
response = spell_checker_async(text, accept_language:accept_language, pragma:pragma, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, action_type:action_type, app_name:app_name, country_code:country_code, client_machine_name:client_machine_name, doc_id:doc_id, market:market, session_id:session_id, set_lang:set_lang, user_id:user_id, mode:mode, pre_context_text:pre_context_text, post_context_text:post_context_text, custom_headers:custom_headers).value!
|
307
|
+
response.body unless response.nil?
|
308
|
+
end
|
309
|
+
|
310
|
+
#
|
311
|
+
# The Bing Spell Check API lets you perform contextual grammar and spell
|
312
|
+
# checking. Bing has developed a web-based spell-checker that leverages machine
|
313
|
+
# learning and statistical machine translation to dynamically train a
|
314
|
+
# constantly evolving and highly contextual algorithm. The spell-checker is
|
315
|
+
# based on a massive corpus of web searches and documents.
|
316
|
+
#
|
317
|
+
# @param text [String] The text string to check for spelling and grammar
|
318
|
+
# errors. The combined length of the text string, preContextText string, and
|
319
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
320
|
+
# parameter in the query string of a GET request or in the body of a POST
|
321
|
+
# request. Because of the query string length limit, you'll typically use a
|
322
|
+
# POST request unless you're checking only short strings.
|
323
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
324
|
+
# languages to use for user interface strings. The list is in decreasing order
|
325
|
+
# of preference. For additional information, including expected format, see
|
326
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
327
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
328
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
329
|
+
# Bing will use the first supported language it finds from the list, and
|
330
|
+
# combine that language with the cc parameter value to determine the market to
|
331
|
+
# return results for. If the list does not include a supported language, Bing
|
332
|
+
# will find the closest language and market that supports the request, and may
|
333
|
+
# use an aggregated or default market for the results instead of a specified
|
334
|
+
# one. You should use this header and the cc query parameter only if you
|
335
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
336
|
+
# query parameters. A user interface string is a string that's used as a label
|
337
|
+
# in a user interface. There are very few user interface strings in the JSON
|
338
|
+
# response objects. Any links in the response objects to Bing.com properties
|
339
|
+
# will apply the specified language.
|
340
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
341
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
342
|
+
# no-cache (for example, Pragma: no-cache).
|
343
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
344
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
345
|
+
# optional, you are strongly encouraged to always specify this header. The
|
346
|
+
# user-agent should be the same string that any commonly used browser would
|
347
|
+
# send. For information about user agents, see [RFC
|
348
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
349
|
+
# @param client_id [String] Bing uses this header to provide users with
|
350
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
351
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
352
|
+
# different flights. If you do not use the same client ID for a user across
|
353
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
354
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
355
|
+
# inconsistent user experience. For example, if the second request has a
|
356
|
+
# different flight assignment than the first, the experience may be unexpected.
|
357
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
358
|
+
# search history, providing a richer experience for the user. Bing also uses
|
359
|
+
# this header to help improve result rankings by analyzing the activity
|
360
|
+
# generated by a client ID. The relevance improvements help with better quality
|
361
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
362
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
363
|
+
# this header required. Persisting the client ID across multiple requests for
|
364
|
+
# the same end user and device combination enables 1) the API consumer to
|
365
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
366
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
367
|
+
# application on the device must have a unique, Bing generated client ID. If
|
368
|
+
# you do not include this header in the request, Bing generates an ID and
|
369
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
370
|
+
# should NOT include this header in a request is the first time the user uses
|
371
|
+
# your app on that device. Use the client ID for each Bing API request that
|
372
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
373
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
374
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
375
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
376
|
+
# time the user uses your app on that device, get the client ID that you
|
377
|
+
# persisted. Bing responses may or may not include this header. If the response
|
378
|
+
# includes this header, capture the client ID and use it for all subsequent
|
379
|
+
# Bing requests for the user on that device. If you include the
|
380
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
381
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
382
|
+
# IP address is used to discover the user's location. Bing uses the location
|
383
|
+
# information to determine safe search behavior. Although optional, you are
|
384
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
385
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
386
|
+
# Obfuscating the address results in the location not being anywhere near the
|
387
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
388
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
389
|
+
# describe the client's geographical location. Bing uses the location
|
390
|
+
# information to determine safe search behavior and to return relevant local
|
391
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
392
|
+
# keys that you use to specify the user's location. lat (required): The
|
393
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
394
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
395
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
396
|
+
# long (required): The longitude of the client's location, in degrees. The
|
397
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
398
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
399
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
400
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
401
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
402
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
403
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
404
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
405
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
406
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
407
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
408
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
409
|
+
# client device is traveling. alt (optional): The altitude of the client
|
410
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
411
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
412
|
+
# the alt key. Although many of the keys are optional, the more information
|
413
|
+
# that you provide, the more accurate the location results are. Although
|
414
|
+
# optional, you are encouraged to always specify the user's geographical
|
415
|
+
# location. Providing the location is especially important if the client's IP
|
416
|
+
# address does not accurately reflect the user's physical location (for
|
417
|
+
# example, if the client uses VPN). For optimal results, you should include
|
418
|
+
# this header and the X-Search-ClientIP header, but at a minimum, you should
|
419
|
+
# include this header.
|
420
|
+
# @param action_type [ActionType] A string that's used by logging to determine
|
421
|
+
# whether the request is coming from an interactive session or a page load. The
|
422
|
+
# following are the possible values. 1) Edit—The request is from an interactive
|
423
|
+
# session 2) Load—The request is from a page load. Possible values include:
|
424
|
+
# 'Edit', 'Load'
|
425
|
+
# @param app_name [String] The unique name of your app. The name must be known
|
426
|
+
# by Bing. Do not include this parameter unless you have previously contacted
|
427
|
+
# Bing to get a unique app name. To get a unique name, contact your Bing
|
428
|
+
# Business Development manager.
|
429
|
+
# @param country_code [String] A 2-character country code of the country where
|
430
|
+
# the results come from. This API supports only the United States market. If
|
431
|
+
# you specify this query parameter, it must be set to us. If you set this
|
432
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
433
|
+
# first supported language it finds from the languages list, and combine that
|
434
|
+
# language with the country code that you specify to determine the market to
|
435
|
+
# return results for. If the languages list does not include a supported
|
436
|
+
# language, Bing finds the closest language and market that supports the
|
437
|
+
# request, or it may use an aggregated or default market for the results
|
438
|
+
# instead of a specified one. You should use this query parameter and the
|
439
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
440
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
441
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
442
|
+
# both.
|
443
|
+
# @param client_machine_name [String] A unique name of the device that the
|
444
|
+
# request is being made from. Generate a unique value for each device (the
|
445
|
+
# value is unimportant). The service uses the ID to help debug issues and
|
446
|
+
# improve the quality of corrections.
|
447
|
+
# @param doc_id [String] A unique ID that identifies the document that the text
|
448
|
+
# belongs to. Generate a unique value for each document (the value is
|
449
|
+
# unimportant). The service uses the ID to help debug issues and improve the
|
450
|
+
# quality of corrections.
|
451
|
+
# @param market [String] The market where the results come from. You are
|
452
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
453
|
+
# market helps Bing route the request and return an appropriate and optimal
|
454
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
455
|
+
# not specify both.
|
456
|
+
# @param session_id [String] A unique ID that identifies this user session.
|
457
|
+
# Generate a unique value for each user session (the value is unimportant). The
|
458
|
+
# service uses the ID to help debug issues and improve the quality of
|
459
|
+
# corrections
|
460
|
+
# @param set_lang [String] The language to use for user interface strings.
|
461
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
462
|
+
# the language code for English is EN. The default is EN (English). Although
|
463
|
+
# optional, you should always specify the language. Typically, you set setLang
|
464
|
+
# to the same language specified by mkt unless the user wants the user
|
465
|
+
# interface strings displayed in a different language. This parameter and the
|
466
|
+
# Accept-Language header are mutually exclusive—do not specify both. A user
|
467
|
+
# interface string is a string that's used as a label in a user interface.
|
468
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
469
|
+
# links to Bing.com properties in the response objects apply the specified
|
470
|
+
# language.
|
471
|
+
# @param user_id [String] A unique ID that identifies the user. Generate a
|
472
|
+
# unique value for each user (the value is unimportant). The service uses the
|
473
|
+
# ID to help debug issues and improve the quality of corrections.
|
474
|
+
# @param mode [Mode] The type of spelling and grammar checks to perform. The
|
475
|
+
# following are the possible values (the values are case insensitive). The
|
476
|
+
# default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2)
|
477
|
+
# Spell—Finds most spelling mistakes but does not find some of the grammar
|
478
|
+
# errors that Proof catches (for example, capitalization and repeated words).
|
479
|
+
# Possible values include: 'Proof', 'Spell'
|
480
|
+
# @param pre_context_text [String] A string that gives context to the text
|
481
|
+
# string. For example, the text string petal is valid. However, if you set
|
482
|
+
# preContextText to bike, the context changes and the text string becomes not
|
483
|
+
# valid. In this case, the API suggests that you change petal to pedal (as in
|
484
|
+
# bike pedal). This text is not checked for grammar or spelling errors. The
|
485
|
+
# combined length of the text string, preContextText string, and
|
486
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
487
|
+
# parameter in the query string of a GET request or in the body of a POST
|
488
|
+
# request.
|
489
|
+
# @param post_context_text [String] A string that gives context to the text
|
490
|
+
# string. For example, the text string read is valid. However, if you set
|
491
|
+
# postContextText to carpet, the context changes and the text string becomes
|
492
|
+
# not valid. In this case, the API suggests that you change read to red (as in
|
493
|
+
# red carpet). This text is not checked for grammar or spelling errors. The
|
494
|
+
# combined length of the text string, preContextText string, and
|
495
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
496
|
+
# parameter in the query string of a GET request or in the body of a POST
|
497
|
+
# request.
|
498
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
499
|
+
# will be added to the HTTP request.
|
500
|
+
#
|
501
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
502
|
+
#
|
503
|
+
def spell_checker_with_http_info(text, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, action_type:nil, app_name:nil, country_code:nil, client_machine_name:nil, doc_id:nil, market:nil, session_id:nil, set_lang:nil, user_id:nil, mode:nil, pre_context_text:nil, post_context_text:nil, custom_headers:nil)
|
504
|
+
spell_checker_async(text, accept_language:accept_language, pragma:pragma, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, action_type:action_type, app_name:app_name, country_code:country_code, client_machine_name:client_machine_name, doc_id:doc_id, market:market, session_id:session_id, set_lang:set_lang, user_id:user_id, mode:mode, pre_context_text:pre_context_text, post_context_text:post_context_text, custom_headers:custom_headers).value!
|
505
|
+
end
|
506
|
+
|
507
|
+
#
|
508
|
+
# The Bing Spell Check API lets you perform contextual grammar and spell
|
509
|
+
# checking. Bing has developed a web-based spell-checker that leverages machine
|
510
|
+
# learning and statistical machine translation to dynamically train a
|
511
|
+
# constantly evolving and highly contextual algorithm. The spell-checker is
|
512
|
+
# based on a massive corpus of web searches and documents.
|
513
|
+
#
|
514
|
+
# @param text [String] The text string to check for spelling and grammar
|
515
|
+
# errors. The combined length of the text string, preContextText string, and
|
516
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
517
|
+
# parameter in the query string of a GET request or in the body of a POST
|
518
|
+
# request. Because of the query string length limit, you'll typically use a
|
519
|
+
# POST request unless you're checking only short strings.
|
520
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
521
|
+
# languages to use for user interface strings. The list is in decreasing order
|
522
|
+
# of preference. For additional information, including expected format, see
|
523
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
524
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
525
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
526
|
+
# Bing will use the first supported language it finds from the list, and
|
527
|
+
# combine that language with the cc parameter value to determine the market to
|
528
|
+
# return results for. If the list does not include a supported language, Bing
|
529
|
+
# will find the closest language and market that supports the request, and may
|
530
|
+
# use an aggregated or default market for the results instead of a specified
|
531
|
+
# one. You should use this header and the cc query parameter only if you
|
532
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
533
|
+
# query parameters. A user interface string is a string that's used as a label
|
534
|
+
# in a user interface. There are very few user interface strings in the JSON
|
535
|
+
# response objects. Any links in the response objects to Bing.com properties
|
536
|
+
# will apply the specified language.
|
537
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
538
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
539
|
+
# no-cache (for example, Pragma: no-cache).
|
540
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
541
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
542
|
+
# optional, you are strongly encouraged to always specify this header. The
|
543
|
+
# user-agent should be the same string that any commonly used browser would
|
544
|
+
# send. For information about user agents, see [RFC
|
545
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
546
|
+
# @param client_id [String] Bing uses this header to provide users with
|
547
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
548
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
549
|
+
# different flights. If you do not use the same client ID for a user across
|
550
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
551
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
552
|
+
# inconsistent user experience. For example, if the second request has a
|
553
|
+
# different flight assignment than the first, the experience may be unexpected.
|
554
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
555
|
+
# search history, providing a richer experience for the user. Bing also uses
|
556
|
+
# this header to help improve result rankings by analyzing the activity
|
557
|
+
# generated by a client ID. The relevance improvements help with better quality
|
558
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
559
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
560
|
+
# this header required. Persisting the client ID across multiple requests for
|
561
|
+
# the same end user and device combination enables 1) the API consumer to
|
562
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
563
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
564
|
+
# application on the device must have a unique, Bing generated client ID. If
|
565
|
+
# you do not include this header in the request, Bing generates an ID and
|
566
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
567
|
+
# should NOT include this header in a request is the first time the user uses
|
568
|
+
# your app on that device. Use the client ID for each Bing API request that
|
569
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
570
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
571
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
572
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
573
|
+
# time the user uses your app on that device, get the client ID that you
|
574
|
+
# persisted. Bing responses may or may not include this header. If the response
|
575
|
+
# includes this header, capture the client ID and use it for all subsequent
|
576
|
+
# Bing requests for the user on that device. If you include the
|
577
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
578
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
579
|
+
# IP address is used to discover the user's location. Bing uses the location
|
580
|
+
# information to determine safe search behavior. Although optional, you are
|
581
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
582
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
583
|
+
# Obfuscating the address results in the location not being anywhere near the
|
584
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
585
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
586
|
+
# describe the client's geographical location. Bing uses the location
|
587
|
+
# information to determine safe search behavior and to return relevant local
|
588
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
589
|
+
# keys that you use to specify the user's location. lat (required): The
|
590
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
591
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
592
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
593
|
+
# long (required): The longitude of the client's location, in degrees. The
|
594
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
595
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
596
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
597
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
598
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
599
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
600
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
601
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
602
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
603
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
604
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
605
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
606
|
+
# client device is traveling. alt (optional): The altitude of the client
|
607
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
608
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
609
|
+
# the alt key. Although many of the keys are optional, the more information
|
610
|
+
# that you provide, the more accurate the location results are. Although
|
611
|
+
# optional, you are encouraged to always specify the user's geographical
|
612
|
+
# location. Providing the location is especially important if the client's IP
|
613
|
+
# address does not accurately reflect the user's physical location (for
|
614
|
+
# example, if the client uses VPN). For optimal results, you should include
|
615
|
+
# this header and the X-Search-ClientIP header, but at a minimum, you should
|
616
|
+
# include this header.
|
617
|
+
# @param action_type [ActionType] A string that's used by logging to determine
|
618
|
+
# whether the request is coming from an interactive session or a page load. The
|
619
|
+
# following are the possible values. 1) Edit—The request is from an interactive
|
620
|
+
# session 2) Load—The request is from a page load. Possible values include:
|
621
|
+
# 'Edit', 'Load'
|
622
|
+
# @param app_name [String] The unique name of your app. The name must be known
|
623
|
+
# by Bing. Do not include this parameter unless you have previously contacted
|
624
|
+
# Bing to get a unique app name. To get a unique name, contact your Bing
|
625
|
+
# Business Development manager.
|
626
|
+
# @param country_code [String] A 2-character country code of the country where
|
627
|
+
# the results come from. This API supports only the United States market. If
|
628
|
+
# you specify this query parameter, it must be set to us. If you set this
|
629
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
630
|
+
# first supported language it finds from the languages list, and combine that
|
631
|
+
# language with the country code that you specify to determine the market to
|
632
|
+
# return results for. If the languages list does not include a supported
|
633
|
+
# language, Bing finds the closest language and market that supports the
|
634
|
+
# request, or it may use an aggregated or default market for the results
|
635
|
+
# instead of a specified one. You should use this query parameter and the
|
636
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
637
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
638
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
639
|
+
# both.
|
640
|
+
# @param client_machine_name [String] A unique name of the device that the
|
641
|
+
# request is being made from. Generate a unique value for each device (the
|
642
|
+
# value is unimportant). The service uses the ID to help debug issues and
|
643
|
+
# improve the quality of corrections.
|
644
|
+
# @param doc_id [String] A unique ID that identifies the document that the text
|
645
|
+
# belongs to. Generate a unique value for each document (the value is
|
646
|
+
# unimportant). The service uses the ID to help debug issues and improve the
|
647
|
+
# quality of corrections.
|
648
|
+
# @param market [String] The market where the results come from. You are
|
649
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
650
|
+
# market helps Bing route the request and return an appropriate and optimal
|
651
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
652
|
+
# not specify both.
|
653
|
+
# @param session_id [String] A unique ID that identifies this user session.
|
654
|
+
# Generate a unique value for each user session (the value is unimportant). The
|
655
|
+
# service uses the ID to help debug issues and improve the quality of
|
656
|
+
# corrections
|
657
|
+
# @param set_lang [String] The language to use for user interface strings.
|
658
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
659
|
+
# the language code for English is EN. The default is EN (English). Although
|
660
|
+
# optional, you should always specify the language. Typically, you set setLang
|
661
|
+
# to the same language specified by mkt unless the user wants the user
|
662
|
+
# interface strings displayed in a different language. This parameter and the
|
663
|
+
# Accept-Language header are mutually exclusive—do not specify both. A user
|
664
|
+
# interface string is a string that's used as a label in a user interface.
|
665
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
666
|
+
# links to Bing.com properties in the response objects apply the specified
|
667
|
+
# language.
|
668
|
+
# @param user_id [String] A unique ID that identifies the user. Generate a
|
669
|
+
# unique value for each user (the value is unimportant). The service uses the
|
670
|
+
# ID to help debug issues and improve the quality of corrections.
|
671
|
+
# @param mode [Mode] The type of spelling and grammar checks to perform. The
|
672
|
+
# following are the possible values (the values are case insensitive). The
|
673
|
+
# default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2)
|
674
|
+
# Spell—Finds most spelling mistakes but does not find some of the grammar
|
675
|
+
# errors that Proof catches (for example, capitalization and repeated words).
|
676
|
+
# Possible values include: 'Proof', 'Spell'
|
677
|
+
# @param pre_context_text [String] A string that gives context to the text
|
678
|
+
# string. For example, the text string petal is valid. However, if you set
|
679
|
+
# preContextText to bike, the context changes and the text string becomes not
|
680
|
+
# valid. In this case, the API suggests that you change petal to pedal (as in
|
681
|
+
# bike pedal). This text is not checked for grammar or spelling errors. The
|
682
|
+
# combined length of the text string, preContextText string, and
|
683
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
684
|
+
# parameter in the query string of a GET request or in the body of a POST
|
685
|
+
# request.
|
686
|
+
# @param post_context_text [String] A string that gives context to the text
|
687
|
+
# string. For example, the text string read is valid. However, if you set
|
688
|
+
# postContextText to carpet, the context changes and the text string becomes
|
689
|
+
# not valid. In this case, the API suggests that you change read to red (as in
|
690
|
+
# red carpet). This text is not checked for grammar or spelling errors. The
|
691
|
+
# combined length of the text string, preContextText string, and
|
692
|
+
# postContextText string may not exceed 10,000 characters. You may specify this
|
693
|
+
# parameter in the query string of a GET request or in the body of a POST
|
694
|
+
# request.
|
695
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
696
|
+
# to the HTTP request.
|
697
|
+
#
|
698
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
699
|
+
#
|
700
|
+
def spell_checker_async(text, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, action_type:nil, app_name:nil, country_code:nil, client_machine_name:nil, doc_id:nil, market:nil, session_id:nil, set_lang:nil, user_id:nil, mode:nil, pre_context_text:nil, post_context_text:nil, custom_headers:nil)
|
701
|
+
x_bing_apis_sdk = 'true'
|
702
|
+
fail ArgumentError, 'text is nil' if text.nil?
|
703
|
+
|
704
|
+
|
705
|
+
request_headers = {}
|
706
|
+
request_headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
707
|
+
|
708
|
+
# Set Headers
|
709
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
710
|
+
request_headers['X-BingApis-SDK'] = x_bing_apis_sdk unless x_bing_apis_sdk.nil?
|
711
|
+
request_headers['Accept-Language'] = accept_language unless accept_language.nil?
|
712
|
+
request_headers['Pragma'] = pragma unless pragma.nil?
|
713
|
+
request_headers['User-Agent'] = user_agent unless user_agent.nil?
|
714
|
+
request_headers['X-MSEdge-ClientID'] = client_id unless client_id.nil?
|
715
|
+
request_headers['X-MSEdge-ClientIP'] = client_ip unless client_ip.nil?
|
716
|
+
request_headers['X-Search-Location'] = location unless location.nil?
|
717
|
+
|
718
|
+
# Set Form Data
|
719
|
+
form_data = {}
|
720
|
+
form_data['Mode'] = mode.to_s unless mode.to_s.nil?
|
721
|
+
form_data['PreContextText'] = pre_context_text unless pre_context_text.nil?
|
722
|
+
form_data['PostContextText'] = post_context_text unless post_context_text.nil?
|
723
|
+
form_data['Text'] = text unless text.nil?
|
724
|
+
|
725
|
+
path_template = 'spellcheck'
|
726
|
+
|
727
|
+
request_url = @base_url || self.base_url
|
728
|
+
|
729
|
+
options = {
|
730
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
731
|
+
query_params: {'ActionType' => action_type,'AppName' => app_name,'cc' => country_code,'ClientMachineName' => client_machine_name,'DocId' => doc_id,'mkt' => market,'SessionId' => session_id,'SetLang' => set_lang,'UserId' => user_id},
|
732
|
+
headers: request_headers.merge(custom_headers || {}),
|
733
|
+
body: URI.encode_www_form(form_data),
|
734
|
+
base_url: request_url
|
735
|
+
}
|
736
|
+
promise = self.make_request_async(:post, path_template, options)
|
737
|
+
|
738
|
+
promise = promise.then do |result|
|
739
|
+
http_response = result.response
|
740
|
+
status_code = http_response.status
|
741
|
+
response_content = http_response.body
|
742
|
+
unless status_code == 200
|
743
|
+
error_model = JSON.load(response_content)
|
744
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
745
|
+
end
|
746
|
+
|
747
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
748
|
+
# Deserialize Response
|
749
|
+
if status_code == 200
|
750
|
+
begin
|
751
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
752
|
+
result_mapper = Azure::CognitiveServices::SpellCheck::V1_0::Models::SpellCheck.mapper()
|
753
|
+
result.body = self.deserialize(result_mapper, parsed_response)
|
754
|
+
rescue Exception => e
|
755
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
756
|
+
end
|
757
|
+
end
|
758
|
+
|
759
|
+
result
|
760
|
+
end
|
761
|
+
|
762
|
+
promise.execute
|
763
|
+
end
|
764
|
+
|
765
|
+
|
766
|
+
private
|
767
|
+
#
|
768
|
+
# Adds telemetry information.
|
769
|
+
#
|
770
|
+
def add_telemetry
|
771
|
+
sdk_information = 'azure_cognitiveservices_spellcheck'
|
772
|
+
sdk_information = "#{sdk_information}/0.16.0"
|
773
|
+
add_user_agent_information(sdk_information)
|
774
|
+
end
|
775
|
+
end
|
776
|
+
end
|