indico 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/PULL_REQUEST_TEMPLATE +37 -0
- data/lib/indico/helper.rb +3 -3
- data/lib/indico/version.rb +1 -1
- data/lib/indico.rb +11 -2
- data/spec/indico_batch_spec.rb +0 -9
- data/spec/indico_spec.rb +0 -18
- data/spec/political_spec.rb +48 -0
- metadata +13 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a07e355897fb68aed8c2fc6b2cf73a52a315360a
|
4
|
+
data.tar.gz: 5dc85c207c80641e80fdad1aa9ce4f02500a52d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a8f30adba9ff040c18ea09f6078a5a39b4b6e3711ac585af7fc0eea701762623c16f192d0f4aec6472328cffb1987c3f5ca540f8d69c24c85ce40aabae80293c
|
7
|
+
data.tar.gz: afa96e01d407b2a7f6d32fa22816b1282394e31be44e3684b474a949116534d90cd2600a6bfa0a2165b8dcc645382e36232bb208a6db07647bd6a986078f4b39
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
<!--- For the author to fill in -->
|
3
|
+
Reviewers:
|
4
|
+
----------
|
5
|
+
<!--- Check yourself off the list after review -->
|
6
|
+
- [ ] @mention
|
7
|
+
|
8
|
+
What's the purpose of the PR?
|
9
|
+
-----------------------------
|
10
|
+
<!--- Does it resolve an issue? Does it add a feature? Is it a refactor? -->
|
11
|
+
<!--- Trello ticket links? Design document links?-->
|
12
|
+
<!--- List out intended functionality. -->
|
13
|
+
|
14
|
+
Description of changes
|
15
|
+
----------------------
|
16
|
+
<!--- What code was changed? Why? -->
|
17
|
+
|
18
|
+
Notes to reviewers
|
19
|
+
------------------
|
20
|
+
<!--- Is there anything in particular you want reviewers to check for? -->
|
21
|
+
|
22
|
+
|
23
|
+
<!--- For the reviewer -->
|
24
|
+
Keep in mind while reviewing code:
|
25
|
+
----------------------------------
|
26
|
+
- Is relevant code tested?
|
27
|
+
- Are added functions/methods documented?
|
28
|
+
- Separation of concerns (SOC)
|
29
|
+
- Don't repeat yourself (DRY)
|
30
|
+
- Limit the number of positional arguments
|
31
|
+
- Is function/method length reasonable?
|
32
|
+
- Can code be broken down into smaller components?
|
33
|
+
- Where do added functions/methods belong?
|
34
|
+
- Are variable names descriptive?
|
35
|
+
- Are errors handled appropriately?
|
36
|
+
- Can logic be simplified?
|
37
|
+
- Does the code make sense in context? (expand the diff)
|
data/lib/indico/helper.rb
CHANGED
@@ -10,7 +10,7 @@ module Indico
|
|
10
10
|
Indico.cloud_protocol + root + '.indico.domains/' + api
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def self.api_handler(data, api, config, method='predict')
|
15
15
|
server = nil
|
16
16
|
api_key = nil
|
@@ -27,7 +27,7 @@ module Indico
|
|
27
27
|
|
28
28
|
api += (method != "predict" ? ("/" + method) : "")
|
29
29
|
|
30
|
-
|
30
|
+
if config
|
31
31
|
server = config.delete('cloud')
|
32
32
|
api_key = config.delete('api_key')
|
33
33
|
apis = config.delete('apis')
|
@@ -41,7 +41,7 @@ module Indico
|
|
41
41
|
if api_key.nil?
|
42
42
|
raise ArgumentError, 'api key is required'
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
url_params = Array.new
|
46
46
|
if apis
|
47
47
|
url_params.push(['apis', apis.join(",")])
|
data/lib/indico/version.rb
CHANGED
data/lib/indico.rb
CHANGED
@@ -26,6 +26,12 @@ module Indico
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.political(text, config = nil)
|
29
|
+
if !config
|
30
|
+
config = {}
|
31
|
+
end
|
32
|
+
if !config.key?(:v) and !config.key?(:version)
|
33
|
+
config['version'] = "2"
|
34
|
+
end
|
29
35
|
api_handler(text, 'political', config)
|
30
36
|
end
|
31
37
|
|
@@ -66,10 +72,13 @@ module Indico
|
|
66
72
|
end
|
67
73
|
|
68
74
|
def self.keywords(text, config = nil)
|
69
|
-
|
75
|
+
if !config
|
76
|
+
config = {}
|
77
|
+
end
|
78
|
+
if !config.key?(:v) and !config.key?(:version)
|
70
79
|
config['version'] = "2"
|
71
80
|
end
|
72
|
-
if config
|
81
|
+
if config.key?(:language) and config[:language] != "english"
|
73
82
|
config['version'] = "1"
|
74
83
|
end
|
75
84
|
api_handler(text, 'keywords', config)
|
data/spec/indico_batch_spec.rb
CHANGED
@@ -12,15 +12,6 @@ describe Indico do
|
|
12
12
|
TEXT_APIS.delete("sentiment_hq")
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'should tag text with correct political tags' do
|
16
|
-
expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
|
17
|
-
data = ['Guns don\'t kill people.', ' People kill people.']
|
18
|
-
response = Indico.political(data, @config)
|
19
|
-
|
20
|
-
expect(Set.new(response[0].keys)).to eql(expected_keys)
|
21
|
-
expect(Set.new(response[1].keys)).to eql(expected_keys)
|
22
|
-
end
|
23
|
-
|
24
15
|
it 'should tag text with correct emotion tags' do
|
25
16
|
expected_keys = Set.new(%w(anger fear joy sadness surprise))
|
26
17
|
data = "I did it. I got into Grad School. Not just any program, but a GREAT program. :-)"
|
data/spec/indico_spec.rb
CHANGED
@@ -11,13 +11,6 @@ describe Indico do
|
|
11
11
|
@config = { api_key: api_key, cloud: private_cloud}
|
12
12
|
end
|
13
13
|
|
14
|
-
it 'should tag text with correct political tags' do
|
15
|
-
expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
|
16
|
-
response = Indico.political('Guns don\'t kill people. People kill people.')
|
17
|
-
|
18
|
-
expect(Set.new(response.keys)).to eql(expected_keys)
|
19
|
-
end
|
20
|
-
|
21
14
|
it 'should return personality values for text' do
|
22
15
|
expected_keys = Set.new(%w(openness extraversion conscientiousness agreeableness))
|
23
16
|
response = Indico.personality('I love my friends!')
|
@@ -34,17 +27,6 @@ describe Indico do
|
|
34
27
|
end
|
35
28
|
end
|
36
29
|
|
37
|
-
it 'should tag text with correct political tags' do
|
38
|
-
expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
|
39
|
-
data = 'Guns don\'t kill people. People kill people.'
|
40
|
-
|
41
|
-
# for mocking: use http to redirect requests to our public cloud endpoint
|
42
|
-
Indico.cloud_protocol = 'http://'
|
43
|
-
response = Indico.political(data, @config)
|
44
|
-
Indico.cloud_protocol = 'https://'
|
45
|
-
expect(Set.new(response.keys)).to eql(expected_keys)
|
46
|
-
end
|
47
|
-
|
48
30
|
it 'should tag text with correct emotion tags' do
|
49
31
|
expected_keys = Set.new(%w(anger fear joy sadness surprise))
|
50
32
|
data = "I did it. I got into Grad School. Not just any program, but a GREAT program. :-)"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Indico do
|
4
|
+
before do
|
5
|
+
api_key = ENV['INDICO_API_KEY']
|
6
|
+
private_cloud = 'indico-test'
|
7
|
+
@config = { api_key: api_key, cloud: private_cloud}
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should tag text with correct political tags' do
|
11
|
+
expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
|
12
|
+
data = ['Guns don\'t kill people.', ' People kill people.']
|
13
|
+
response = Indico.political(data, @config)
|
14
|
+
|
15
|
+
expect(Set.new(response[0].keys)).to eql(expected_keys)
|
16
|
+
expect(Set.new(response[1].keys)).to eql(expected_keys)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should tag text with correct political tags' do
|
20
|
+
expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
|
21
|
+
response = Indico.political('Guns don\'t kill people. People kill people.')
|
22
|
+
|
23
|
+
expect(Set.new(response.keys)).to eql(expected_keys)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'single political should return the right response' do
|
27
|
+
expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
|
28
|
+
|
29
|
+
config = @config.clone
|
30
|
+
config["version"] = 1
|
31
|
+
response = Indico.political('Guns don\'t kill people. People kill people.')
|
32
|
+
|
33
|
+
expect(Set.new(response.keys)).to eql(expected_keys)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'batch political should return the right response' do
|
37
|
+
expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
|
38
|
+
data = 'Guns don\'t kill people. People kill people.'
|
39
|
+
|
40
|
+
config = @config.clone
|
41
|
+
config["version"] = 1
|
42
|
+
response = Indico.political([data, data])
|
43
|
+
|
44
|
+
expect(response.length).to eql(2)
|
45
|
+
expect(Set.new(response[0].keys)).to eql(expected_keys)
|
46
|
+
expect(Set.new(response[1].keys)).to eql(expected_keys)
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
5
|
-
prerelease:
|
4
|
+
version: 0.9.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Slater Victoroff
|
@@ -12,12 +11,11 @@ authors:
|
|
12
11
|
autorequire:
|
13
12
|
bindir: bin
|
14
13
|
cert_chain: []
|
15
|
-
date: 2016-
|
14
|
+
date: 2016-06-17 00:00:00.000000000 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: inifile
|
19
18
|
requirement: !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
19
|
requirements:
|
22
20
|
- - ~>
|
23
21
|
- !ruby/object:Gem::Version
|
@@ -25,7 +23,6 @@ dependencies:
|
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
27
|
- - ~>
|
31
28
|
- !ruby/object:Gem::Version
|
@@ -33,7 +30,6 @@ dependencies:
|
|
33
30
|
- !ruby/object:Gem::Dependency
|
34
31
|
name: oily_png
|
35
32
|
requirement: !ruby/object:Gem::Requirement
|
36
|
-
none: false
|
37
33
|
requirements:
|
38
34
|
- - ~>
|
39
35
|
- !ruby/object:Gem::Version
|
@@ -41,7 +37,6 @@ dependencies:
|
|
41
37
|
type: :runtime
|
42
38
|
prerelease: false
|
43
39
|
version_requirements: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
40
|
requirements:
|
46
41
|
- - ~>
|
47
42
|
- !ruby/object:Gem::Version
|
@@ -49,7 +44,6 @@ dependencies:
|
|
49
44
|
- !ruby/object:Gem::Dependency
|
50
45
|
name: bundler
|
51
46
|
requirement: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
47
|
requirements:
|
54
48
|
- - ~>
|
55
49
|
- !ruby/object:Gem::Version
|
@@ -57,7 +51,6 @@ dependencies:
|
|
57
51
|
type: :development
|
58
52
|
prerelease: false
|
59
53
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
54
|
requirements:
|
62
55
|
- - ~>
|
63
56
|
- !ruby/object:Gem::Version
|
@@ -65,33 +58,29 @@ dependencies:
|
|
65
58
|
- !ruby/object:Gem::Dependency
|
66
59
|
name: rake
|
67
60
|
requirement: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
61
|
requirements:
|
70
|
-
- -
|
62
|
+
- - '>='
|
71
63
|
- !ruby/object:Gem::Version
|
72
64
|
version: '0'
|
73
65
|
type: :development
|
74
66
|
prerelease: false
|
75
67
|
version_requirements: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
68
|
requirements:
|
78
|
-
- -
|
69
|
+
- - '>='
|
79
70
|
- !ruby/object:Gem::Version
|
80
71
|
version: '0'
|
81
72
|
- !ruby/object:Gem::Dependency
|
82
73
|
name: rspec
|
83
74
|
requirement: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
75
|
requirements:
|
86
|
-
- -
|
76
|
+
- - '>='
|
87
77
|
- !ruby/object:Gem::Version
|
88
78
|
version: '0'
|
89
79
|
type: :development
|
90
80
|
prerelease: false
|
91
81
|
version_requirements: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
82
|
requirements:
|
94
|
-
- -
|
83
|
+
- - '>='
|
95
84
|
- !ruby/object:Gem::Version
|
96
85
|
version: '0'
|
97
86
|
description: A simple Ruby Wrapper for the indico set of APIs.
|
@@ -104,6 +93,7 @@ executables: []
|
|
104
93
|
extensions: []
|
105
94
|
extra_rdoc_files: []
|
106
95
|
files:
|
96
|
+
- .github/PULL_REQUEST_TEMPLATE
|
107
97
|
- .gitignore
|
108
98
|
- .rspec
|
109
99
|
- Gemfile
|
@@ -128,32 +118,32 @@ files:
|
|
128
118
|
- spec/indico_batch_spec.rb
|
129
119
|
- spec/indico_spec.rb
|
130
120
|
- spec/keywords_v2_spec.rb
|
121
|
+
- spec/political_spec.rb
|
131
122
|
- spec/settings_spec.rb
|
132
123
|
- spec/spec_helper.rb
|
133
124
|
- spec/versioning_spec.rb
|
134
125
|
homepage: https://github.com/IndicoDataSolutions/IndicoIo-ruby
|
135
126
|
licenses:
|
136
127
|
- MIT
|
128
|
+
metadata: {}
|
137
129
|
post_install_message:
|
138
130
|
rdoc_options: []
|
139
131
|
require_paths:
|
140
132
|
- lib
|
141
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
-
none: false
|
143
134
|
requirements:
|
144
|
-
- -
|
135
|
+
- - '>='
|
145
136
|
- !ruby/object:Gem::Version
|
146
137
|
version: '0'
|
147
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
-
none: false
|
149
139
|
requirements:
|
150
|
-
- -
|
140
|
+
- - '>='
|
151
141
|
- !ruby/object:Gem::Version
|
152
142
|
version: '0'
|
153
143
|
requirements: []
|
154
144
|
rubyforge_project:
|
155
|
-
rubygems_version:
|
145
|
+
rubygems_version: 2.0.14.1
|
156
146
|
signing_key:
|
157
|
-
specification_version:
|
147
|
+
specification_version: 4
|
158
148
|
summary: A simple Ruby Wrapper for the indico set of APIs.
|
159
149
|
test_files: []
|