paralleldots 3.2.2 → 3.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paralleldots.rb +1 -103
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f01b58e5dd43ef2fcc8168c8899e74779de8d8aa214f8bdd7f37d968d89a3e4
|
4
|
+
data.tar.gz: a968e7c598fc7b0cbb92ebfcc9e96cb44575abf60dcffa32bf97dc2b2726bd99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e0e1d16bc46f013827b4aace1f9d35e8bba99b12ff4700acf844adc7d2e26045abb4eecb95212c34360e381f002cedce2bb3dc5754418c1066737b7a75e0aa1
|
7
|
+
data.tar.gz: 3327c9b9d5332a0c0eca63cc03ff0da786b7ebf3d0036c4bad2169d6c76f4a82260a82364c080c52b9f0c1cab09c96c84cd6c5c392afae10d37a050f94316391
|
data/lib/paralleldots.rb
CHANGED
@@ -3,25 +3,8 @@ require 'rest-client'
|
|
3
3
|
require 'open-uri'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
-
def check( api_key, text )
|
7
|
-
if api_key == nil or api_key == "" then
|
8
|
-
return { "error": "API Key cannot be nil or an empty String." }
|
9
|
-
end
|
10
|
-
if text.class != String then
|
11
|
-
return { "error": "Input has to be a String." }
|
12
|
-
end
|
13
|
-
if text == "" then
|
14
|
-
return { "error": "Input cannot be an empty String." }
|
15
|
-
end
|
16
|
-
return true
|
17
|
-
end
|
18
|
-
|
19
6
|
def sentiment( text, lang_code= "en" )
|
20
7
|
api_key = get_api_key
|
21
|
-
valid = check( api_key, text )
|
22
|
-
if valid != true then
|
23
|
-
return valid
|
24
|
-
end
|
25
8
|
response = RestClient.post "https://apis.paralleldots.com/v3/sentiment", { api_key: api_key, text: text, lang_code: lang_code }
|
26
9
|
response = JSON.parse( response )
|
27
10
|
return response
|
@@ -29,10 +12,6 @@ end
|
|
29
12
|
|
30
13
|
def ner( text )
|
31
14
|
api_key = get_api_key
|
32
|
-
valid = check( api_key, text )
|
33
|
-
if valid != true then
|
34
|
-
return valid
|
35
|
-
end
|
36
15
|
response = RestClient.post "https://apis.paralleldots.com/v3/ner", { api_key: api_key, text: text }
|
37
16
|
response = JSON.parse( response )
|
38
17
|
return response
|
@@ -40,10 +19,6 @@ end
|
|
40
19
|
|
41
20
|
def keywords( text )
|
42
21
|
api_key = get_api_key
|
43
|
-
valid = check( api_key, text )
|
44
|
-
if valid != true then
|
45
|
-
return valid
|
46
|
-
end
|
47
22
|
response = RestClient.post "https://apis.paralleldots.com/v3/keywords", { api_key: api_key, text: text }
|
48
23
|
response = JSON.parse( response )
|
49
24
|
return response
|
@@ -51,10 +26,6 @@ end
|
|
51
26
|
|
52
27
|
def intent( text )
|
53
28
|
api_key = get_api_key
|
54
|
-
valid = check( api_key, text )
|
55
|
-
if valid != true then
|
56
|
-
return valid
|
57
|
-
end
|
58
29
|
response = RestClient.post "https://apis.paralleldots.com/v3/intent", { api_key: api_key, text: text }
|
59
30
|
response = JSON.parse( response )
|
60
31
|
return response
|
@@ -62,10 +33,6 @@ end
|
|
62
33
|
|
63
34
|
def emotion( text, lang_code= "en" )
|
64
35
|
api_key = get_api_key
|
65
|
-
valid = check( api_key, text )
|
66
|
-
if valid != true then
|
67
|
-
return valid
|
68
|
-
end
|
69
36
|
response = RestClient.post "https://apis.paralleldots.com/v3/emotion", { api_key: api_key, text: text, lang_code: lang_code }
|
70
37
|
response = JSON.parse( response )
|
71
38
|
return response
|
@@ -73,10 +40,6 @@ end
|
|
73
40
|
|
74
41
|
def abuse( text )
|
75
42
|
api_key = get_api_key
|
76
|
-
valid = check( api_key, text )
|
77
|
-
if valid != true then
|
78
|
-
return valid
|
79
|
-
end
|
80
43
|
response = RestClient.post "https://apis.paralleldots.com/v3/abuse", { api_key: api_key, text: text }
|
81
44
|
response = JSON.parse( response )
|
82
45
|
return response
|
@@ -84,10 +47,6 @@ end
|
|
84
47
|
|
85
48
|
def taxonomy( text )
|
86
49
|
api_key = get_api_key
|
87
|
-
valid = check( api_key, text )
|
88
|
-
if valid != true then
|
89
|
-
return valid
|
90
|
-
end
|
91
50
|
response = RestClient.post "https://apis.paralleldots.com/v3/taxonomy", { api_key: api_key, text: text }
|
92
51
|
response = JSON.parse( response )
|
93
52
|
return response
|
@@ -95,11 +54,6 @@ end
|
|
95
54
|
|
96
55
|
def similarity( text_1, text_2 )
|
97
56
|
api_key = get_api_key
|
98
|
-
valid_1 = check( api_key, text_1 )
|
99
|
-
valid_2 = check( api_key, text_2 )
|
100
|
-
if valid_1 != true or valid_2 != true then
|
101
|
-
return { text_1: valid_1, text_2: valid_2 }
|
102
|
-
end
|
103
57
|
response = RestClient.post "https://apis.paralleldots.com/v3/similarity", { api_key: api_key, text_1: text_1, text_2: text_2 }
|
104
58
|
response = JSON.parse( response )
|
105
59
|
return response
|
@@ -107,10 +61,6 @@ end
|
|
107
61
|
|
108
62
|
def custom_classifier( text, category )
|
109
63
|
api_key = get_api_key
|
110
|
-
valid = check( api_key, text )
|
111
|
-
if valid != true then
|
112
|
-
return valid
|
113
|
-
end
|
114
64
|
category = category.to_json
|
115
65
|
response = RestClient.post "https://apis.paralleldots.com/v3/custom_classifier", { api_key: api_key, text: text, category: category }
|
116
66
|
response = JSON.parse( response )
|
@@ -119,10 +69,6 @@ end
|
|
119
69
|
|
120
70
|
def phrase_extractor( text )
|
121
71
|
api_key = get_api_key
|
122
|
-
valid = check( api_key, text )
|
123
|
-
if valid != true then
|
124
|
-
return valid
|
125
|
-
end
|
126
72
|
response = RestClient.post "https://apis.paralleldots.com/v3/phrase_extractor", { api_key: api_key, text: text }
|
127
73
|
response = JSON.parse( response )
|
128
74
|
return response
|
@@ -130,10 +76,6 @@ end
|
|
130
76
|
|
131
77
|
def language_detection( text )
|
132
78
|
api_key = get_api_key
|
133
|
-
valid = check( api_key, text )
|
134
|
-
if valid != true then
|
135
|
-
return valid
|
136
|
-
end
|
137
79
|
response = RestClient.post "https://apis.paralleldots.com/v3/language_detection", { api_key: api_key, text: text }
|
138
80
|
response = JSON.parse( response )
|
139
81
|
return response
|
@@ -141,10 +83,6 @@ end
|
|
141
83
|
|
142
84
|
def text_parser( text )
|
143
85
|
api_key = get_api_key
|
144
|
-
valid = check( api_key, text )
|
145
|
-
if valid != true then
|
146
|
-
return valid
|
147
|
-
end
|
148
86
|
response = RestClient.post "https://apis.paralleldots.com/v3/text_parser", { api_key: api_key, text: text }
|
149
87
|
response = JSON.parse( response )
|
150
88
|
return response
|
@@ -152,10 +90,6 @@ end
|
|
152
90
|
|
153
91
|
def multilang_keywords( text, lang_code= "en" )
|
154
92
|
api_key = get_api_key
|
155
|
-
valid = check( api_key, text )
|
156
|
-
if valid != true then
|
157
|
-
return valid
|
158
|
-
end
|
159
93
|
response = RestClient.post "https://apis.paralleldots.com/v3/multilang_keywords", { api_key: api_key, text: text, lang_code: lang_code }
|
160
94
|
response = JSON.parse( response )
|
161
95
|
return response
|
@@ -163,10 +97,6 @@ end
|
|
163
97
|
|
164
98
|
def popularity( path )
|
165
99
|
api_key = get_api_key
|
166
|
-
valid = check( api_key, path )
|
167
|
-
if valid != true then
|
168
|
-
return valid
|
169
|
-
end
|
170
100
|
response = RestClient.post "https://apis.paralleldots.com/v3/popularity", { api_key: api_key, file: File.new( path ) }
|
171
101
|
response = JSON.parse( response )
|
172
102
|
return response
|
@@ -174,10 +104,6 @@ end
|
|
174
104
|
|
175
105
|
def nsfw( path )
|
176
106
|
api_key = get_api_key
|
177
|
-
valid = check( api_key, path )
|
178
|
-
if valid != true then
|
179
|
-
return valid
|
180
|
-
end
|
181
107
|
response = RestClient.post "https://apis.paralleldots.com/v3/nsfw", { api_key: api_key, file: File.new( path ) }
|
182
108
|
response = JSON.parse( response )
|
183
109
|
return response
|
@@ -185,10 +111,6 @@ end
|
|
185
111
|
|
186
112
|
def facial_emotion( path )
|
187
113
|
api_key = get_api_key
|
188
|
-
valid = check( api_key, path )
|
189
|
-
if valid != true then
|
190
|
-
return valid
|
191
|
-
end
|
192
114
|
response = RestClient.post "https://apis.paralleldots.com/v3/facial_emotion", { api_key: api_key, file: File.new( path ) }
|
193
115
|
response = JSON.parse( response )
|
194
116
|
return response
|
@@ -196,10 +118,6 @@ end
|
|
196
118
|
|
197
119
|
def object_recognizer( path )
|
198
120
|
api_key = get_api_key
|
199
|
-
valid = check( api_key, path )
|
200
|
-
if valid != true then
|
201
|
-
return valid
|
202
|
-
end
|
203
121
|
response = RestClient.post "https://apis.paralleldots.com/v3/object_recognizer", { api_key: api_key, file: File.new( path ) }
|
204
122
|
response = JSON.parse( response )
|
205
123
|
return response
|
@@ -207,56 +125,36 @@ end
|
|
207
125
|
|
208
126
|
def popularity_url( url )
|
209
127
|
api_key = get_api_key
|
210
|
-
valid = check( api_key, url )
|
211
|
-
if valid != true then
|
212
|
-
return valid
|
213
|
-
end
|
214
128
|
response = RestClient.post "https://apis.paralleldots.com/v3/popularity", { api_key: api_key, url: url }
|
215
129
|
response = JSON.parse( response )
|
216
|
-
response[ "usage" ] = "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: https://www.paralleldots.com/terms-and-conditions"
|
217
130
|
return response
|
218
131
|
end
|
219
132
|
|
220
133
|
def nsfw_url( url )
|
221
134
|
api_key = get_api_key
|
222
|
-
valid = check( api_key, url )
|
223
|
-
if valid != true then
|
224
|
-
return valid
|
225
|
-
end
|
226
135
|
response = RestClient.post "https://apis.paralleldots.com/v3/nsfw", { api_key: api_key, url: url }
|
227
136
|
response = JSON.parse( response )
|
228
|
-
response[ "usage" ] = "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: https://www.paralleldots.com/terms-and-conditions"
|
229
137
|
return response
|
230
138
|
end
|
231
139
|
|
232
140
|
def facial_emotion_url( url )
|
233
141
|
api_key = get_api_key
|
234
|
-
valid = check( api_key, url )
|
235
|
-
if valid != true then
|
236
|
-
return valid
|
237
|
-
end
|
238
142
|
response = RestClient.post "https://apis.paralleldots.com/v3/facial_emotion", { api_key: api_key, url: url }
|
239
143
|
response = JSON.parse( response )
|
240
|
-
response[ "usage" ] = "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: https://www.paralleldots.com/terms-and-conditions"
|
241
144
|
return response
|
242
145
|
end
|
243
146
|
|
244
147
|
def object_recognizer_url( url )
|
245
148
|
api_key = get_api_key
|
246
|
-
valid = check( api_key, url )
|
247
|
-
if valid != true then
|
248
|
-
return valid
|
249
|
-
end
|
250
149
|
response = RestClient.post "https://apis.paralleldots.com/v3/object_recognizer", { api_key: api_key, url: url }
|
251
150
|
response = JSON.parse( response )
|
252
|
-
response[ "usage" ] = "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: https://www.paralleldots.com/terms-and-conditions"
|
253
151
|
return response
|
254
152
|
end
|
255
153
|
|
256
154
|
def usage()
|
257
155
|
api_key = get_api_key
|
258
156
|
if api_key == nil or api_key == "" then
|
259
|
-
return { "
|
157
|
+
return { "Error": "API Key cannot be nil or an empty String." }
|
260
158
|
end
|
261
159
|
response = RestClient.post "https://apis.paralleldots.com/usage", { api_key: api_key }
|
262
160
|
response = JSON.parse( response )
|