indico 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +35 -6
- data/lib/indico.rb +46 -15
- data/lib/indico/helper.rb +21 -7
- data/lib/indico/version.rb +1 -1
- data/spec/indico_batch_spec.rb +133 -0
- data/spec/indico_spec.rb +34 -7
- metadata +4 -5
- data/lib/indico_local.rb +0 -37
- data/spec/indico_local_spec.rb +0 -107
data/README.md
CHANGED
@@ -16,6 +16,10 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install indico
|
18
18
|
|
19
|
+
Documentation
|
20
|
+
------------
|
21
|
+
Found [here](http://indico.readme.io/v1.0/docs)
|
22
|
+
|
19
23
|
## Usage
|
20
24
|
|
21
25
|
```ruby
|
@@ -41,19 +45,44 @@ Or install it yourself as:
|
|
41
45
|
|
42
46
|
```
|
43
47
|
|
44
|
-
###
|
48
|
+
###Batch API Access
|
45
49
|
|
46
|
-
|
50
|
+
If you'd like to use our batch api interface, please check out the [pricing page](https://indico.io/pricing) on our website to find the right plan for you.
|
47
51
|
|
48
52
|
```ruby
|
49
|
-
> require '
|
53
|
+
> require 'indico'
|
50
54
|
|
51
55
|
=> true
|
52
56
|
|
53
|
-
>
|
57
|
+
> data = ["I believe in capital punishment", "The president is wrong"]
|
58
|
+
|
59
|
+
=> ["I believe in capital punishment", "The president is wrong"]
|
60
|
+
|
61
|
+
> Indico.batch_political(data, "username", "password")
|
62
|
+
|
63
|
+
=> [ {"Libertarian"=>0.3511057701654774, "Liberal"=>0.06709112089656208, "Green"=>0.03830472376983833, "Conservative"=>0.5434983851681222}, {"Libertarian"=>0.08762905907467175, "Liberal"=>0.18965142341591298, "Green"=>0.02612359787701222, "Conservative"=>0.696595919632403}]
|
64
|
+
````
|
65
|
+
|
66
|
+
###Private cloud API Access
|
67
|
+
|
68
|
+
If you're looking to use indico's API for high throughput applications, please check out the [pricing page](https://indico.io/pricing) on our website to find the right plan for you.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
> require 'indico'
|
72
|
+
|
73
|
+
=> true
|
74
|
+
|
75
|
+
> data = ["I believe in capital punishment", "The president is wrong"]
|
76
|
+
|
77
|
+
=> ["I believe in capital punishment", "The president is wrong"]
|
78
|
+
|
79
|
+
> Indico.batch_political(data, "username", "password", cloud)
|
80
|
+
|
81
|
+
=> [ {"Libertarian"=>0.3511057701654774, "Liberal"=>0.06709112089656208, "Green"=>0.03830472376983833, "Conservative"=>0.5434983851681222}, {"Libertarian"=>0.08762905907467175, "Liberal"=>0.18965142341591298, "Green"=>0.02612359787701222, "Conservative"=>0.696595919632403}]
|
82
|
+
````
|
83
|
+
|
84
|
+
The `cloud` parameter redirects API calls to your private cloud hosted at `[cloud].indico.domains`
|
54
85
|
|
55
|
-
=> {"Sentiment"=>0.7483253499779664}
|
56
|
-
```
|
57
86
|
|
58
87
|
## Contributing
|
59
88
|
|
data/lib/indico.rb
CHANGED
@@ -8,37 +8,68 @@ module Indico
|
|
8
8
|
|
9
9
|
HEADERS = { "Content-Type" => "application/json", "Accept" => "text/plain" }
|
10
10
|
|
11
|
-
def self.political(test_text,
|
12
|
-
api_handler(test_text,
|
11
|
+
def self.political(test_text, username=nil, password=nil, private_cloud=nil)
|
12
|
+
api_handler(test_text, private_cloud, "political", username, password)
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
16
|
-
api_handler(test_text,
|
15
|
+
def self.batch_political(test_text, username, password, private_cloud=nil)
|
16
|
+
api_handler(test_text, private_cloud, "political/batch", username, password)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.posneg(test_text, username=nil, password=nil, private_cloud=nil)
|
20
|
+
api_handler(test_text, private_cloud, "sentiment", username, password)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.batch_posneg(test_text, username, password, private_cloud=nil)
|
24
|
+
api_handler(test_text, private_cloud, "sentiment/batch", username, password)
|
17
25
|
end
|
18
26
|
|
19
27
|
def self.sentiment(*args)
|
20
28
|
self.posneg(*args)
|
21
29
|
end
|
22
30
|
|
23
|
-
def self.
|
24
|
-
|
31
|
+
def self.batch_sentiment(*args)
|
32
|
+
self.batch_posneg(*args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.language(test_text, username=nil, password=nil, private_cloud=nil)
|
36
|
+
api_handler(test_text, private_cloud, "language", username, password)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.batch_language(test_text, username, password, private_cloud=nil)
|
40
|
+
api_handler(test_text, private_cloud, "language/batch", username, password)
|
25
41
|
end
|
26
42
|
|
27
|
-
def self.text_tags(test_text,
|
28
|
-
api_handler(test_text,
|
43
|
+
def self.text_tags(test_text, username=nil, password=nil, private_cloud=nil)
|
44
|
+
api_handler(test_text, private_cloud, "texttags", username, password)
|
29
45
|
end
|
30
|
-
|
31
|
-
def self.
|
32
|
-
api_handler(
|
46
|
+
|
47
|
+
def self.batch_text_tags(test_text, username, password, private_cloud=nil)
|
48
|
+
api_handler(test_text, private_cloud, "texttags/batch", username, password)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.fer(face, username=nil, password=nil, private_cloud=nil)
|
52
|
+
api_handler(face, private_cloud, "fer", username, password)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.batch_fer(test_text, username, password, private_cloud=nil)
|
56
|
+
api_handler(test_text, private_cloud, "fer/batch", username, password)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.facial_features(face, username=nil, password=nil, private_cloud=nil)
|
60
|
+
api_handler(face, private_cloud, "facialfeatures", username, password)
|
33
61
|
end
|
34
62
|
|
35
|
-
def self.
|
36
|
-
api_handler(
|
63
|
+
def self.batch_facial_features(test_text, username, password, private_cloud=nil)
|
64
|
+
api_handler(test_text, private_cloud, "facialfeatures/batch", username, password)
|
37
65
|
end
|
38
66
|
|
39
|
-
def self.image_features(face,
|
40
|
-
api_handler(face,
|
67
|
+
def self.image_features(face, username=nil, password=nil, private_cloud=nil)
|
68
|
+
api_handler(face, private_cloud, "imagefeatures", username, password)
|
41
69
|
end
|
42
70
|
|
71
|
+
def self.batch_image_features(test_text, username, password, private_cloud=nil)
|
72
|
+
api_handler(test_text, private_cloud, "imagefeatures/batch", username, password)
|
73
|
+
end
|
43
74
|
|
44
75
|
end
|
data/lib/indico/helper.rb
CHANGED
@@ -1,22 +1,28 @@
|
|
1
|
+
require "base64"
|
2
|
+
|
1
3
|
module Indico
|
2
4
|
private
|
3
5
|
|
4
6
|
def self.url_join(root, api)
|
5
|
-
if root
|
6
|
-
"http://localhost:9438/%s" % api
|
7
|
-
else
|
7
|
+
if root.nil?
|
8
8
|
"http://apiv1.indico.io/%s" % api
|
9
|
+
else
|
10
|
+
"http://" + root + ".indico.domains/" + api
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
|
-
def self.api_handler(data, server, api)
|
14
|
+
def self.api_handler(data, server, api, username=nil, password=nil)
|
13
15
|
d = {}
|
14
16
|
d['data'] = data
|
15
17
|
data_dict = JSON.dump(d)
|
16
|
-
|
18
|
+
if username.nil?
|
19
|
+
response = make_request(url_join(server, api), data_dict, HEADERS)
|
20
|
+
else
|
21
|
+
response = make_request(url_join(server, api), data_dict, encode_credentials(username, password))
|
22
|
+
end
|
17
23
|
results = JSON.parse(response.body)
|
18
24
|
if results.key?("error")
|
19
|
-
|
25
|
+
raise results["error"]
|
20
26
|
else
|
21
27
|
results = results["results"]
|
22
28
|
end
|
@@ -36,4 +42,12 @@ module Indico
|
|
36
42
|
|
37
43
|
http.request(request)
|
38
44
|
end
|
39
|
-
|
45
|
+
|
46
|
+
def self.encode_credentials(username, password)
|
47
|
+
headers = { "Content-Type" => "application/json", "Accept" => "text/plain" }
|
48
|
+
credentials = username + ":" + password
|
49
|
+
headers["Authorization"] = "Basic " + Base64.strict_encode64(credentials)
|
50
|
+
headers
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/lib/indico/version.rb
CHANGED
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
$username = ENV['INDICO_USERNAME']
|
5
|
+
$password = ENV['INDICO_PASSWORD']
|
6
|
+
$private_cloud = 'indico-test'
|
7
|
+
|
8
|
+
describe Indico do
|
9
|
+
|
10
|
+
it "should tag text with correct political tags" do
|
11
|
+
expected_keys = Set.new(["Conservative", "Green", "Liberal", "Libertarian"])
|
12
|
+
data = ["Guns don't kill people."," People kill people."]
|
13
|
+
response = Indico.batch_political(data, $username, $password) # Guns don't kill people. People kill people.
|
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 access a private cloud" do
|
20
|
+
expected_keys = Set.new(["Conservative", "Green", "Liberal", "Libertarian"])
|
21
|
+
data = ["Guns don't kill people."," People kill people."]
|
22
|
+
response = Indico.batch_political(data, $username, $password, $private_cloud) # Guns don't kill people. People kill people.
|
23
|
+
|
24
|
+
expect(Set.new(response[0].keys)).to eql(expected_keys)
|
25
|
+
expect(Set.new(response[1].keys)).to eql(expected_keys)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should tag text with correct sentiment tags" do
|
29
|
+
response = Indico.batch_sentiment(["Worst movie ever."], $username, $password)
|
30
|
+
|
31
|
+
expect(response[0] < 0.5).to eql(true)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should tag text with correct language tags" do
|
35
|
+
expected_keys = Set.new([
|
36
|
+
'English',
|
37
|
+
'Spanish',
|
38
|
+
'Tagalog',
|
39
|
+
'Esperanto',
|
40
|
+
'French',
|
41
|
+
'Chinese',
|
42
|
+
'French',
|
43
|
+
'Bulgarian',
|
44
|
+
'Latin',
|
45
|
+
'Slovak',
|
46
|
+
'Hebrew',
|
47
|
+
'Russian',
|
48
|
+
'German',
|
49
|
+
'Japanese',
|
50
|
+
'Korean',
|
51
|
+
'Portuguese',
|
52
|
+
'Italian',
|
53
|
+
'Polish',
|
54
|
+
'Turkish',
|
55
|
+
'Dutch',
|
56
|
+
'Arabic',
|
57
|
+
'Persian (Farsi)',
|
58
|
+
'Czech',
|
59
|
+
'Swedish',
|
60
|
+
'Indonesian',
|
61
|
+
'Vietnamese',
|
62
|
+
'Romanian',
|
63
|
+
'Greek',
|
64
|
+
'Danish',
|
65
|
+
'Hungarian',
|
66
|
+
'Thai',
|
67
|
+
'Finnish',
|
68
|
+
'Norwegian',
|
69
|
+
'Lithuanian'
|
70
|
+
])
|
71
|
+
|
72
|
+
data = ['Quis custodiet ipsos custodes', 'Clearly english, foo!']
|
73
|
+
response = Indico.batch_language(data, $username, $password)
|
74
|
+
|
75
|
+
expect(Set.new(response[0].keys)).to eql(expected_keys)
|
76
|
+
expect(Set.new(response[1].keys)).to eql(expected_keys)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should tag text with correct text tags" do
|
80
|
+
expected_keys = Set.new(['fashion', 'art', 'energy', 'economics', 'entrepreneur',
|
81
|
+
'books', 'politics', 'gardening', 'nba', 'conservative',
|
82
|
+
'technology', 'startups', 'relationships', 'education',
|
83
|
+
'humor', 'psychology', 'bicycling', 'investing', 'travel',
|
84
|
+
'cooking', 'christianity', 'environment', 'religion', 'health',
|
85
|
+
'hockey', 'pets', 'music', 'soccer', 'guns', 'gaming', 'jobs',
|
86
|
+
'business', 'nature', 'food', 'cars', 'photography', 'philosophy',
|
87
|
+
'geek', 'sports', 'baseball', 'news', 'television', 'entertainment',
|
88
|
+
'parenting', 'comics', 'science', 'nfl','programming',
|
89
|
+
'personalfinance', 'atheism', 'movies', 'anime', 'fitness',
|
90
|
+
'military', 'realestate', 'history'])
|
91
|
+
|
92
|
+
data = ["Guns don't kill people.", "People kill people."]
|
93
|
+
response = Indico.batch_text_tags(data, $username, $password) # Guns don't kill people. People kill people.
|
94
|
+
|
95
|
+
expect Set.new(response[0].keys).subset?(Set.new(expected_keys))
|
96
|
+
expect Set.new(response[1].keys).subset?(Set.new(expected_keys))
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should tag face with correct facial expression" do
|
100
|
+
expected_keys = Set.new(["Angry", "Sad", "Neutral", "Surprise", "Fear", "Happy"])
|
101
|
+
test_face = Array.new(48){Array.new(48){rand(100)/100.0} }
|
102
|
+
response = Indico.batch_fer([test_face, test_face], $username, $password)
|
103
|
+
|
104
|
+
expect(Set.new(response[0].keys)).to eql(expected_keys)
|
105
|
+
expect(Set.new(response[1].keys)).to eql(expected_keys)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should tag face with correct facial features" do
|
109
|
+
test_face = Array.new(48){Array.new(48){rand(100)/100.0} }
|
110
|
+
response = Indico.batch_facial_features([test_face, test_face], $username, $password)
|
111
|
+
|
112
|
+
expect(response[0].length).to eql(48)
|
113
|
+
expect(response[1].length).to eql(48)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should tag image with correct image features" do
|
117
|
+
test_image = Array.new(48){Array.new(48){rand(100)/100.0} }
|
118
|
+
response = Indico.batch_image_features([test_image, test_image], $username, $password)
|
119
|
+
|
120
|
+
expect(response[0].length).to eql(2048)
|
121
|
+
expect(response[1].length).to eql(2048)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Uncomment when frontend updated to accept image urls
|
125
|
+
# it "should accept image urls" do
|
126
|
+
# test_image = "http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/48/Emotes-face-smile-icon.png"
|
127
|
+
# response = Indico.batch_image_features([test_image, test_image], $username, $password)
|
128
|
+
|
129
|
+
# expect(response[0].length).to eql(2048)
|
130
|
+
# expect(response[1].length).to eql(2048)
|
131
|
+
# end
|
132
|
+
|
133
|
+
end
|
data/spec/indico_spec.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'set'
|
3
3
|
|
4
|
+
$username = ENV['INDICO_USERNAME']
|
5
|
+
$password = ENV['INDICO_PASSWORD']
|
6
|
+
$private_cloud = 'indico-test'
|
7
|
+
|
4
8
|
describe Indico do
|
5
9
|
|
6
10
|
it "should tag text with correct political tags" do
|
@@ -10,6 +14,14 @@ describe Indico do
|
|
10
14
|
expect(Set.new(response.keys)).to eql(expected_keys)
|
11
15
|
end
|
12
16
|
|
17
|
+
it "should tag text with correct political tags" do
|
18
|
+
expected_keys = Set.new(["Conservative", "Green", "Liberal", "Libertarian"])
|
19
|
+
data = "Guns don't kill people. People kill people."
|
20
|
+
response = Indico.political(data, $username, $password, $private_cloud) # Guns don't kill people. People kill people.
|
21
|
+
|
22
|
+
expect(Set.new(response.keys)).to eql(expected_keys)
|
23
|
+
end
|
24
|
+
|
13
25
|
it "should tag text with correct sentiment tags" do
|
14
26
|
response = Indico.sentiment("Worst movie ever.")
|
15
27
|
|
@@ -59,11 +71,11 @@ describe Indico do
|
|
59
71
|
end
|
60
72
|
|
61
73
|
it "should tag text with correct text tags" do
|
62
|
-
expected_keys = Set.new(['fashion', 'art', 'energy', 'economics', 'entrepreneur',
|
63
|
-
'books', 'politics', 'gardening', 'nba', 'conservative',
|
74
|
+
expected_keys = Set.new(['fashion', 'art', 'energy', 'economics', 'entrepreneur',
|
75
|
+
'books', 'politics', 'gardening', 'nba', 'conservative',
|
64
76
|
'technology', 'startups', 'relationships', 'education',
|
65
77
|
'humor', 'psychology', 'bicycling', 'investing', 'travel',
|
66
|
-
'cooking', 'christianity', 'environment', 'religion', 'health',
|
78
|
+
'cooking', 'christianity', 'environment', 'religion', 'health',
|
67
79
|
'hockey', 'pets', 'music', 'soccer', 'guns', 'gaming', 'jobs',
|
68
80
|
'business', 'nature', 'food', 'cars', 'photography', 'philosophy',
|
69
81
|
'geek', 'sports', 'baseball', 'news', 'television', 'entertainment',
|
@@ -72,22 +84,37 @@ describe Indico do
|
|
72
84
|
'military', 'realestate', 'history'])
|
73
85
|
response = Indico.text_tags("Guns don't kill people. People kill people.") # Guns don't kill people. People kill people.
|
74
86
|
|
75
|
-
expect
|
87
|
+
expect Set.new(response.keys).subset?(Set.new(expected_keys))
|
76
88
|
end
|
77
89
|
|
78
90
|
it "should tag face with correct facial expression" do
|
79
91
|
expected_keys = Set.new(["Angry", "Sad", "Neutral", "Surprise", "Fear", "Happy"])
|
80
|
-
test_face =
|
92
|
+
test_face = Array.new(48){Array.new(48){rand(100)/100.0} }
|
93
|
+
|
81
94
|
response = Indico.fer(test_face)
|
82
95
|
|
83
96
|
expect(Set.new(response.keys)).to eql(expected_keys)
|
84
97
|
end
|
85
98
|
|
86
99
|
it "should tag face with correct facial features" do
|
87
|
-
test_face =
|
100
|
+
test_face = Array.new(48){Array.new(48){rand(100)/100.0} }
|
88
101
|
response = Indico.facial_features(test_face)
|
89
102
|
|
90
103
|
expect(response.length).to eql(48)
|
91
104
|
end
|
92
105
|
|
93
|
-
|
106
|
+
it "should tag image with correct image features" do
|
107
|
+
test_image = Array.new(48){Array.new(48){rand(100)/100.0} }
|
108
|
+
response = Indico.image_features(test_image)
|
109
|
+
|
110
|
+
expect(response.length).to eql(2048)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Uncomment when frontend updated to accept image urls
|
114
|
+
# it "should accept image urls" do
|
115
|
+
# response = Indico.image_features("http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/48/Emotes-face-smile-icon.png")
|
116
|
+
|
117
|
+
# expect(response.length).to eql(2048)
|
118
|
+
# end
|
119
|
+
|
120
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -78,8 +78,7 @@ files:
|
|
78
78
|
- lib/indico.rb
|
79
79
|
- lib/indico/helper.rb
|
80
80
|
- lib/indico/version.rb
|
81
|
-
-
|
82
|
-
- spec/indico_local_spec.rb
|
81
|
+
- spec/indico_batch_spec.rb
|
83
82
|
- spec/indico_spec.rb
|
84
83
|
- spec/spec_helper.rb
|
85
84
|
homepage: https://github.com/IndicoDataSolutions/IndicoIo-ruby
|
@@ -108,6 +107,6 @@ signing_key:
|
|
108
107
|
specification_version: 3
|
109
108
|
summary: A simple Ruby Wrapper for the indico set of APIs.
|
110
109
|
test_files:
|
111
|
-
- spec/
|
110
|
+
- spec/indico_batch_spec.rb
|
112
111
|
- spec/indico_spec.rb
|
113
112
|
- spec/spec_helper.rb
|
data/lib/indico_local.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require "indico"
|
2
|
-
|
3
|
-
module IndicoLocal
|
4
|
-
|
5
|
-
def self.political(test_text)
|
6
|
-
Indico.political(test_text, "local")
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.posneg(test_text)
|
10
|
-
Indico.posneg(test_text, "local")
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.sentiment(*args)
|
14
|
-
self.posneg(*args)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.language(test_text)
|
18
|
-
Indico.language(test_text, "local")
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.text_tags(test_text)
|
22
|
-
Indico.text_tags(test_text, "local")
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.fer(face)
|
26
|
-
Indico.fer(face, "local")
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.facial_features(face)
|
30
|
-
Indico.facial_features(face, "local")
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.image_features(image)
|
34
|
-
Indico.image_features(image, "local")
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/spec/indico_local_spec.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'indico_local'
|
2
|
-
require 'set'
|
3
|
-
|
4
|
-
describe Indico do
|
5
|
-
|
6
|
-
it "should tag text with correct political tags" do
|
7
|
-
expected_keys = Set.new(["Conservative", "Green", "Liberal", "Libertarian"])
|
8
|
-
response = Indico.political("Guns don't kill people. People kill people.") # Guns don't kill people. People kill people.
|
9
|
-
|
10
|
-
expect(Set.new(response.keys)).to eql(expected_keys)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should tag text with correct text tags" do
|
14
|
-
expected_keys = Set.new(["political", "arts", "products", "news"])
|
15
|
-
response = Indico.text_tags("Guns don't kill people. People kill people.") # Guns don't kill people. People kill people.
|
16
|
-
|
17
|
-
expect(Set.new(response.keys)).to eql(expected_keys)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should tag text with correct sentiment tags" do
|
21
|
-
response = Indico.sentiment("Worst movie ever.")
|
22
|
-
|
23
|
-
expect(response).to be < 0.5
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should tag text with correct language tags" do
|
27
|
-
expected_keys = Set.new([
|
28
|
-
'English',
|
29
|
-
'Spanish',
|
30
|
-
'Tagalog',
|
31
|
-
'Esperanto',
|
32
|
-
'French',
|
33
|
-
'Chinese',
|
34
|
-
'French',
|
35
|
-
'Bulgarian',
|
36
|
-
'Latin',
|
37
|
-
'Slovak',
|
38
|
-
'Hebrew',
|
39
|
-
'Russian',
|
40
|
-
'German',
|
41
|
-
'Japanese',
|
42
|
-
'Korean',
|
43
|
-
'Portuguese',
|
44
|
-
'Italian',
|
45
|
-
'Polish',
|
46
|
-
'Turkish',
|
47
|
-
'Dutch',
|
48
|
-
'Arabic',
|
49
|
-
'Persian (Farsi)',
|
50
|
-
'Czech',
|
51
|
-
'Swedish',
|
52
|
-
'Indonesian',
|
53
|
-
'Vietnamese',
|
54
|
-
'Romanian',
|
55
|
-
'Greek',
|
56
|
-
'Danish',
|
57
|
-
'Hungarian',
|
58
|
-
'Thai',
|
59
|
-
'Finnish',
|
60
|
-
'Norwegian',
|
61
|
-
'Lithuanian'
|
62
|
-
])
|
63
|
-
response = Indico.language('Quis custodiet ipsos custodes')
|
64
|
-
|
65
|
-
expect(Set.new(response.keys)).to eql(expected_keys)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should tag text with correct text tags" do
|
69
|
-
expected_keys = Set.new(['fashion', 'art', 'energy', 'economics', 'entrepreneur',
|
70
|
-
'books', 'politics', 'gardening', 'nba', 'conservative',
|
71
|
-
'technology', 'startups', 'relationships', 'education',
|
72
|
-
'humor', 'psychology', 'bicycling', 'investing', 'travel',
|
73
|
-
'cooking', 'christianity', 'environment', 'religion', 'health',
|
74
|
-
'hockey', 'pets', 'music', 'soccer', 'guns', 'gaming', 'jobs',
|
75
|
-
'business', 'nature', 'food', 'cars', 'photography', 'philosophy',
|
76
|
-
'geek', 'sports', 'baseball', 'news', 'television', 'entertainment',
|
77
|
-
'parenting', 'comics', 'science', 'nfl','programming',
|
78
|
-
'personalfinance', 'atheism', 'movies', 'anime', 'fitness',
|
79
|
-
'military', 'realestate', 'history'])
|
80
|
-
response = Indico.text_tags("Guns don't kill people. People kill people.") # Guns don't kill people. People kill people.
|
81
|
-
|
82
|
-
expect(Set.new(response.keys)).to eql(expected_keys)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should tag face with correct facial expression" do
|
86
|
-
expected_keys = Set.new(["Angry", "Sad", "Neutral", "Surprise", "Fear", "Happy"])
|
87
|
-
test_face = 0.step(1, 1.0/(48.0*48.0)).to_a[0..-2].each_slice(48).to_a
|
88
|
-
response = Indico.fer(test_face)
|
89
|
-
|
90
|
-
expect(Set.new(response.keys)).to eql(expected_keys)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should return a facial feature vector" do
|
94
|
-
test_face = 0.step(1, 1.0/(48.0*48.0)).to_a[0..-2].each_slice(48).to_a
|
95
|
-
response = Indico.facial_features(test_face)
|
96
|
-
|
97
|
-
expect(response.length).to eql(48)
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should return an image features vector" do
|
101
|
-
test_image = 0.step(1, 1.0/(48.0*48.0)).to_a[0..-2].each_slice(48).to_a
|
102
|
-
response = Indico.image_features(test_image)
|
103
|
-
|
104
|
-
expect(response.length).to eql(2048)
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|