alchemy-api-rb 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/alchemy-api-rb.gemspec +2 -2
- data/lib/alchemy-api/targeted_sentiment_analysis.rb +15 -0
- data/lib/alchemy-api/version.rb +1 -1
- data/lib/alchemy_api.rb +1 -0
- data/spec/alchemy_api_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/targeted_sentiment_analysis_spec.rb +44 -0
- data/spec/vcr_cassettes/sentiment_targeted_html_json_search.yml +41 -0
- data/spec/vcr_cassettes/sentiment_targeted_text_json_search.yml +41 -0
- data/spec/vcr_cassettes/sentiment_targeted_url_json_search.yml +41 -0
- metadata +16 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fe783161cfc11d94ad31463753b5934d0699d30
|
4
|
+
data.tar.gz: fc79c8485c2d26797f58ddba5de5c9b27e06dcf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ee9b8997c5c4cae595ba7b3fd8ab2e5c56299a5b1474203e36309f5bf77b406742f314a2e75c1f75c8a508d38ced446ea74e9fb2d6ae170175e991c2f435e79
|
7
|
+
data.tar.gz: c2d22edcf5ba13d52f586a8c8837277999c6ee69f270deba3c46c9a891ac16b18e2792df7f99e69812a4396861cb75dc02011e0efdec31a91aa3c618488e7ebc
|
data/README.md
CHANGED
@@ -10,13 +10,16 @@ This is a Ruby Client Library that provides access to the [Alchemy text mining A
|
|
10
10
|
|
11
11
|
* Keyword Extraction
|
12
12
|
* Text Extraction
|
13
|
+
* Title Extraction
|
13
14
|
* Entity Extraction
|
14
|
-
* Relation Extraction
|
15
15
|
* Sentiment Analysis
|
16
|
+
* Targeted Sentiment Analysis
|
17
|
+
* Relation Extraction
|
16
18
|
* Concept Tagging
|
17
19
|
* Text Categorization
|
18
20
|
* Language Detection
|
19
21
|
* Author Extraction
|
22
|
+
* Taxonomy
|
20
23
|
* Image Tagging
|
21
24
|
|
22
25
|
Not yet implemented API's:
|
data/alchemy-api-rb.gemspec
CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_dependency 'faraday', '~> 0.8.x'
|
20
20
|
gem.add_dependency 'excon', '~> 0.28.x'
|
21
21
|
|
22
|
-
gem.add_development_dependency 'minitest', '~>
|
22
|
+
gem.add_development_dependency 'minitest', '~> 5.4.x'
|
23
23
|
gem.add_development_dependency 'pry', '~> 0.10.x'
|
24
24
|
gem.add_development_dependency 'rake', '~> 10.3.x'
|
25
|
-
gem.add_development_dependency '
|
25
|
+
gem.add_development_dependency 'minitest-reporters', '~> 1.0.x'
|
26
26
|
gem.add_development_dependency 'vcr', '~> 2.3.x'
|
27
27
|
gem.add_development_dependency 'webmock', '~> 1.18.x'
|
28
28
|
gem.add_development_dependency 'coveralls', '~> 0.7.x'
|
data/lib/alchemy-api/version.rb
CHANGED
data/lib/alchemy_api.rb
CHANGED
@@ -6,6 +6,7 @@ require "alchemy-api/text_extraction"
|
|
6
6
|
require "alchemy-api/title_extraction"
|
7
7
|
require "alchemy-api/entity_extraction"
|
8
8
|
require "alchemy-api/sentiment_analysis"
|
9
|
+
require "alchemy-api/targeted_sentiment_analysis"
|
9
10
|
require "alchemy-api/relation_extraction"
|
10
11
|
require "alchemy-api/concept_tagging"
|
11
12
|
require "alchemy-api/text_categorization"
|
data/spec/alchemy_api_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'minitest/spec'
|
2
2
|
require 'minitest/autorun'
|
3
|
-
require '
|
3
|
+
require 'minitest/reporters'
|
4
4
|
require 'webmock/minitest'
|
5
5
|
require 'vcr'
|
6
6
|
require 'pry'
|
@@ -9,6 +9,7 @@ require 'coveralls'
|
|
9
9
|
|
10
10
|
CodeClimate::TestReporter.start
|
11
11
|
Coveralls.wear!
|
12
|
+
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
|
12
13
|
|
13
14
|
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/alchemy_api'))
|
14
15
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
|
+
|
3
|
+
describe AlchemyAPI, "targeted_sentiment_analysis" do
|
4
|
+
before do
|
5
|
+
AlchemyAPI::Config.apikey = API_KEY
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:keyphrase) { "alchemyapi" }
|
9
|
+
|
10
|
+
subject() { AlchemyAPI::TargetedSentimentAnalysis.new }
|
11
|
+
|
12
|
+
describe "#search" do
|
13
|
+
{
|
14
|
+
:text => "AlchemyAPI is cool",
|
15
|
+
:html => "<html><body>AlchemyAPI is cool</body></html>",
|
16
|
+
:url => "http://www.alchemyapi.com"
|
17
|
+
}.each do |type,value|
|
18
|
+
[:json].each do |output_mode|
|
19
|
+
before do
|
20
|
+
AlchemyAPI::Config.output_mode = output_mode
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#{type} search with #{output_mode} results" do
|
24
|
+
it "returns an array of results" do
|
25
|
+
VCR.use_cassette("sentiment_targeted_#{type}_#{output_mode}_search") do
|
26
|
+
result = subject.search(type => value, :target => keyphrase)
|
27
|
+
|
28
|
+
result.must_be_instance_of Hash
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "includes the keyword text and relavence" do
|
33
|
+
VCR.use_cassette("sentiment_targeted_#{type}_#{output_mode}_search") do
|
34
|
+
result = subject.search(type => value, :target => keyphrase)
|
35
|
+
|
36
|
+
result["type"].wont_be_nil
|
37
|
+
result["score"].wont_be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://access.alchemyapi.com/calls/html/HTMLGetTargetedSentiment
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: apikey=ALCHEMY_KEY&html=<html><body>AlchemyAPI is cool</body></html>&target=alchemyapi&outputMode=json
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: ''
|
16
|
+
headers:
|
17
|
+
Server:
|
18
|
+
- nginx
|
19
|
+
Date:
|
20
|
+
- Sun, 31 Aug 2014 21:50:32 GMT
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
Content-Length:
|
24
|
+
- '351'
|
25
|
+
Connection:
|
26
|
+
- close
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- "*, *"
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: "{\r\n \"status\": \"OK\",\r\n \"usage\": \"By accessing AlchemyAPI
|
34
|
+
or using information generated by AlchemyAPI, you are agreeing to be bound
|
35
|
+
by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html\",\r\n
|
36
|
+
\ \"url\": \"\",\r\n \"language\": \"english\",\r\n \"docSentiment\":
|
37
|
+
{\r\n \"type\": \"positive\",\r\n \"score\": \"0.65298\"\r\n
|
38
|
+
\ }\r\n}\r\n"
|
39
|
+
http_version:
|
40
|
+
recorded_at: Sun, 31 Aug 2014 21:50:32 GMT
|
41
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://access.alchemyapi.com/calls/text/TextGetTargetedSentiment
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: apikey=ALCHEMY_KEY&text=AlchemyAPI is cool&target=alchemyapi&outputMode=json
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: ''
|
16
|
+
headers:
|
17
|
+
Server:
|
18
|
+
- nginx
|
19
|
+
Date:
|
20
|
+
- Sun, 31 Aug 2014 21:50:33 GMT
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
Content-Length:
|
24
|
+
- '351'
|
25
|
+
Connection:
|
26
|
+
- close
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- "*, *"
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: "{\r\n \"status\": \"OK\",\r\n \"usage\": \"By accessing AlchemyAPI
|
34
|
+
or using information generated by AlchemyAPI, you are agreeing to be bound
|
35
|
+
by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html\",\r\n
|
36
|
+
\ \"url\": \"\",\r\n \"language\": \"english\",\r\n \"docSentiment\":
|
37
|
+
{\r\n \"type\": \"positive\",\r\n \"score\": \"0.65298\"\r\n
|
38
|
+
\ }\r\n}\r\n"
|
39
|
+
http_version:
|
40
|
+
recorded_at: Sun, 31 Aug 2014 21:50:33 GMT
|
41
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://access.alchemyapi.com/calls/url/URLGetTargetedSentiment
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: apikey=ALCHEMY_KEY&url=http://www.alchemyapi.com&target=alchemyapi&outputMode=json
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: ''
|
16
|
+
headers:
|
17
|
+
Server:
|
18
|
+
- nginx
|
19
|
+
Date:
|
20
|
+
- Sun, 31 Aug 2014 21:50:33 GMT
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
Content-Length:
|
24
|
+
- '378'
|
25
|
+
Connection:
|
26
|
+
- close
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- "*, *"
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: "{\r\n \"status\": \"OK\",\r\n \"usage\": \"By accessing AlchemyAPI
|
34
|
+
or using information generated by AlchemyAPI, you are agreeing to be bound
|
35
|
+
by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html\",\r\n
|
36
|
+
\ \"url\": \"http://www.alchemyapi.com/\",\r\n \"language\": \"english\",\r\n
|
37
|
+
\ \"docSentiment\": {\r\n \"type\": \"positive\",\r\n \"score\":
|
38
|
+
\"0.466968\"\r\n }\r\n}\r\n"
|
39
|
+
http_version:
|
40
|
+
recorded_at: Sun, 31 Aug 2014 21:50:33 GMT
|
41
|
+
recorded_with: VCR 2.9.2
|
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.4.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: 2014-
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 5.4.x
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 5.4.x
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,19 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 10.3.x
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: minitest-reporters
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 1.0.x
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 1.0.x
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: vcr
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/alchemy-api/language_detection.rb
|
162
162
|
- lib/alchemy-api/relation_extraction.rb
|
163
163
|
- lib/alchemy-api/sentiment_analysis.rb
|
164
|
+
- lib/alchemy-api/targeted_sentiment_analysis.rb
|
164
165
|
- lib/alchemy-api/taxonomy.rb
|
165
166
|
- lib/alchemy-api/text_categorization.rb
|
166
167
|
- lib/alchemy-api/text_extraction.rb
|
@@ -178,6 +179,7 @@ files:
|
|
178
179
|
- spec/relation_extraction_spec.rb
|
179
180
|
- spec/sentiment_analysis_spec.rb
|
180
181
|
- spec/spec_helper.rb
|
182
|
+
- spec/targeted_sentiment_analysis_spec.rb
|
181
183
|
- spec/text_categorization_spec.rb
|
182
184
|
- spec/text_extraction_spec.rb
|
183
185
|
- spec/vcr_cassettes/author_basic_html_json_search.yml
|
@@ -203,6 +205,9 @@ files:
|
|
203
205
|
- spec/vcr_cassettes/sentiment_basic_html_json_search.yml
|
204
206
|
- spec/vcr_cassettes/sentiment_basic_text_json_search.yml
|
205
207
|
- spec/vcr_cassettes/sentiment_basic_url_json_search.yml
|
208
|
+
- spec/vcr_cassettes/sentiment_targeted_html_json_search.yml
|
209
|
+
- spec/vcr_cassettes/sentiment_targeted_text_json_search.yml
|
210
|
+
- spec/vcr_cassettes/sentiment_targeted_url_json_search.yml
|
206
211
|
- spec/vcr_cassettes/text_basic_html_json_search.yml
|
207
212
|
- spec/vcr_cassettes/text_basic_url_json_search.yml
|
208
213
|
homepage: https://github.com/technekes/alchemy-api-rb
|
@@ -243,6 +248,7 @@ test_files:
|
|
243
248
|
- spec/relation_extraction_spec.rb
|
244
249
|
- spec/sentiment_analysis_spec.rb
|
245
250
|
- spec/spec_helper.rb
|
251
|
+
- spec/targeted_sentiment_analysis_spec.rb
|
246
252
|
- spec/text_categorization_spec.rb
|
247
253
|
- spec/text_extraction_spec.rb
|
248
254
|
- spec/vcr_cassettes/author_basic_html_json_search.yml
|
@@ -268,5 +274,8 @@ test_files:
|
|
268
274
|
- spec/vcr_cassettes/sentiment_basic_html_json_search.yml
|
269
275
|
- spec/vcr_cassettes/sentiment_basic_text_json_search.yml
|
270
276
|
- spec/vcr_cassettes/sentiment_basic_url_json_search.yml
|
277
|
+
- spec/vcr_cassettes/sentiment_targeted_html_json_search.yml
|
278
|
+
- spec/vcr_cassettes/sentiment_targeted_text_json_search.yml
|
279
|
+
- spec/vcr_cassettes/sentiment_targeted_url_json_search.yml
|
271
280
|
- spec/vcr_cassettes/text_basic_html_json_search.yml
|
272
281
|
- spec/vcr_cassettes/text_basic_url_json_search.yml
|