Top Level Namespace
Instance Method Summary collapse
- #abuse(text) ⇒ Object
- #batch_abuse(data) ⇒ Object
- #batch_emotion(data, lang_code = "en") ⇒ Object
- #batch_intent(data) ⇒ Object
- #batch_keywords(data) ⇒ Object
- #batch_language_detection(data) ⇒ Object
- #batch_ner(data, lang_code = "en") ⇒ Object
- #batch_phrase_extractor(data) ⇒ Object
- #batch_sarcasm(data, lang_code = "en") ⇒ Object
- #batch_sentiment(data, lang_code = "en") ⇒ Object
- #batch_target_sentiment(data, entity) ⇒ Object
- #batch_taxonomy(data) ⇒ Object
- #custom_classifier(text, category) ⇒ Object
- #emotion(text, lang_code = "en") ⇒ Object
- #facial_emotion(path) ⇒ Object
- #facial_emotion_url(url) ⇒ Object
- #get_api_key ⇒ Object
- #intent(text) ⇒ Object
- #keywords(text) ⇒ Object
- #language_detection(text) ⇒ Object
- #multilang_keywords(text, lang_code = "en") ⇒ Object
- #ner(text, lang_code = "en") ⇒ Object
- #nsfw(path) ⇒ Object
- #nsfw_url(url) ⇒ Object
- #object_recognizer(path) ⇒ Object
- #object_recognizer_url(url) ⇒ Object
- #phrase_extractor(text) ⇒ Object
- #popularity(path) ⇒ Object
- #popularity_url(url) ⇒ Object
- #sarcasm(text, lang_code = "en") ⇒ Object
- #sentiment(text, lang_code = "en") ⇒ Object
- #set_api_key(api_key) ⇒ Object
- #similarity(text_1, text_2) ⇒ Object
- #target_sentiment(text, entity) ⇒ Object
- #taxonomy(text) ⇒ Object
- #text_parser(text) ⇒ Object
- #usage ⇒ Object
Instance Method Details
#abuse(text) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/paralleldots.rb', line 55 def abuse( text ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/abuse", { api_key: api_key, text: text } response = JSON.parse( response ) return response end |
#batch_abuse(data) ⇒ Object
186 187 188 189 190 191 |
# File 'lib/paralleldots.rb', line 186 def batch_abuse( data ) api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/abuse_batch", { "text": data.to_json, "api_key": api_key } response = JSON.parse( response ) return response end |
#batch_emotion(data, lang_code = "en") ⇒ Object
235 236 237 238 239 240 |
# File 'lib/paralleldots.rb', line 235 def batch_emotion( data, lang_code="en") api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/emotion_batch", { "text": data.to_json, "api_key": api_key, "lang_code":lang_code} response = JSON.parse( response ) return response end |
#batch_intent(data) ⇒ Object
179 180 181 182 183 184 |
# File 'lib/paralleldots.rb', line 179 def batch_intent( data ) api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/intent_batch", { "text": data.to_json, "api_key": api_key } response = JSON.parse( response ) return response end |
#batch_keywords(data) ⇒ Object
221 222 223 224 225 226 |
# File 'lib/paralleldots.rb', line 221 def batch_keywords( data ) api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/keywords_batch", { "text": data.to_json, "api_key": api_key } response = JSON.parse( response ) return response end |
#batch_language_detection(data) ⇒ Object
207 208 209 210 211 212 |
# File 'lib/paralleldots.rb', line 207 def batch_language_detection( data ) api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/language_detection_batch", { "text": data.to_json, "api_key": api_key } response = JSON.parse( response ) return response end |
#batch_ner(data, lang_code = "en") ⇒ Object
193 194 195 196 197 198 |
# File 'lib/paralleldots.rb', line 193 def batch_ner( data, lang_code="en") api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/ner_batch", { "text": data.to_json, "api_key": api_key, "lang_code":lang_code} response = JSON.parse( response ) return response end |
#batch_phrase_extractor(data) ⇒ Object
214 215 216 217 218 219 |
# File 'lib/paralleldots.rb', line 214 def batch_phrase_extractor( data ) api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/phrase_extractor_batch", { "text": data.to_json, "api_key": api_key } response = JSON.parse( response ) return response end |
#batch_sarcasm(data, lang_code = "en") ⇒ Object
242 243 244 245 246 247 |
# File 'lib/paralleldots.rb', line 242 def batch_sarcasm( data, lang_code="en") api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/sarcasm_batch", { "text": data.to_json, "api_key": api_key, "lang_code":lang_code} response = JSON.parse( response ) return response end |
#batch_sentiment(data, lang_code = "en") ⇒ Object
228 229 230 231 232 233 |
# File 'lib/paralleldots.rb', line 228 def batch_sentiment( data, lang_code="en") api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/sentiment_batch", { "text": data.to_json, "api_key": api_key, "lang_code":lang_code} response = JSON.parse( response ) return response end |
#batch_target_sentiment(data, entity) ⇒ Object
249 250 251 252 253 254 |
# File 'lib/paralleldots.rb', line 249 def batch_target_sentiment( data, entity ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/target/sentiment_batch", { "api_key": api_key, "text": data.to_json, "entity": entity } response = JSON.parse( response ) return response end |
#batch_taxonomy(data) ⇒ Object
200 201 202 203 204 205 |
# File 'lib/paralleldots.rb', line 200 def batch_taxonomy( data ) api_key = get_api_key() response = RestClient.post "https://apis.paralleldots.com/v4/taxonomy_batch", { "text": data.to_json, "api_key": api_key } response = JSON.parse( response ) return response end |
#custom_classifier(text, category) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/paralleldots.rb', line 76 def custom_classifier( text, category ) api_key = get_api_key category = category.to_json response = RestClient.post "https://apis.paralleldots.com/v4/custom_classifier", { api_key: api_key, text: text, category: category } response = JSON.parse( response ) return response end |
#emotion(text, lang_code = "en") ⇒ Object
34 35 36 37 38 39 |
# File 'lib/paralleldots.rb', line 34 def emotion( text, lang_code= "en" ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/emotion", { api_key: api_key, text: text, lang_code: lang_code } response = JSON.parse( response ) return response end |
#facial_emotion(path) ⇒ Object
126 127 128 129 130 131 |
# File 'lib/paralleldots.rb', line 126 def facial_emotion( path ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/facial_emotion", { api_key: api_key, file: File.new( path ) } response = JSON.parse( response ) return response end |
#facial_emotion_url(url) ⇒ Object
154 155 156 157 158 159 |
# File 'lib/paralleldots.rb', line 154 def facial_emotion_url( url ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/facial_emotion", { api_key: api_key, url: url } response = JSON.parse( response ) return response end |
#get_api_key ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/config.rb', line 12 def get_api_key begin config = ParseConfig.new( "paralleldots_key.conf" ) return config[ "PD" ] rescue puts "No API Key Found." return end end |
#intent(text) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/paralleldots.rb', line 27 def intent( text ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/intent", { api_key: api_key, text: text } response = JSON.parse( response ) return response end |
#keywords(text) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/paralleldots.rb', line 20 def keywords( text ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/keywords", { api_key: api_key, text: text } response = JSON.parse( response ) return response end |
#language_detection(text) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/paralleldots.rb', line 91 def language_detection( text ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/language_detection", { api_key: api_key, text: text } response = JSON.parse( response ) return response end |
#multilang_keywords(text, lang_code = "en") ⇒ Object
105 106 107 108 109 110 |
# File 'lib/paralleldots.rb', line 105 def multilang_keywords( text, lang_code= "en" ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/multilang_keywords", { api_key: api_key, text: text, lang_code: lang_code } response = JSON.parse( response ) return response end |
#ner(text, lang_code = "en") ⇒ Object
13 14 15 16 17 18 |
# File 'lib/paralleldots.rb', line 13 def ner( text,lang_code = "en" ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/ner", { api_key: api_key, text: text, lang_code: lang_code } response = JSON.parse( response ) return response end |
#nsfw(path) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/paralleldots.rb', line 119 def nsfw( path ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/nsfw", { api_key: api_key, file: File.new( path ) } response = JSON.parse( response ) return response end |
#nsfw_url(url) ⇒ Object
147 148 149 150 151 152 |
# File 'lib/paralleldots.rb', line 147 def nsfw_url( url ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/nsfw", { api_key: api_key, url: url } response = JSON.parse( response ) return response end |
#object_recognizer(path) ⇒ Object
133 134 135 136 137 138 |
# File 'lib/paralleldots.rb', line 133 def object_recognizer( path ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/object_recognizer", { api_key: api_key, file: File.new( path ) } response = JSON.parse( response ) return response end |
#object_recognizer_url(url) ⇒ Object
161 162 163 164 165 166 |
# File 'lib/paralleldots.rb', line 161 def object_recognizer_url( url ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/object_recognizer", { api_key: api_key, url: url } response = JSON.parse( response ) return response end |
#phrase_extractor(text) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/paralleldots.rb', line 84 def phrase_extractor( text ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/phrase_extractor", { api_key: api_key, text: text } response = JSON.parse( response ) return response end |
#popularity(path) ⇒ Object
112 113 114 115 116 117 |
# File 'lib/paralleldots.rb', line 112 def popularity( path ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/popularity", { api_key: api_key, file: File.new( path ) } response = JSON.parse( response ) return response end |
#popularity_url(url) ⇒ Object
140 141 142 143 144 145 |
# File 'lib/paralleldots.rb', line 140 def popularity_url( url ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/popularity", { api_key: api_key, url: url } response = JSON.parse( response ) return response end |
#sarcasm(text, lang_code = "en") ⇒ Object
41 42 43 44 45 46 |
# File 'lib/paralleldots.rb', line 41 def sarcasm( text, lang_code= "en" ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/sarcasm", { api_key: api_key, text: text, lang_code: lang_code } response = JSON.parse( response ) return response end |
#sentiment(text, lang_code = "en") ⇒ Object
6 7 8 9 10 11 |
# File 'lib/paralleldots.rb', line 6 def sentiment( text, lang_code= "en" ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/sentiment", { api_key: api_key, text: text, lang_code: lang_code } response = JSON.parse( response ) return response end |
#set_api_key(api_key) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/config.rb', line 3 def set_api_key( api_key ) file = File.open( 'paralleldots_key.conf', 'w' ) config = ParseConfig.new( file ) config.add( "PD", api_key ) config.write( file ) file.close puts "API Key Set.\nKey Value: %s"%api_key end |
#similarity(text_1, text_2) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/paralleldots.rb', line 69 def similarity( text_1, text_2 ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/similarity", { api_key: api_key, text_1: text_1, text_2: text_2 } response = JSON.parse( response ) return response end |
#target_sentiment(text, entity) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/paralleldots.rb', line 48 def target_sentiment( text, entity ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/target/sentiment", { api_key: api_key, text: text, entity: entity } response = JSON.parse( response ) return response end |
#taxonomy(text) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/paralleldots.rb', line 62 def taxonomy( text ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/taxonomy", { api_key: api_key, text: text } response = JSON.parse( response ) return response end |
#text_parser(text) ⇒ Object
98 99 100 101 102 103 |
# File 'lib/paralleldots.rb', line 98 def text_parser( text ) api_key = get_api_key response = RestClient.post "https://apis.paralleldots.com/v4/text_parser", { api_key: api_key, text: text } response = JSON.parse( response ) return response end |
#usage ⇒ Object
168 169 170 171 172 173 174 175 176 |
# File 'lib/paralleldots.rb', line 168 def usage() api_key = get_api_key if api_key == nil or api_key == "" then return { "Error": "API Key cannot be nil or an empty String." } end response = RestClient.post "https://apis.paralleldots.com/usage", { api_key: api_key } response = JSON.parse( response ) return response end |