alchemy-api-rb 0.4.0 → 0.5.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -0
- data/.travis.yml +7 -2
- data/CHANGELOG.md +23 -0
- data/CONTRIBUTING.md +117 -0
- data/README.md +32 -20
- data/Rakefile +6 -3
- data/alchemy-api-rb.gemspec +10 -9
- data/lib/alchemy-api/author_extraction.rb +1 -3
- data/lib/alchemy-api/base.rb +7 -11
- data/lib/alchemy-api/concept_tagging.rb +1 -2
- data/lib/alchemy-api/config.rb +3 -3
- data/lib/alchemy-api/entity_extraction.rb +1 -1
- data/lib/alchemy-api/image_tagging.rb +1 -1
- data/lib/alchemy-api/keyword_extraction.rb +1 -1
- data/lib/alchemy-api/language_detection.rb +0 -2
- data/lib/alchemy-api/relation_extraction.rb +1 -2
- data/lib/alchemy-api/sentiment_analysis.rb +1 -2
- data/lib/alchemy-api/targeted_sentiment_analysis.rb +1 -1
- data/lib/alchemy-api/taxonomy.rb +1 -2
- data/lib/alchemy-api/text_categorization.rb +0 -1
- data/lib/alchemy-api/text_extraction.rb +1 -1
- data/lib/alchemy-api/title_extraction.rb +1 -1
- data/lib/alchemy-api/version.rb +1 -1
- data/lib/alchemy_api.rb +19 -19
- data/spec/alchemy_api_spec.rb +22 -22
- data/spec/author_extraction_spec.rb +8 -19
- data/spec/base_spec.rb +13 -10
- data/spec/concept_tagging_spec.rb +11 -13
- data/spec/entity_extraction_spec.rb +13 -13
- data/spec/image_tagging_spec.rb +13 -11
- data/spec/keyword_extraction_spec.rb +13 -13
- data/spec/language_detection_spec.rb +10 -12
- data/spec/relation_extraction_spec.rb +12 -13
- data/spec/sentiment_analysis_spec.rb +11 -12
- data/spec/spec_helper.rb +3 -2
- data/spec/targeted_sentiment_analysis_spec.rb +16 -14
- data/spec/text_categorization_spec.rb +11 -12
- data/spec/text_extraction_spec.rb +7 -7
- metadata +37 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c725dda0bc9ef0485b08b94e4002de54d7101b1f
|
4
|
+
data.tar.gz: bf91f17e97f5f0fde36fb8dcb0a1ca96739fdcc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ae196f15536e7307688a104dd6a5a495f98df59ab0288572d94962440e5a0067fb73f8a980977ce561276f2054d9f9503260595ccc16700a4c055bc257d0858
|
7
|
+
data.tar.gz: 66a00d022c1640553078815b35369ef0f150a384725ec52800de06881a943b79aa35922e2ee0ac50b8422d65749ce2bf25726946bc1f85893450ed7b721f5d21
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- alchemy-api-rb.gemspec
|
4
|
+
- vendor/**/*
|
5
|
+
|
6
|
+
Documentation:
|
7
|
+
# don't require classes to be documented
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Encoding:
|
11
|
+
# no need to always specify encoding
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
LineLength:
|
15
|
+
# just one more character please
|
16
|
+
Max: 80
|
17
|
+
|
data/.travis.yml
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
3
|
+
cache: bundler
|
4
|
+
|
2
5
|
rvm:
|
3
6
|
- 2.1.2
|
7
|
+
- 2.1.0
|
4
8
|
- 2.0.0
|
5
9
|
- 1.9.3
|
6
|
-
- jruby
|
10
|
+
- jruby-19mode
|
11
|
+
|
7
12
|
env:
|
8
13
|
global:
|
9
14
|
secure: CubibQsfHYol2AlaplZH5Q1AiGJY/tn9pR9A06xrK28YQc4TLeEE4vrzntBiMd7UrgHjJ07gDshSF5muoCpLscuC0sK7LqHVA62iPYuIiK+9gd6+OPgnJ+3Rw5MMJLuboHkPwKHIMgCArtg+xPCHASxt4eK59wny80d9b7ifnnw=
|
10
|
-
|
15
|
+
|
11
16
|
addons:
|
12
17
|
code_climate:
|
13
18
|
repo_token: 412bc15e5c0d57c3381d70da56b468979f649edc02f3078f697d8f66334b3fc5
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Next Release
|
2
|
+
|
3
|
+
* Your contribution here.
|
4
|
+
* [#15](https://github.com/technekes/alchemy-api-rb/pull/15): Author extraction now returns a String (like title extraction) instead of a Hash - [@reshleman](https://github.com/reshleman).
|
5
|
+
|
6
|
+
# 0.4.0 (08/31/2014)
|
7
|
+
|
8
|
+
#### Features
|
9
|
+
|
10
|
+
* [#13](https://github.com/technekes/alchemy-api-rb/pull/13): Adds targeted sentiment analysis endpoint - [@vaibhao90](https://github.com/vaibhao90) and [@johnallen3d](https://github.com/johnallen3d).
|
11
|
+
|
12
|
+
# 0.3.0 (7/27/2014)
|
13
|
+
|
14
|
+
#### Features
|
15
|
+
|
16
|
+
* [#12](https://github.com/technekes/alchemy-api-rb/pull/12): Adds support for the image tagging endpoint - [@fdeschenes](https://github.com/fdeschenes).
|
17
|
+
* [#11](https://github.com/technekes/alchemy-api-rb/pull/11): Adds support for the title extraction endpoint - [@garretthunyadi](https://github.com/garretthunyadi).
|
18
|
+
* [#10](https://github.com/technekes/alchemy-api-rb/pull/10): Adds support for the taxonomy endpoint - [@garretthunyadi](https://github.com/garretthunyadi).
|
19
|
+
|
20
|
+
#### Fixes
|
21
|
+
|
22
|
+
* [#9](https://github.com/technekes/alchemy-api-rb/pull/9): Set excon adapter on faraday initialization - [@AdamFerguson](https://github.com/AdamFerguson).
|
23
|
+
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# Contributing to alchemy-api-rb
|
2
|
+
|
3
|
+
alchemy-api-rb is work of [several contributors](https://github.com/technekes/alchemy-api-rb/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/technekes/alchemy-api-rb/pulls), [propose features and discuss issues](https://github.com/technekes/alchemy-api-rb/issues).
|
4
|
+
|
5
|
+
#### Fork the Project
|
6
|
+
|
7
|
+
Fork the [project on Github](https://github.com/technekes/alchemy-api-rb) and check out your copy.
|
8
|
+
|
9
|
+
```
|
10
|
+
git clone https://github.com/contributor/alchemy-api-rb.git
|
11
|
+
cd alchemy-api-rb
|
12
|
+
git remote add upstream https://github.com/technekes/alchemy-api-rb.git
|
13
|
+
```
|
14
|
+
|
15
|
+
#### Create a Topic Branch
|
16
|
+
|
17
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
18
|
+
|
19
|
+
```
|
20
|
+
git checkout master
|
21
|
+
git pull upstream master
|
22
|
+
git checkout -b my-feature-branch
|
23
|
+
```
|
24
|
+
|
25
|
+
#### Bundle Install and Test
|
26
|
+
|
27
|
+
Ensure that you can build the project and run tests.
|
28
|
+
|
29
|
+
```
|
30
|
+
bundle install
|
31
|
+
ALCHEMY_API_KEY="this-is-my-40-character-key" bundle exec rake test
|
32
|
+
```
|
33
|
+
|
34
|
+
#### Write Tests
|
35
|
+
|
36
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/](spec/).
|
37
|
+
|
38
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
39
|
+
|
40
|
+
#### Write Code
|
41
|
+
|
42
|
+
Implement your feature or bug fix.
|
43
|
+
|
44
|
+
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
|
45
|
+
|
46
|
+
Make sure that `ALCHEMY_API_KEY="this-is-my-40-character-key" bundle exec rake test` completes without errors.
|
47
|
+
|
48
|
+
#### Write Documentation
|
49
|
+
|
50
|
+
Document any external behavior in the [README](README.md).
|
51
|
+
|
52
|
+
#### Update Changelog
|
53
|
+
|
54
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
|
55
|
+
|
56
|
+
#### Commit Changes
|
57
|
+
|
58
|
+
Make sure git knows your name and email address:
|
59
|
+
|
60
|
+
```
|
61
|
+
git config --global user.name "Your Name"
|
62
|
+
git config --global user.email "contributor@example.com"
|
63
|
+
```
|
64
|
+
|
65
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
66
|
+
|
67
|
+
```
|
68
|
+
git add ...
|
69
|
+
git commit
|
70
|
+
```
|
71
|
+
|
72
|
+
#### Push
|
73
|
+
|
74
|
+
```
|
75
|
+
git push origin my-feature-branch
|
76
|
+
```
|
77
|
+
|
78
|
+
#### Make a Pull Request
|
79
|
+
|
80
|
+
Go to https://github.com/technekes/alchemy-api-rb/compare and select your feature branch. Click the 'Create pull request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
81
|
+
|
82
|
+
#### Rebase
|
83
|
+
|
84
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
85
|
+
|
86
|
+
```
|
87
|
+
git fetch upstream
|
88
|
+
git rebase upstream/master
|
89
|
+
git push origin my-feature-branch -f
|
90
|
+
```
|
91
|
+
|
92
|
+
#### Update CHANGELOG Again
|
93
|
+
|
94
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
95
|
+
|
96
|
+
```
|
97
|
+
* [#13](https://github.com/technekes/alchemy-api-rb/pull/13): Adds targeted sentiment analysis endpoint - [@vaibhao90](https://github.com/vaibhao90) and [@johnallen3d](https://github.com/johnallen3d).
|
98
|
+
```
|
99
|
+
|
100
|
+
Amend your previous commit and force push the changes.
|
101
|
+
|
102
|
+
```
|
103
|
+
git commit --amend
|
104
|
+
git push origin my-feature-branch -f
|
105
|
+
```
|
106
|
+
|
107
|
+
#### Check on Your Pull Request
|
108
|
+
|
109
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
110
|
+
|
111
|
+
#### Be Patient
|
112
|
+
|
113
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
114
|
+
|
115
|
+
#### Thank You
|
116
|
+
|
117
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/README.md
CHANGED
@@ -32,7 +32,9 @@ Not yet implemented API's:
|
|
32
32
|
|
33
33
|
Add this line to your application's Gemfile:
|
34
34
|
|
35
|
-
|
35
|
+
```ruby
|
36
|
+
gem 'alchemy-api-rb', :require => 'alchemy_api'
|
37
|
+
```
|
36
38
|
|
37
39
|
And then execute:
|
38
40
|
|
@@ -48,35 +50,47 @@ You'll need to [request an API Key](http://www.alchemyapi.com/api/register.html)
|
|
48
50
|
|
49
51
|
Set your API Key in an initializer or something similar:
|
50
52
|
|
51
|
-
|
53
|
+
```ruby
|
54
|
+
AlchemyAPI.key = "xxxxxxxxxxxxxxxxxx"
|
55
|
+
```
|
52
56
|
|
53
57
|
You may set the key along with other config settings:
|
54
58
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
```ruby
|
60
|
+
AlchemyAPI.configure do |config|
|
61
|
+
config.apikey = "xxxxxxxxxxxxxxxxxx"
|
62
|
+
config.output_mode = :xml # not yet supported
|
63
|
+
end
|
64
|
+
```
|
59
65
|
|
60
66
|
Request keyword extraction for a string of text:
|
61
67
|
|
62
|
-
|
68
|
+
```ruby
|
69
|
+
results = AlchemyAPI.search(:keyword_extraction, text: "hello world")
|
70
|
+
```
|
63
71
|
|
64
72
|
or
|
65
73
|
|
66
|
-
|
74
|
+
```ruby
|
75
|
+
results = AlchemyAPI::KeywordExtraction.new.search(url: 'http://www.alchemyapi.com/')
|
76
|
+
```
|
67
77
|
|
68
78
|
or
|
69
79
|
|
70
|
-
|
80
|
+
```ruby
|
81
|
+
results = AlchemyAPI::KeywordExtraction.new.search(html: "<html><body>lorem ipsum</body></html>")
|
82
|
+
```
|
71
83
|
|
72
84
|
Results for keyword extraction are returned as a array of keywords:
|
73
85
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
86
|
+
```ruby
|
87
|
+
[
|
88
|
+
{
|
89
|
+
"text" => 'lorem ipsum',
|
90
|
+
"relevance" => "0.993164"
|
91
|
+
}
|
92
|
+
]
|
93
|
+
```
|
80
94
|
|
81
95
|
## Testing
|
82
96
|
|
@@ -96,11 +110,9 @@ If you would like to expirement with the API you can run the `console` rake task
|
|
96
110
|
|
97
111
|
## Contributing
|
98
112
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
103
|
-
5. Create new Pull Request
|
113
|
+
alchemy-api-rb is work of several contributors. You're encouraged to submit pull requests, propose features and discuss issues.
|
114
|
+
|
115
|
+
See [CONTRIBUTING](CONTRIBUTING.md).
|
104
116
|
|
105
117
|
## License
|
106
118
|
|
data/Rakefile
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require
|
2
|
+
require 'bundler/gem_tasks'
|
3
3
|
require 'rake/testtask'
|
4
|
+
require 'rubocop/rake_task'
|
4
5
|
|
5
|
-
|
6
|
+
RuboCop::RakeTask.new(:rubocop)
|
7
|
+
|
8
|
+
task default: [:rubocop, :test]
|
6
9
|
|
7
10
|
Rake::TestTask.new do |t|
|
8
|
-
t.libs.push
|
11
|
+
t.libs.push 'lib'
|
9
12
|
t.test_files = FileList['spec/**/*_spec.rb']
|
10
13
|
t.verbose = true
|
11
14
|
end
|
data/alchemy-api-rb.gemspec
CHANGED
@@ -16,14 +16,15 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = AlchemyAPI::VERSION
|
18
18
|
|
19
|
-
gem.add_dependency 'faraday', '~> 0.8.
|
20
|
-
gem.add_dependency 'excon', '~> 0.28.
|
19
|
+
gem.add_dependency 'faraday', '~> 0.8.0'
|
20
|
+
gem.add_dependency 'excon', '~> 0.28.0'
|
21
21
|
|
22
|
-
gem.add_development_dependency 'minitest', '~> 5.4.
|
23
|
-
gem.add_development_dependency 'pry', '~> 0.10.
|
24
|
-
gem.add_development_dependency 'rake', '~> 10.3.
|
25
|
-
gem.add_development_dependency 'minitest-reporters', '~> 1.0.
|
26
|
-
gem.add_development_dependency 'vcr', '~> 2.3.
|
27
|
-
gem.add_development_dependency 'webmock', '~> 1.18.
|
28
|
-
gem.add_development_dependency 'coveralls', '~> 0.7.
|
22
|
+
gem.add_development_dependency 'minitest', '~> 5.4.0'
|
23
|
+
gem.add_development_dependency 'pry', '~> 0.10.0'
|
24
|
+
gem.add_development_dependency 'rake', '~> 10.3.0'
|
25
|
+
gem.add_development_dependency 'minitest-reporters', '~> 1.0.0'
|
26
|
+
gem.add_development_dependency 'vcr', '~> 2.3.0'
|
27
|
+
gem.add_development_dependency 'webmock', '~> 1.18.0'
|
28
|
+
gem.add_development_dependency 'coveralls', '~> 0.7.0'
|
29
|
+
gem.add_development_dependency 'rubocop', '~> 0.25.0'
|
29
30
|
end
|
data/lib/alchemy-api/base.rb
CHANGED
@@ -20,7 +20,7 @@ module AlchemyAPI
|
|
20
20
|
indexer ? parsed[indexer] : parsed
|
21
21
|
when :xml
|
22
22
|
when :rdf
|
23
|
-
|
23
|
+
fail NotImplementedError
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -33,11 +33,8 @@ module AlchemyAPI
|
|
33
33
|
def check_options(opts)
|
34
34
|
@options = opts
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
unless supported_search_types.include?(mode)
|
39
|
-
raise UnsupportedSearchMode.new
|
40
|
-
end
|
36
|
+
fail MissingOptionsError unless options && options.keys
|
37
|
+
fail UnsupportedSearchMode unless supported_search_types.include?(mode)
|
41
38
|
end
|
42
39
|
|
43
40
|
def connection
|
@@ -55,14 +52,14 @@ module AlchemyAPI
|
|
55
52
|
return type if options.keys && options.keys.include?(type)
|
56
53
|
end
|
57
54
|
|
58
|
-
|
55
|
+
fail MissingOptionsError
|
59
56
|
end
|
60
57
|
|
61
58
|
def method_prefix
|
62
59
|
case mode
|
63
|
-
when :text then
|
64
|
-
when :url
|
65
|
-
when :html then
|
60
|
+
when :text then 'Text'
|
61
|
+
when :url then 'URL'
|
62
|
+
when :html then 'HTML'
|
66
63
|
end
|
67
64
|
end
|
68
65
|
|
@@ -77,4 +74,3 @@ module AlchemyAPI
|
|
77
74
|
end
|
78
75
|
end
|
79
76
|
end
|
80
|
-
|
data/lib/alchemy-api/config.rb
CHANGED
@@ -13,7 +13,7 @@ module AlchemyAPI
|
|
13
13
|
|
14
14
|
def self.default_options
|
15
15
|
{
|
16
|
-
:
|
16
|
+
outputMode: output_mode
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
@@ -22,13 +22,13 @@ module AlchemyAPI
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.output_mode=(value)
|
25
|
-
|
25
|
+
fail InvalidOutputMode unless valid_output_modes.include?(value.to_s)
|
26
26
|
|
27
27
|
@output_mode = value
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.valid_output_modes
|
31
|
-
[
|
31
|
+
['xml', 'json', 'rdf', 'rel-tag', 'rel-tag-raw']
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|