alchemy-api-rb 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/alchemy-api-rb.gemspec +2 -2
- data/lib/alchemy-api/face_detection.rb +19 -0
- data/lib/alchemy-api/version.rb +1 -1
- data/lib/alchemy_api.rb +1 -0
- data/spec/face_detection_spec.rb +46 -0
- data/spec/vcr_cassettes/face_detection_basic_url_json_search.yml +159 -0
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e866606714874154f75f11d2d22fb0afa16f83ab
|
4
|
+
data.tar.gz: e2cd0b195b127998f4b568eea246099bf894fc9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205a9d9aefc445fa2ea563e2c72a83aaa66f42b48635a159265af4de676a6e6832e80e02e1cbea183de56a771ce5aadc879dcb04befc2ac4b698fe1043404ef6
|
7
|
+
data.tar.gz: 133627a8f0e840fbf412ed36b0742bdfdb09dcb95d09ecaf8a233d3a2aeef1f8c8db32ba3b338e8139b6da5a04a3e8086674464068d99b9a79f977676228171d
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/alchemy-api-rb.gemspec
CHANGED
@@ -23,8 +23,8 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_development_dependency 'pry', '~> 0.10.0'
|
24
24
|
gem.add_development_dependency 'rake', '~> 10.3.0'
|
25
25
|
gem.add_development_dependency 'minitest-reporters', '~> 1.0.0'
|
26
|
-
gem.add_development_dependency 'vcr', '~> 2.
|
27
|
-
gem.add_development_dependency 'webmock', '~> 1.
|
26
|
+
gem.add_development_dependency 'vcr', '~> 2.9.2'
|
27
|
+
gem.add_development_dependency 'webmock', '~> 1.19.0'
|
28
28
|
gem.add_development_dependency 'coveralls', '~> 0.7.0'
|
29
29
|
gem.add_development_dependency 'rubocop', '~> 0.25.0'
|
30
30
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module AlchemyAPI
|
2
|
+
class FaceDetection < Base
|
3
|
+
Config.add_mode :face_detection, self
|
4
|
+
|
5
|
+
def web_method
|
6
|
+
"#{method_prefix}GetRankedImageFaceTags"
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def supported_search_types
|
12
|
+
[:url]
|
13
|
+
end
|
14
|
+
|
15
|
+
def indexer
|
16
|
+
'imageFaces'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/alchemy-api/version.rb
CHANGED
data/lib/alchemy_api.rb
CHANGED
@@ -5,6 +5,7 @@ require 'alchemy-api/keyword_extraction'
|
|
5
5
|
require 'alchemy-api/text_extraction'
|
6
6
|
require 'alchemy-api/title_extraction'
|
7
7
|
require 'alchemy-api/entity_extraction'
|
8
|
+
require 'alchemy-api/face_detection'
|
8
9
|
require 'alchemy-api/sentiment_analysis'
|
9
10
|
require 'alchemy-api/targeted_sentiment_analysis'
|
10
11
|
require 'alchemy-api/relation_extraction'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
|
+
|
3
|
+
describe AlchemyAPI, 'face_detection' do
|
4
|
+
before do
|
5
|
+
AlchemyAPI::Config.apikey = API_KEY
|
6
|
+
end
|
7
|
+
|
8
|
+
subject { AlchemyAPI::FaceDetection.new }
|
9
|
+
|
10
|
+
describe '#search' do
|
11
|
+
{
|
12
|
+
url: 'http://vision.alchemy.ai/img/demo/5682349.jpg'
|
13
|
+
}.each do |type, value|
|
14
|
+
[:json].each do |output_mode|
|
15
|
+
before do
|
16
|
+
AlchemyAPI::Config.output_mode = output_mode
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#{type} search with #{output_mode} results" do
|
20
|
+
it 'returns an array of results' do
|
21
|
+
cassette_name = "face_detection_basic_#{type}_#{output_mode}_search"
|
22
|
+
VCR.use_cassette(cassette_name) do
|
23
|
+
result = subject.search(type => value)
|
24
|
+
|
25
|
+
result.must_be_instance_of Array
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'includes the keyword text and score' do
|
30
|
+
cassette_name = "face_detection_basic_#{type}_#{output_mode}_search"
|
31
|
+
VCR.use_cassette(cassette_name) do
|
32
|
+
result = subject.search(type => value)[0]
|
33
|
+
|
34
|
+
result['age'].wont_be_nil
|
35
|
+
result['gender'].wont_be_nil
|
36
|
+
result['identity'].wont_be_nil
|
37
|
+
result['positionX'].wont_be_nil
|
38
|
+
result['positionY'].wont_be_nil
|
39
|
+
result['width'].wont_be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://access.alchemyapi.com/calls/url/URLGetRankedImageFaceTags
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: apikey=ALCHEMY_KEY&outputMode=json&url=http%3A%2F%2Fvision.alchemy.ai%2Fimg%2Fdemo%2F5682349.jpg
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.2
|
12
|
+
Content-Type:
|
13
|
+
- application/x-www-form-urlencoded
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: ''
|
18
|
+
headers:
|
19
|
+
Server:
|
20
|
+
- nginx
|
21
|
+
Date:
|
22
|
+
- Mon, 22 Feb 2016 21:51:48 GMT
|
23
|
+
Content-Type:
|
24
|
+
- application/json
|
25
|
+
Content-Length:
|
26
|
+
- '8098'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
X-Alchemyapi-Currentversion:
|
32
|
+
- '12.28'
|
33
|
+
X-Alchemyapi-Key:
|
34
|
+
- ALCHEMY_KEY
|
35
|
+
X-Alchemyapi-Params:
|
36
|
+
- sentiment=0&knowledgeGraph=0&detectedLanguage=unknown
|
37
|
+
X-Alchemyapi-Raw-Content-Size:
|
38
|
+
- '96653'
|
39
|
+
X-Alchemyapi-Requested-Url:
|
40
|
+
- http://vision.alchemy.ai/img/demo/5682349.jpg
|
41
|
+
X-Alchemyapi-Retrieved-Url:
|
42
|
+
- http://vision.alchemy.ai/img/demo/5682349.jpg
|
43
|
+
X-Alchemyapi-Status:
|
44
|
+
- OK
|
45
|
+
X-Alchemyapi-Total-Transactions:
|
46
|
+
- '4'
|
47
|
+
Access-Control-Allow-Origin:
|
48
|
+
- "*"
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: "{\r\n \"status\": \"OK\",\r\n \"usage\": \"By accessing AlchemyAPI
|
52
|
+
or using information generated by AlchemyAPI, you are agreeing to be bound
|
53
|
+
by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html\",\r\n
|
54
|
+
\ \"url\": \"http://vision.alchemy.ai/img/demo/5682349.jpg\",\n \"totalTransactions\":
|
55
|
+
\"4\",\n \"imageFaces\": [\n {\n \"age\": {\n \"ageRange\":
|
56
|
+
\"55-64\",\n \"score\": \"0.447907\"\n },\n \"gender\":
|
57
|
+
{\n \"gender\": \"MALE\",\n \"score\": \"0.99394\"\n
|
58
|
+
\ },\n \"height\": \"44\",\n \"identity\":
|
59
|
+
{\n \"disambiguated\": {\n \"dbpedia\":
|
60
|
+
\"http://dbpedia.org/resource/Jeffrey_Tambor\",\n \"freebase\":
|
61
|
+
\"http://rdf.freebase.com/ns/m.02r_d4\",\n \"name\": \"Jeffrey
|
62
|
+
Tambor\",\n \"subType\": [\n \"Person\",\n
|
63
|
+
\ \"Actor\",\n \"AwardNominee\",\n
|
64
|
+
\ \"FilmActor\",\n \"TVActor\"\n
|
65
|
+
\ ],\n \"yago\": \"http://yago-knowledge.org/resource/Jeffrey_Tambor\"\n
|
66
|
+
\ },\n \"name\": \"Jeffrey Tambor\",\n \"score\":
|
67
|
+
\"0.99394\"\n },\n \"positionX\": \"276\",\n \"positionY\":
|
68
|
+
\"56\",\n \"width\": \"44\"\n },\n {\n \"age\":
|
69
|
+
{\n \"ageRange\": \"18-24\",\n \"score\": \"0.445553\"\n
|
70
|
+
\ },\n \"gender\": {\n \"gender\": \"MALE\",\n
|
71
|
+
\ \"score\": \"0.995033\"\n },\n \"height\":
|
72
|
+
\"48\",\n \"identity\": {\n \"disambiguated\": {\n
|
73
|
+
\ \"dbpedia\": \"http://dbpedia.org/resource/Tony_Hale\",\n
|
74
|
+
\ \"freebase\": \"http://rdf.freebase.com/ns/m.03q3vd\",\n
|
75
|
+
\ \"name\": \"Tony Hale\",\n \"subType\":
|
76
|
+
[\n \"Person\",\n \"Actor\",\n
|
77
|
+
\ \"FilmActor\",\n \"TVActor\"\n
|
78
|
+
\ ],\n \"yago\": \"http://yago-knowledge.org/resource/Tony_Hale\"\n
|
79
|
+
\ },\n \"name\": \"Tony Hale\",\n \"score\":
|
80
|
+
\"0.995033\"\n },\n \"positionX\": \"167\",\n \"positionY\":
|
81
|
+
\"59\",\n \"width\": \"48\"\n },\n {\n \"age\":
|
82
|
+
{\n \"ageRange\": \"35-44\",\n \"score\": \"0.399737\"\n
|
83
|
+
\ },\n \"gender\": {\n \"gender\": \"MALE\",\n
|
84
|
+
\ \"score\": \"0.996316\"\n },\n \"height\":
|
85
|
+
\"38\",\n \"identity\": {\n \"disambiguated\": {\n
|
86
|
+
\ \"dbpedia\": \"http://dbpedia.org/resource/Will_Arnett\",\n
|
87
|
+
\ \"freebase\": \"http://rdf.freebase.com/ns/m.03q43g\",\n
|
88
|
+
\ \"name\": \"Will Arnett\",\n \"subType\":
|
89
|
+
[\n \"Person\",\n \"Actor\",\n
|
90
|
+
\ \"AwardNominee\",\n \"Celebrity\",\n
|
91
|
+
\ \"FilmActor\",\n \"FilmProducer\",\n
|
92
|
+
\ \"TVActor\",\n \"FilmWriter\"\n
|
93
|
+
\ ],\n \"yago\": \"http://yago-knowledge.org/resource/Will_Arnett\"\n
|
94
|
+
\ },\n \"name\": \"Will Arnett\",\n \"score\":
|
95
|
+
\"0.994514\"\n },\n \"positionX\": \"442\",\n \"positionY\":
|
96
|
+
\"64\",\n \"width\": \"38\"\n },\n {\n \"age\":
|
97
|
+
{\n \"ageRange\": \"35-44\",\n \"score\": \"0.467653\"\n
|
98
|
+
\ },\n \"gender\": {\n \"gender\": \"MALE\",\n
|
99
|
+
\ \"score\": \"0.996665\"\n },\n \"height\":
|
100
|
+
\"52\",\n \"identity\": {\n \"disambiguated\": {\n
|
101
|
+
\ \"dbpedia\": \"http://dbpedia.org/resource/Jason_Bateman\",\n
|
102
|
+
\ \"freebase\": \"http://rdf.freebase.com/ns/m.032xhg\",\n
|
103
|
+
\ \"name\": \"Jason Bateman\",\n \"subType\":
|
104
|
+
[\n \"Person\",\n \"Actor\",\n
|
105
|
+
\ \"AwardNominee\",\n \"AwardWinner\",\n
|
106
|
+
\ \"Celebrity\",\n \"FilmActor\",\n
|
107
|
+
\ \"TVActor\",\n \"TVDirector\"\n
|
108
|
+
\ ],\n \"yago\": \"http://yago-knowledge.org/resource/Jason_Bateman\"\n
|
109
|
+
\ },\n \"name\": \"Jason Bateman\",\n \"score\":
|
110
|
+
\"0.996665\"\n },\n \"positionX\": \"508\",\n \"positionY\":
|
111
|
+
\"72\",\n \"width\": \"52\"\n },\n {\n \"age\":
|
112
|
+
{\n \"ageRange\": \"18-24\",\n \"score\": \"0.502411\"\n
|
113
|
+
\ },\n \"gender\": {\n \"gender\": \"MALE\",\n
|
114
|
+
\ \"score\": \"0.996665\"\n },\n \"height\":
|
115
|
+
\"46\",\n \"identity\": {\n \"disambiguated\": {\n
|
116
|
+
\ \"dbpedia\": \"http://dbpedia.org/resource/Michael_Cera\",\n
|
117
|
+
\ \"freebase\": \"http://rdf.freebase.com/ns/m.03q3sy\",\n
|
118
|
+
\ \"name\": \"Michael Cera\",\n \"subType\":
|
119
|
+
[\n \"Person\",\n \"Actor\",\n
|
120
|
+
\ \"AwardNominee\",\n \"Celebrity\",\n
|
121
|
+
\ \"Dedicator\",\n \"FilmActor\",\n
|
122
|
+
\ \"FilmMusicContributor\",\n \"TVActor\"\n
|
123
|
+
\ ],\n \"website\": \"http://www.clarkandmichael.com/\",\n
|
124
|
+
\ \"yago\": \"http://yago-knowledge.org/resource/Michael_Cera\"\n
|
125
|
+
\ },\n \"name\": \"Michael Cera\",\n \"score\":
|
126
|
+
\"0.996665\"\n },\n \"positionX\": \"350\",\n \"positionY\":
|
127
|
+
\"91\",\n \"width\": \"46\"\n },\n {\n \"age\":
|
128
|
+
{\n \"ageRange\": \"55-64\",\n \"score\": \"0.617719\"\n
|
129
|
+
\ },\n \"gender\": {\n \"gender\": \"FEMALE\",\n
|
130
|
+
\ \"score\": \"0.994514\"\n },\n \"height\":
|
131
|
+
\"44\",\n \"identity\": {\n \"disambiguated\": {\n
|
132
|
+
\ \"dbpedia\": \"http://dbpedia.org/resource/Jessica_Walter\",\n
|
133
|
+
\ \"freebase\": \"http://rdf.freebase.com/ns/m.03q3x5\",\n
|
134
|
+
\ \"name\": \"Jessica Walter\",\n \"subType\":
|
135
|
+
[\n \"Person\",\n \"Actor\",\n
|
136
|
+
\ \"AwardNominee\",\n \"AwardWinner\",\n
|
137
|
+
\ \"FilmActor\",\n \"TVActor\"\n
|
138
|
+
\ ],\n \"yago\": \"http://yago-knowledge.org/resource/Jessica_Walter\"\n
|
139
|
+
\ },\n \"name\": \"Jessica Walter\",\n \"score\":
|
140
|
+
\"0.994514\"\n },\n \"positionX\": \"96\",\n \"positionY\":
|
141
|
+
\"92\",\n \"width\": \"44\"\n },\n {\n \"age\":
|
142
|
+
{\n \"ageRange\": \"18-24\",\n \"score\": \"0.664736\"\n
|
143
|
+
\ },\n \"gender\": {\n \"gender\": \"FEMALE\",\n
|
144
|
+
\ \"score\": \"0.994514\"\n },\n \"height\":
|
145
|
+
\"44\",\n \"identity\": {\n \"disambiguated\": {\n
|
146
|
+
\ \"dbpedia\": \"http://dbpedia.org/resource/Portia_de_Rossi\",\n
|
147
|
+
\ \"freebase\": \"http://rdf.freebase.com/ns/m.01pcz9\",\n
|
148
|
+
\ \"name\": \"Portia de Rossi\",\n \"opencyc\":
|
149
|
+
\"http://sw.opencyc.org/concept/Mx4rvu6nHZwpEbGdrcN5Y29ycA\",\n \"subType\":
|
150
|
+
[\n \"Person\",\n \"Actor\",\n
|
151
|
+
\ \"Celebrity\",\n \"DietFollower\",\n
|
152
|
+
\ \"FilmActor\",\n \"TVActor\"\n
|
153
|
+
\ ],\n \"yago\": \"http://yago-knowledge.org/resource/Portia_de_Rossi\"\n
|
154
|
+
\ },\n \"name\": \"Portia de Rossi\",\n \"score\":
|
155
|
+
\"0.991837\"\n },\n \"positionX\": \"20\",\n \"positionY\":
|
156
|
+
\"96\",\n \"width\": \"44\"\n }\n ]\n}\r\n"
|
157
|
+
http_version:
|
158
|
+
recorded_at: Mon, 22 Feb 2016 21:51:48 GMT
|
159
|
+
recorded_with: VCR 2.9.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy-api-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -100,28 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
103
|
+
version: 2.9.2
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
110
|
+
version: 2.9.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: webmock
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.19.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
124
|
+
version: 1.19.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: coveralls
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/alchemy-api/concept_tagging.rb
|
175
175
|
- lib/alchemy-api/config.rb
|
176
176
|
- lib/alchemy-api/entity_extraction.rb
|
177
|
+
- lib/alchemy-api/face_detection.rb
|
177
178
|
- lib/alchemy-api/image_tagging.rb
|
178
179
|
- lib/alchemy-api/keyword_extraction.rb
|
179
180
|
- lib/alchemy-api/language_detection.rb
|
@@ -191,6 +192,7 @@ files:
|
|
191
192
|
- spec/base_spec.rb
|
192
193
|
- spec/concept_tagging_spec.rb
|
193
194
|
- spec/entity_extraction_spec.rb
|
195
|
+
- spec/face_detection_spec.rb
|
194
196
|
- spec/image_tagging_spec.rb
|
195
197
|
- spec/keyword_extraction_spec.rb
|
196
198
|
- spec/language_detection_spec.rb
|
@@ -210,6 +212,7 @@ files:
|
|
210
212
|
- spec/vcr_cassettes/entity_basic_html_json_search.yml
|
211
213
|
- spec/vcr_cassettes/entity_basic_text_json_search.yml
|
212
214
|
- spec/vcr_cassettes/entity_basic_url_json_search.yml
|
215
|
+
- spec/vcr_cassettes/face_detection_basic_url_json_search.yml
|
213
216
|
- spec/vcr_cassettes/image_tagging_basic_url_json_search.yml
|
214
217
|
- spec/vcr_cassettes/keyword_basic_html_json_search.yml
|
215
218
|
- spec/vcr_cassettes/keyword_basic_text_json_search.yml
|
@@ -248,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
251
|
version: '0'
|
249
252
|
requirements: []
|
250
253
|
rubyforge_project:
|
251
|
-
rubygems_version: 2.
|
254
|
+
rubygems_version: 2.5.2
|
252
255
|
signing_key:
|
253
256
|
specification_version: 4
|
254
257
|
summary: This is a ruby client library that provides access to the Alechemy text mining
|
@@ -260,6 +263,7 @@ test_files:
|
|
260
263
|
- spec/base_spec.rb
|
261
264
|
- spec/concept_tagging_spec.rb
|
262
265
|
- spec/entity_extraction_spec.rb
|
266
|
+
- spec/face_detection_spec.rb
|
263
267
|
- spec/image_tagging_spec.rb
|
264
268
|
- spec/keyword_extraction_spec.rb
|
265
269
|
- spec/language_detection_spec.rb
|
@@ -279,6 +283,7 @@ test_files:
|
|
279
283
|
- spec/vcr_cassettes/entity_basic_html_json_search.yml
|
280
284
|
- spec/vcr_cassettes/entity_basic_text_json_search.yml
|
281
285
|
- spec/vcr_cassettes/entity_basic_url_json_search.yml
|
286
|
+
- spec/vcr_cassettes/face_detection_basic_url_json_search.yml
|
282
287
|
- spec/vcr_cassettes/image_tagging_basic_url_json_search.yml
|
283
288
|
- spec/vcr_cassettes/keyword_basic_html_json_search.yml
|
284
289
|
- spec/vcr_cassettes/keyword_basic_text_json_search.yml
|