paralleldots 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +79 -0
- data/lib/config.rb +21 -0
- data/lib/paralleldots.rb +126 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 25841565850c535803bdcf3ae83336a1a22ae61b
|
4
|
+
data.tar.gz: 962369f8568f75022524a08dbb70df5222fbfefb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b4cedf1f76bf0ae3ef3295076ecf0d2ef015a6e7c897de648f1436c3fe4a636021d9cef78e000c405bcee4949f25abf5121ba9c1f63f1ef8d40b984181f41f5
|
7
|
+
data.tar.gz: 59d49369b217c2128173eafdbdd8f4428a1b5b9bddb7acb24e670b8e1aa365ce99e3572b89b289eb4685b62b6f42c681334128cfe8442fe645f9d947e15a93a6
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
ParallelDots Ruby API
|
2
|
+
=======================
|
3
|
+
|
4
|
+
A wrapper for the [ParallelDots API](http://www.paralleldots.com).
|
5
|
+
|
6
|
+
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
From Gem:
|
10
|
+
|
11
|
+
gem install paralleldots
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
API Keys + Setup
|
16
|
+
----------------
|
17
|
+
Signup and get your free API key from [ParallelDots]( http://www.paralleldots.com/pricing).
|
18
|
+
You will receive a mail containing the API key at the registered email id.
|
19
|
+
|
20
|
+
Configuration:
|
21
|
+
|
22
|
+
|
23
|
+
> require 'paralleldots'
|
24
|
+
|
25
|
+
# Setting your API key
|
26
|
+
> set_api_key("YOUR API KEY")
|
27
|
+
|
28
|
+
# Viewing your API key
|
29
|
+
> get_api_key()
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
Supported APIs:
|
34
|
+
---------------
|
35
|
+
|
36
|
+
- [Semantic Similarity](https://tinyurl.com/k23nqs9)
|
37
|
+
- [Sentiment Analysis](https://tinyurl.com/km99mzb)
|
38
|
+
- Taxonomy
|
39
|
+
- [Named Entity Extraction ( NER )](https://tinyurl.com/k9yglwc)
|
40
|
+
- [Keywords](https://tinyurl.com/kujcu8o)
|
41
|
+
- [Intent](https://tinyurl.com/n568bqw)
|
42
|
+
- Emotion
|
43
|
+
- Abuse
|
44
|
+
- Multiple Language Sentiment
|
45
|
+
- Portuguese ( pt )
|
46
|
+
- French ( fr )
|
47
|
+
|
48
|
+
Examples
|
49
|
+
--------
|
50
|
+
|
51
|
+
|
52
|
+
> require 'paralleldots'
|
53
|
+
|
54
|
+
> similarity( "Sachin is the greatest batsman", "Tendulkar is the finest cricketer" )
|
55
|
+
{"actual_score": 0.8429316099720955, "normalized_score": 4.931468684177398, "similarity": 4.931468684177398}
|
56
|
+
|
57
|
+
> sentiment( "Come on, lets play together" )
|
58
|
+
{"sentiment": 0.8513014912605286}
|
59
|
+
|
60
|
+
> taxonomy( "Narendra Modi is the prime minister of India" )
|
61
|
+
{"tags": [[u"finance", 4.088], [u"government", 3.4284], [u"business", 1.2719]]}
|
62
|
+
|
63
|
+
> ner( "Narendra Modi is the prime minister of India" )
|
64
|
+
{"entities": [[u"Modi", 1.0, [u"person"], u""], [u"India", 1.0, [u"org"], u""], [u"Narendra", 1.0, [u"org"], u""]]}
|
65
|
+
|
66
|
+
> keywords( "Prime Minister Narendra Modi tweeted a link to the speech Human Resource Development Minister Smriti Irani made in the Lok Sabha during the debate on the ongoing JNU row and the suicide of Dalit scholar Rohith Vemula at the Hyderabad Central University." )
|
67
|
+
{"keywords": [[u"Human Resource Development Minister Smriti Irani", 6], [u"Prime Minister Narendra Modi", 4], [u"Hyderabad Central University", 3], [u"ongoing JNU row", 3], [u"Dalit scholar", 2], [u"Lok Sabha", 2], [u"Rohith Vemula", 2]]}
|
68
|
+
|
69
|
+
> emotion("Did you hear the latest Porcupine Tree song ? It's rocking !")
|
70
|
+
{"emotion": "happy"}
|
71
|
+
|
72
|
+
> intent("Finance ministry calls banks to discuss new facility to drain cash")
|
73
|
+
{"intent": "news"}
|
74
|
+
|
75
|
+
> abuse("you f**king a$$hole")
|
76
|
+
{"confidence_score"=>0.998047, "sentence_type"=>"Abusive"}
|
77
|
+
|
78
|
+
> multilang_sentiment("La ville de Paris est très belle", "fr")
|
79
|
+
{"sentiment": "positive", "confidence_score": 0.998047}
|
data/lib/config.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'parseconfig'
|
2
|
+
|
3
|
+
def set_api_key( api_key )
|
4
|
+
file = File.open( 'paralleldots_key.conf', 'w' )
|
5
|
+
config = ParseConfig.new( file )
|
6
|
+
config.add( "PD", api_key )
|
7
|
+
config.write( file )
|
8
|
+
file.close
|
9
|
+
puts "API Key Set.\nKey Value: %s"%api_key
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_api_key
|
13
|
+
begin
|
14
|
+
config = ParseConfig.new( "paralleldots_key.conf" )
|
15
|
+
return config[ "PD" ]
|
16
|
+
|
17
|
+
rescue
|
18
|
+
puts "No API Key Found."
|
19
|
+
return
|
20
|
+
end
|
21
|
+
end
|
data/lib/paralleldots.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require_relative 'config'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
def check( api_key, text )
|
6
|
+
if api_key == nil or api_key == "" then
|
7
|
+
return { "error": "API Key cannot be nil or an empty String." }
|
8
|
+
end
|
9
|
+
if text.class != String then
|
10
|
+
return { "error": "Input has to be a String." }
|
11
|
+
end
|
12
|
+
if text == "" then
|
13
|
+
return { "error": "Input cannot be an empty String." }
|
14
|
+
end
|
15
|
+
return true
|
16
|
+
end
|
17
|
+
|
18
|
+
def sentiment( text )
|
19
|
+
api_key = get_api_key
|
20
|
+
valid = check( api_key, text )
|
21
|
+
if valid != true then
|
22
|
+
return valid
|
23
|
+
end
|
24
|
+
response = RestClient.get "http://apis.paralleldots.com/sentiment", { params: { apikey: api_key, sentence1: text } }
|
25
|
+
response = JSON.parse( response )
|
26
|
+
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: http://www.paralleldots.com/terms-and-conditions"
|
27
|
+
return response
|
28
|
+
end
|
29
|
+
|
30
|
+
def ner( text )
|
31
|
+
api_key = get_api_key
|
32
|
+
valid = check( api_key, text )
|
33
|
+
if valid != true then
|
34
|
+
return valid
|
35
|
+
end
|
36
|
+
response = RestClient.post "http://apis.paralleldots.com/ner", { "apikey" => api_key, "text" => text }.to_json
|
37
|
+
response = JSON.parse( response )
|
38
|
+
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: http://www.paralleldots.com/terms-and-conditions"
|
39
|
+
return response
|
40
|
+
end
|
41
|
+
|
42
|
+
def keywords( text )
|
43
|
+
api_key = get_api_key
|
44
|
+
valid = check( api_key, text )
|
45
|
+
if valid != true then
|
46
|
+
return valid
|
47
|
+
end
|
48
|
+
response = RestClient.post "http://apis.paralleldots.com/keywords", { apikey: api_key, q: text }
|
49
|
+
response = JSON.parse( response )
|
50
|
+
response = { "keywords": 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: http://www.paralleldots.com/terms-and-conditions" }
|
51
|
+
return response
|
52
|
+
end
|
53
|
+
|
54
|
+
def intent( text )
|
55
|
+
api_key = get_api_key
|
56
|
+
valid = check( api_key, text )
|
57
|
+
if valid != true then
|
58
|
+
return valid
|
59
|
+
end
|
60
|
+
response = RestClient.post "http://apis.paralleldots.com/intent", { apikey: api_key, text: text }
|
61
|
+
response = JSON.parse( response )
|
62
|
+
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: http://www.paralleldots.com/terms-and-conditions"
|
63
|
+
return response
|
64
|
+
end
|
65
|
+
|
66
|
+
def emotion( text )
|
67
|
+
api_key = get_api_key
|
68
|
+
valid = check( api_key, text )
|
69
|
+
if valid != true then
|
70
|
+
return valid
|
71
|
+
end
|
72
|
+
response = RestClient.post "http://apis.paralleldots.com/emotion", { apikey: api_key, text: text }
|
73
|
+
response = JSON.parse( response )
|
74
|
+
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: http://www.paralleldots.com/terms-and-conditions"
|
75
|
+
return response
|
76
|
+
end
|
77
|
+
|
78
|
+
def abuse( text )
|
79
|
+
api_key = get_api_key
|
80
|
+
valid = check( api_key, text )
|
81
|
+
if valid != true then
|
82
|
+
return valid
|
83
|
+
end
|
84
|
+
response = RestClient.post "http://apis.paralleldots.com/abuse", { apikey: api_key, text: text }
|
85
|
+
response = JSON.parse( response )
|
86
|
+
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: http://www.paralleldots.com/terms-and-conditions"
|
87
|
+
return response
|
88
|
+
end
|
89
|
+
|
90
|
+
def taxonomy( text )
|
91
|
+
api_key = get_api_key
|
92
|
+
valid = check( api_key, text )
|
93
|
+
if valid != true then
|
94
|
+
return valid
|
95
|
+
end
|
96
|
+
response = RestClient.post "http://apis.paralleldots.com/taxonomy", { "apikey" => api_key, "sentence1" => text }.to_json
|
97
|
+
response = JSON.parse( response )
|
98
|
+
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: http://www.paralleldots.com/terms-and-conditions"
|
99
|
+
return response
|
100
|
+
end
|
101
|
+
|
102
|
+
def similarity( text_1, text_2 )
|
103
|
+
api_key = get_api_key
|
104
|
+
valid_1 = check( api_key, text_1 )
|
105
|
+
valid_2 = check( api_key, text_2 )
|
106
|
+
if valid_1 != true or valid_2 != true then
|
107
|
+
return { "text_1": valid_1, "text_2": valid_2 }
|
108
|
+
end
|
109
|
+
response = RestClient.get "http://apis.paralleldots.com/semanticsimilarity", { params: { apikey: api_key, sentence1: text_1, sentence2: text_2 } }
|
110
|
+
response = JSON.parse( response )
|
111
|
+
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: http://www.paralleldots.com/terms-and-conditions"
|
112
|
+
return response
|
113
|
+
end
|
114
|
+
|
115
|
+
def multilang_sentiment( text, lang )
|
116
|
+
api_key = get_api_key
|
117
|
+
valid_1 = check( api_key, text )
|
118
|
+
valid_2 = check( api_key, lang )
|
119
|
+
if valid_1 != true or valid_2 != true then
|
120
|
+
return { "text": valid_1, "lang": valid_2 }
|
121
|
+
end
|
122
|
+
response = RestClient.post "http://apis.paralleldots.com/multilang_sentiment", { apikey: api_key, text: text, lang: lang }
|
123
|
+
response = JSON.parse( response )
|
124
|
+
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: http://www.paralleldots.com/terms-and-conditions"
|
125
|
+
return response
|
126
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paralleldots
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Meghdeep Ray
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: parseconfig
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.8
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.8
|
41
|
+
description: Ruby Wrapper for ParallelDots APIs
|
42
|
+
email: meghdeepr@paralleldots.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files:
|
46
|
+
- README.md
|
47
|
+
files:
|
48
|
+
- README.md
|
49
|
+
- lib/config.rb
|
50
|
+
- lib/paralleldots.rb
|
51
|
+
homepage: http://rubygems.org/gems/paralleldots
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata: {}
|
55
|
+
post_install_message: |-
|
56
|
+
Installation Comlete !
|
57
|
+
Get your free API key: https://www.paralleldots.com/text-analysis-apis
|
58
|
+
Docs: https://www.paralleldots.com/docs/
|
59
|
+
Happy Coding !
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.5.1
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Ruby Wrapper for ParallelDots APIs
|
79
|
+
test_files: []
|