cloudmersive-nlp-api-client 2.0.7 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +16 -8
- data/cloudmersive-nlp-api-client.gemspec +3 -3
- data/docs/AnalyticsApi.md +113 -3
- data/docs/ExtractEntitiesApi.md +1 -1
- data/docs/HateSpeechAnalysisRequest.md +8 -0
- data/docs/HateSpeechAnalysisResponse.md +10 -0
- data/docs/LanguageDetectionApi.md +1 -1
- data/docs/LanguageTranslationApi.md +114 -4
- data/docs/ParseApi.md +1 -1
- data/docs/PosTaggerApi.md +6 -6
- data/docs/RephraseApi.md +1 -1
- data/docs/SegmentationApi.md +2 -2
- data/docs/SimilarityAnalysisRequest.md +9 -0
- data/docs/SimilarityAnalysisResponse.md +10 -0
- data/docs/SpellcheckApi.md +2 -2
- data/lib/cloudmersive-nlp-api-client.rb +5 -1
- data/lib/cloudmersive-nlp-api-client/api/analytics_api.rb +120 -15
- data/lib/cloudmersive-nlp-api-client/api/extract_entities_api.rb +6 -7
- data/lib/cloudmersive-nlp-api-client/api/language_detection_api.rb +6 -7
- data/lib/cloudmersive-nlp-api-client/api/language_translation_api.rb +124 -20
- data/lib/cloudmersive-nlp-api-client/api/parse_api.rb +6 -7
- data/lib/cloudmersive-nlp-api-client/api/pos_tagger_api.rb +26 -32
- data/lib/cloudmersive-nlp-api-client/api/rephrase_api.rb +6 -7
- data/lib/cloudmersive-nlp-api-client/api/segmentation_api.rb +10 -12
- data/lib/cloudmersive-nlp-api-client/api/spellcheck_api.rb +10 -12
- data/lib/cloudmersive-nlp-api-client/api_client.rb +11 -9
- data/lib/cloudmersive-nlp-api-client/api_error.rb +1 -1
- data/lib/cloudmersive-nlp-api-client/configuration.rb +2 -2
- data/lib/cloudmersive-nlp-api-client/models/check_sentence_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/check_sentence_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/check_word_request.rb +7 -11
- data/lib/cloudmersive-nlp-api-client/models/check_word_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/correct_word_in_sentence.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/entity.rb +7 -11
- data/lib/cloudmersive-nlp-api-client/models/extract_entities_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/extract_entities_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/get_words_request.rb +7 -11
- data/lib/cloudmersive-nlp-api-client/models/get_words_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/hate_speech_analysis_request.rb +186 -0
- data/lib/cloudmersive-nlp-api-client/models/hate_speech_analysis_response.rb +206 -0
- data/lib/cloudmersive-nlp-api-client/models/language_detection_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/language_detection_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/language_translation_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/language_translation_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/parse_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/parse_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/pos_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/pos_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/pos_sentence.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/pos_tagged_word.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/profanity_analysis_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/profanity_analysis_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/rephrase_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/rephrase_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/rephrased_sentence.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/rephrased_sentence_option.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/sentence_segmentation_request.rb +7 -11
- data/lib/cloudmersive-nlp-api-client/models/sentence_segmentation_response.rb +7 -11
- data/lib/cloudmersive-nlp-api-client/models/sentiment_analysis_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/sentiment_analysis_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/similarity_analysis_request.rb +196 -0
- data/lib/cloudmersive-nlp-api-client/models/similarity_analysis_response.rb +206 -0
- data/lib/cloudmersive-nlp-api-client/models/subjectivity_analysis_request.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/subjectivity_analysis_response.rb +7 -10
- data/lib/cloudmersive-nlp-api-client/models/word_position.rb +7 -11
- data/lib/cloudmersive-nlp-api-client/version.rb +2 -2
- data/spec/api/analytics_api_spec.rb +28 -4
- data/spec/api/extract_entities_api_spec.rb +2 -2
- data/spec/api/language_detection_api_spec.rb +2 -2
- data/spec/api/language_translation_api_spec.rb +29 -5
- data/spec/api/parse_api_spec.rb +2 -2
- data/spec/api/pos_tagger_api_spec.rb +7 -7
- data/spec/api/rephrase_api_spec.rb +2 -2
- data/spec/api/segmentation_api_spec.rb +3 -3
- data/spec/api/spellcheck_api_spec.rb +3 -3
- data/spec/api_client_spec.rb +52 -35
- data/spec/configuration_spec.rb +9 -9
- data/spec/models/check_sentence_request_spec.rb +2 -3
- data/spec/models/check_sentence_response_spec.rb +3 -4
- data/spec/models/check_word_request_spec.rb +2 -3
- data/spec/models/check_word_response_spec.rb +3 -4
- data/spec/models/correct_word_in_sentence_spec.rb +4 -5
- data/spec/models/entity_spec.rb +3 -4
- data/spec/models/extract_entities_request_spec.rb +2 -3
- data/spec/models/extract_entities_response_spec.rb +3 -4
- data/spec/models/get_words_request_spec.rb +2 -3
- data/spec/models/get_words_response_spec.rb +2 -3
- data/spec/models/hate_speech_analysis_request_spec.rb +41 -0
- data/spec/models/hate_speech_analysis_response_spec.rb +53 -0
- data/spec/models/language_detection_request_spec.rb +2 -3
- data/spec/models/language_detection_response_spec.rb +4 -5
- data/spec/models/language_translation_request_spec.rb +2 -3
- data/spec/models/language_translation_response_spec.rb +4 -5
- data/spec/models/parse_request_spec.rb +2 -3
- data/spec/models/parse_response_spec.rb +2 -3
- data/spec/models/pos_request_spec.rb +2 -3
- data/spec/models/pos_response_spec.rb +2 -3
- data/spec/models/pos_sentence_spec.rb +2 -3
- data/spec/models/pos_tagged_word_spec.rb +3 -4
- data/spec/models/profanity_analysis_request_spec.rb +2 -3
- data/spec/models/profanity_analysis_response_spec.rb +4 -5
- data/spec/models/rephrase_request_spec.rb +3 -4
- data/spec/models/rephrase_response_spec.rb +4 -5
- data/spec/models/rephrased_sentence_option_spec.rb +3 -4
- data/spec/models/rephrased_sentence_spec.rb +4 -5
- data/spec/models/sentence_segmentation_request_spec.rb +2 -3
- data/spec/models/sentence_segmentation_response_spec.rb +4 -5
- data/spec/models/sentiment_analysis_request_spec.rb +2 -3
- data/spec/models/sentiment_analysis_response_spec.rb +5 -6
- data/spec/models/similarity_analysis_request_spec.rb +47 -0
- data/spec/models/similarity_analysis_response_spec.rb +53 -0
- data/spec/models/subjectivity_analysis_request_spec.rb +2 -3
- data/spec/models/subjectivity_analysis_response_spec.rb +4 -5
- data/spec/models/word_position_spec.rb +5 -6
- data/spec/spec_helper.rb +1 -1
- metadata +14 -2
@@ -6,18 +6,16 @@
|
|
6
6
|
OpenAPI spec version: v1
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
14
|
|
15
15
|
module CloudmersiveNlpApiClient
|
16
|
-
|
17
16
|
class GetWordsRequest
|
18
17
|
attr_accessor :input_text
|
19
18
|
|
20
|
-
|
21
19
|
# Attribute mapping from ruby-style variable name to JSON key.
|
22
20
|
def self.attribute_map
|
23
21
|
{
|
@@ -38,25 +36,24 @@ module CloudmersiveNlpApiClient
|
|
38
36
|
return unless attributes.is_a?(Hash)
|
39
37
|
|
40
38
|
# convert string to symbol for hash key
|
41
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
39
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
42
40
|
|
43
41
|
if attributes.has_key?(:'InputText')
|
44
42
|
self.input_text = attributes[:'InputText']
|
45
43
|
end
|
46
|
-
|
47
44
|
end
|
48
45
|
|
49
46
|
# Show invalid properties with the reasons. Usually used together with valid?
|
50
47
|
# @return Array for valid properties with the reasons
|
51
48
|
def list_invalid_properties
|
52
49
|
invalid_properties = Array.new
|
53
|
-
|
50
|
+
invalid_properties
|
54
51
|
end
|
55
52
|
|
56
53
|
# Check to see if the all the properties in the model are valid
|
57
54
|
# @return true if the model is valid
|
58
55
|
def valid?
|
59
|
-
|
56
|
+
true
|
60
57
|
end
|
61
58
|
|
62
59
|
# Checks equality by comparing each attribute.
|
@@ -86,10 +83,10 @@ module CloudmersiveNlpApiClient
|
|
86
83
|
return nil unless attributes.is_a?(Hash)
|
87
84
|
self.class.swagger_types.each_pair do |key, type|
|
88
85
|
if type =~ /\AArray<(.*)>/i
|
89
|
-
# check to ensure the input is an array given that the
|
86
|
+
# check to ensure the input is an array given that the attribute
|
90
87
|
# is documented as an array but the input is not
|
91
88
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
92
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) }
|
89
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
93
90
|
end
|
94
91
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
95
92
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
@@ -171,7 +168,7 @@ module CloudmersiveNlpApiClient
|
|
171
168
|
# @return [Hash] Returns the value in the form of hash
|
172
169
|
def _to_hash(value)
|
173
170
|
if value.is_a?(Array)
|
174
|
-
value.compact.map{ |v| _to_hash(v) }
|
171
|
+
value.compact.map { |v| _to_hash(v) }
|
175
172
|
elsif value.is_a?(Hash)
|
176
173
|
{}.tap do |hash|
|
177
174
|
value.each { |k, v| hash[k] = _to_hash(v) }
|
@@ -184,5 +181,4 @@ module CloudmersiveNlpApiClient
|
|
184
181
|
end
|
185
182
|
|
186
183
|
end
|
187
|
-
|
188
184
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: v1
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -18,7 +18,6 @@ module CloudmersiveNlpApiClient
|
|
18
18
|
# Array of words
|
19
19
|
attr_accessor :words
|
20
20
|
|
21
|
-
|
22
21
|
# Attribute mapping from ruby-style variable name to JSON key.
|
23
22
|
def self.attribute_map
|
24
23
|
{
|
@@ -39,27 +38,26 @@ module CloudmersiveNlpApiClient
|
|
39
38
|
return unless attributes.is_a?(Hash)
|
40
39
|
|
41
40
|
# convert string to symbol for hash key
|
42
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
41
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
43
42
|
|
44
43
|
if attributes.has_key?(:'Words')
|
45
44
|
if (value = attributes[:'Words']).is_a?(Array)
|
46
45
|
self.words = value
|
47
46
|
end
|
48
47
|
end
|
49
|
-
|
50
48
|
end
|
51
49
|
|
52
50
|
# Show invalid properties with the reasons. Usually used together with valid?
|
53
51
|
# @return Array for valid properties with the reasons
|
54
52
|
def list_invalid_properties
|
55
53
|
invalid_properties = Array.new
|
56
|
-
|
54
|
+
invalid_properties
|
57
55
|
end
|
58
56
|
|
59
57
|
# Check to see if the all the properties in the model are valid
|
60
58
|
# @return true if the model is valid
|
61
59
|
def valid?
|
62
|
-
|
60
|
+
true
|
63
61
|
end
|
64
62
|
|
65
63
|
# Checks equality by comparing each attribute.
|
@@ -89,10 +87,10 @@ module CloudmersiveNlpApiClient
|
|
89
87
|
return nil unless attributes.is_a?(Hash)
|
90
88
|
self.class.swagger_types.each_pair do |key, type|
|
91
89
|
if type =~ /\AArray<(.*)>/i
|
92
|
-
# check to ensure the input is an array given that the
|
90
|
+
# check to ensure the input is an array given that the attribute
|
93
91
|
# is documented as an array but the input is not
|
94
92
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
95
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) }
|
93
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
96
94
|
end
|
97
95
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
98
96
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
@@ -174,7 +172,7 @@ module CloudmersiveNlpApiClient
|
|
174
172
|
# @return [Hash] Returns the value in the form of hash
|
175
173
|
def _to_hash(value)
|
176
174
|
if value.is_a?(Array)
|
177
|
-
value.compact.map{ |v| _to_hash(v) }
|
175
|
+
value.compact.map { |v| _to_hash(v) }
|
178
176
|
elsif value.is_a?(Hash)
|
179
177
|
{}.tap do |hash|
|
180
178
|
value.each { |k, v| hash[k] = _to_hash(v) }
|
@@ -187,5 +185,4 @@ module CloudmersiveNlpApiClient
|
|
187
185
|
end
|
188
186
|
|
189
187
|
end
|
190
|
-
|
191
188
|
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
=begin
|
2
|
+
#nlpapiv2
|
3
|
+
|
4
|
+
#The powerful Natural Language Processing APIs (v2) let you perform part of speech tagging, entity identification, sentence parsing, and much more to help you understand the meaning of unstructured text.
|
5
|
+
|
6
|
+
OpenAPI spec version: v1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CloudmersiveNlpApiClient
|
16
|
+
# Input to a hate speech analysis operation
|
17
|
+
class HateSpeechAnalysisRequest
|
18
|
+
# Text to analyze
|
19
|
+
attr_accessor :text_to_analyze
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'text_to_analyze' => :'TextToAnalyze'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
:'text_to_analyze' => :'String'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
return unless attributes.is_a?(Hash)
|
39
|
+
|
40
|
+
# convert string to symbol for hash key
|
41
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
42
|
+
|
43
|
+
if attributes.has_key?(:'TextToAnalyze')
|
44
|
+
self.text_to_analyze = attributes[:'TextToAnalyze']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
49
|
+
# @return Array for valid properties with the reasons
|
50
|
+
def list_invalid_properties
|
51
|
+
invalid_properties = Array.new
|
52
|
+
invalid_properties
|
53
|
+
end
|
54
|
+
|
55
|
+
# Check to see if the all the properties in the model are valid
|
56
|
+
# @return true if the model is valid
|
57
|
+
def valid?
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
# Checks equality by comparing each attribute.
|
62
|
+
# @param [Object] Object to be compared
|
63
|
+
def ==(o)
|
64
|
+
return true if self.equal?(o)
|
65
|
+
self.class == o.class &&
|
66
|
+
text_to_analyze == o.text_to_analyze
|
67
|
+
end
|
68
|
+
|
69
|
+
# @see the `==` method
|
70
|
+
# @param [Object] Object to be compared
|
71
|
+
def eql?(o)
|
72
|
+
self == o
|
73
|
+
end
|
74
|
+
|
75
|
+
# Calculates hash code according to all attributes.
|
76
|
+
# @return [Fixnum] Hash code
|
77
|
+
def hash
|
78
|
+
[text_to_analyze].hash
|
79
|
+
end
|
80
|
+
|
81
|
+
# Builds the object from hash
|
82
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
83
|
+
# @return [Object] Returns the model itself
|
84
|
+
def build_from_hash(attributes)
|
85
|
+
return nil unless attributes.is_a?(Hash)
|
86
|
+
self.class.swagger_types.each_pair do |key, type|
|
87
|
+
if type =~ /\AArray<(.*)>/i
|
88
|
+
# check to ensure the input is an array given that the attribute
|
89
|
+
# is documented as an array but the input is not
|
90
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
91
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
92
|
+
end
|
93
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
94
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
95
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
96
|
+
end
|
97
|
+
|
98
|
+
self
|
99
|
+
end
|
100
|
+
|
101
|
+
# Deserializes the data based on type
|
102
|
+
# @param string type Data type
|
103
|
+
# @param string value Value to be deserialized
|
104
|
+
# @return [Object] Deserialized data
|
105
|
+
def _deserialize(type, value)
|
106
|
+
case type.to_sym
|
107
|
+
when :DateTime
|
108
|
+
DateTime.parse(value)
|
109
|
+
when :Date
|
110
|
+
Date.parse(value)
|
111
|
+
when :String
|
112
|
+
value.to_s
|
113
|
+
when :Integer
|
114
|
+
value.to_i
|
115
|
+
when :Float
|
116
|
+
value.to_f
|
117
|
+
when :BOOLEAN
|
118
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
119
|
+
true
|
120
|
+
else
|
121
|
+
false
|
122
|
+
end
|
123
|
+
when :Object
|
124
|
+
# generic object (usually a Hash), return directly
|
125
|
+
value
|
126
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
127
|
+
inner_type = Regexp.last_match[:inner_type]
|
128
|
+
value.map { |v| _deserialize(inner_type, v) }
|
129
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
130
|
+
k_type = Regexp.last_match[:k_type]
|
131
|
+
v_type = Regexp.last_match[:v_type]
|
132
|
+
{}.tap do |hash|
|
133
|
+
value.each do |k, v|
|
134
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
else # model
|
138
|
+
temp_model = CloudmersiveNlpApiClient.const_get(type).new
|
139
|
+
temp_model.build_from_hash(value)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Returns the string representation of the object
|
144
|
+
# @return [String] String presentation of the object
|
145
|
+
def to_s
|
146
|
+
to_hash.to_s
|
147
|
+
end
|
148
|
+
|
149
|
+
# to_body is an alias to to_hash (backward compatibility)
|
150
|
+
# @return [Hash] Returns the object in the form of hash
|
151
|
+
def to_body
|
152
|
+
to_hash
|
153
|
+
end
|
154
|
+
|
155
|
+
# Returns the object in the form of hash
|
156
|
+
# @return [Hash] Returns the object in the form of hash
|
157
|
+
def to_hash
|
158
|
+
hash = {}
|
159
|
+
self.class.attribute_map.each_pair do |attr, param|
|
160
|
+
value = self.send(attr)
|
161
|
+
next if value.nil?
|
162
|
+
hash[param] = _to_hash(value)
|
163
|
+
end
|
164
|
+
hash
|
165
|
+
end
|
166
|
+
|
167
|
+
# Outputs non-array value in the form of hash
|
168
|
+
# For object, use to_hash. Otherwise, just return the value
|
169
|
+
# @param [Object] value Any valid value
|
170
|
+
# @return [Hash] Returns the value in the form of hash
|
171
|
+
def _to_hash(value)
|
172
|
+
if value.is_a?(Array)
|
173
|
+
value.compact.map { |v| _to_hash(v) }
|
174
|
+
elsif value.is_a?(Hash)
|
175
|
+
{}.tap do |hash|
|
176
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
177
|
+
end
|
178
|
+
elsif value.respond_to? :to_hash
|
179
|
+
value.to_hash
|
180
|
+
else
|
181
|
+
value
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
=begin
|
2
|
+
#nlpapiv2
|
3
|
+
|
4
|
+
#The powerful Natural Language Processing APIs (v2) let you perform part of speech tagging, entity identification, sentence parsing, and much more to help you understand the meaning of unstructured text.
|
5
|
+
|
6
|
+
OpenAPI spec version: v1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CloudmersiveNlpApiClient
|
16
|
+
# Output of a hate speech analysis operation
|
17
|
+
class HateSpeechAnalysisResponse
|
18
|
+
# True if the profanity detection operation was successful, false otherwise
|
19
|
+
attr_accessor :successful
|
20
|
+
|
21
|
+
# Hate speech classification score between 0.0 and 1.0 where scores closer to zero have a low probability of being hate speech language, while scores close to 1.0 have a high probability of being hate speech language. Values above 0.8 have a very high probability of being hate speech.
|
22
|
+
attr_accessor :hate_speech_score_result
|
23
|
+
|
24
|
+
# Number of sentences in input text
|
25
|
+
attr_accessor :sentence_count
|
26
|
+
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
+
def self.attribute_map
|
29
|
+
{
|
30
|
+
:'successful' => :'Successful',
|
31
|
+
:'hate_speech_score_result' => :'HateSpeechScoreResult',
|
32
|
+
:'sentence_count' => :'SentenceCount'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute type mapping.
|
37
|
+
def self.swagger_types
|
38
|
+
{
|
39
|
+
:'successful' => :'BOOLEAN',
|
40
|
+
:'hate_speech_score_result' => :'Float',
|
41
|
+
:'sentence_count' => :'Integer'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes the object
|
46
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
+
def initialize(attributes = {})
|
48
|
+
return unless attributes.is_a?(Hash)
|
49
|
+
|
50
|
+
# convert string to symbol for hash key
|
51
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
52
|
+
|
53
|
+
if attributes.has_key?(:'Successful')
|
54
|
+
self.successful = attributes[:'Successful']
|
55
|
+
end
|
56
|
+
|
57
|
+
if attributes.has_key?(:'HateSpeechScoreResult')
|
58
|
+
self.hate_speech_score_result = attributes[:'HateSpeechScoreResult']
|
59
|
+
end
|
60
|
+
|
61
|
+
if attributes.has_key?(:'SentenceCount')
|
62
|
+
self.sentence_count = attributes[:'SentenceCount']
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
67
|
+
# @return Array for valid properties with the reasons
|
68
|
+
def list_invalid_properties
|
69
|
+
invalid_properties = Array.new
|
70
|
+
invalid_properties
|
71
|
+
end
|
72
|
+
|
73
|
+
# Check to see if the all the properties in the model are valid
|
74
|
+
# @return true if the model is valid
|
75
|
+
def valid?
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
# Checks equality by comparing each attribute.
|
80
|
+
# @param [Object] Object to be compared
|
81
|
+
def ==(o)
|
82
|
+
return true if self.equal?(o)
|
83
|
+
self.class == o.class &&
|
84
|
+
successful == o.successful &&
|
85
|
+
hate_speech_score_result == o.hate_speech_score_result &&
|
86
|
+
sentence_count == o.sentence_count
|
87
|
+
end
|
88
|
+
|
89
|
+
# @see the `==` method
|
90
|
+
# @param [Object] Object to be compared
|
91
|
+
def eql?(o)
|
92
|
+
self == o
|
93
|
+
end
|
94
|
+
|
95
|
+
# Calculates hash code according to all attributes.
|
96
|
+
# @return [Fixnum] Hash code
|
97
|
+
def hash
|
98
|
+
[successful, hate_speech_score_result, sentence_count].hash
|
99
|
+
end
|
100
|
+
|
101
|
+
# Builds the object from hash
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
103
|
+
# @return [Object] Returns the model itself
|
104
|
+
def build_from_hash(attributes)
|
105
|
+
return nil unless attributes.is_a?(Hash)
|
106
|
+
self.class.swagger_types.each_pair do |key, type|
|
107
|
+
if type =~ /\AArray<(.*)>/i
|
108
|
+
# check to ensure the input is an array given that the attribute
|
109
|
+
# is documented as an array but the input is not
|
110
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
111
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
112
|
+
end
|
113
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
114
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
115
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
116
|
+
end
|
117
|
+
|
118
|
+
self
|
119
|
+
end
|
120
|
+
|
121
|
+
# Deserializes the data based on type
|
122
|
+
# @param string type Data type
|
123
|
+
# @param string value Value to be deserialized
|
124
|
+
# @return [Object] Deserialized data
|
125
|
+
def _deserialize(type, value)
|
126
|
+
case type.to_sym
|
127
|
+
when :DateTime
|
128
|
+
DateTime.parse(value)
|
129
|
+
when :Date
|
130
|
+
Date.parse(value)
|
131
|
+
when :String
|
132
|
+
value.to_s
|
133
|
+
when :Integer
|
134
|
+
value.to_i
|
135
|
+
when :Float
|
136
|
+
value.to_f
|
137
|
+
when :BOOLEAN
|
138
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
139
|
+
true
|
140
|
+
else
|
141
|
+
false
|
142
|
+
end
|
143
|
+
when :Object
|
144
|
+
# generic object (usually a Hash), return directly
|
145
|
+
value
|
146
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
147
|
+
inner_type = Regexp.last_match[:inner_type]
|
148
|
+
value.map { |v| _deserialize(inner_type, v) }
|
149
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
150
|
+
k_type = Regexp.last_match[:k_type]
|
151
|
+
v_type = Regexp.last_match[:v_type]
|
152
|
+
{}.tap do |hash|
|
153
|
+
value.each do |k, v|
|
154
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
else # model
|
158
|
+
temp_model = CloudmersiveNlpApiClient.const_get(type).new
|
159
|
+
temp_model.build_from_hash(value)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the string representation of the object
|
164
|
+
# @return [String] String presentation of the object
|
165
|
+
def to_s
|
166
|
+
to_hash.to_s
|
167
|
+
end
|
168
|
+
|
169
|
+
# to_body is an alias to to_hash (backward compatibility)
|
170
|
+
# @return [Hash] Returns the object in the form of hash
|
171
|
+
def to_body
|
172
|
+
to_hash
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the object in the form of hash
|
176
|
+
# @return [Hash] Returns the object in the form of hash
|
177
|
+
def to_hash
|
178
|
+
hash = {}
|
179
|
+
self.class.attribute_map.each_pair do |attr, param|
|
180
|
+
value = self.send(attr)
|
181
|
+
next if value.nil?
|
182
|
+
hash[param] = _to_hash(value)
|
183
|
+
end
|
184
|
+
hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Outputs non-array value in the form of hash
|
188
|
+
# For object, use to_hash. Otherwise, just return the value
|
189
|
+
# @param [Object] value Any valid value
|
190
|
+
# @return [Hash] Returns the value in the form of hash
|
191
|
+
def _to_hash(value)
|
192
|
+
if value.is_a?(Array)
|
193
|
+
value.compact.map { |v| _to_hash(v) }
|
194
|
+
elsif value.is_a?(Hash)
|
195
|
+
{}.tap do |hash|
|
196
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
197
|
+
end
|
198
|
+
elsif value.respond_to? :to_hash
|
199
|
+
value.to_hash
|
200
|
+
else
|
201
|
+
value
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
end
|