alchemy-api-rb 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -0
  3. data/.travis.yml +7 -2
  4. data/CHANGELOG.md +23 -0
  5. data/CONTRIBUTING.md +117 -0
  6. data/README.md +32 -20
  7. data/Rakefile +6 -3
  8. data/alchemy-api-rb.gemspec +10 -9
  9. data/lib/alchemy-api/author_extraction.rb +1 -3
  10. data/lib/alchemy-api/base.rb +7 -11
  11. data/lib/alchemy-api/concept_tagging.rb +1 -2
  12. data/lib/alchemy-api/config.rb +3 -3
  13. data/lib/alchemy-api/entity_extraction.rb +1 -1
  14. data/lib/alchemy-api/image_tagging.rb +1 -1
  15. data/lib/alchemy-api/keyword_extraction.rb +1 -1
  16. data/lib/alchemy-api/language_detection.rb +0 -2
  17. data/lib/alchemy-api/relation_extraction.rb +1 -2
  18. data/lib/alchemy-api/sentiment_analysis.rb +1 -2
  19. data/lib/alchemy-api/targeted_sentiment_analysis.rb +1 -1
  20. data/lib/alchemy-api/taxonomy.rb +1 -2
  21. data/lib/alchemy-api/text_categorization.rb +0 -1
  22. data/lib/alchemy-api/text_extraction.rb +1 -1
  23. data/lib/alchemy-api/title_extraction.rb +1 -1
  24. data/lib/alchemy-api/version.rb +1 -1
  25. data/lib/alchemy_api.rb +19 -19
  26. data/spec/alchemy_api_spec.rb +22 -22
  27. data/spec/author_extraction_spec.rb +8 -19
  28. data/spec/base_spec.rb +13 -10
  29. data/spec/concept_tagging_spec.rb +11 -13
  30. data/spec/entity_extraction_spec.rb +13 -13
  31. data/spec/image_tagging_spec.rb +13 -11
  32. data/spec/keyword_extraction_spec.rb +13 -13
  33. data/spec/language_detection_spec.rb +10 -12
  34. data/spec/relation_extraction_spec.rb +12 -13
  35. data/spec/sentiment_analysis_spec.rb +11 -12
  36. data/spec/spec_helper.rb +3 -2
  37. data/spec/targeted_sentiment_analysis_spec.rb +16 -14
  38. data/spec/text_categorization_spec.rb +11 -12
  39. data/spec/text_extraction_spec.rb +7 -7
  40. metadata +37 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fe783161cfc11d94ad31463753b5934d0699d30
4
- data.tar.gz: fc79c8485c2d26797f58ddba5de5c9b27e06dcf5
3
+ metadata.gz: c725dda0bc9ef0485b08b94e4002de54d7101b1f
4
+ data.tar.gz: bf91f17e97f5f0fde36fb8dcb0a1ca96739fdcc0
5
5
  SHA512:
6
- metadata.gz: 7ee9b8997c5c4cae595ba7b3fd8ab2e5c56299a5b1474203e36309f5bf77b406742f314a2e75c1f75c8a508d38ced446ea74e9fb2d6ae170175e991c2f435e79
7
- data.tar.gz: c2d22edcf5ba13d52f586a8c8837277999c6ee69f270deba3c46c9a891ac16b18e2792df7f99e69812a4396861cb75dc02011e0efdec31a91aa3c618488e7ebc
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
- cache: bundler
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
- gem 'alchemy-api-rb', :require => 'alchemy_api'
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
- AlchemyAPI.key = "xxxxxxxxxxxxxxxxxx"
53
+ ```ruby
54
+ AlchemyAPI.key = "xxxxxxxxxxxxxxxxxx"
55
+ ```
52
56
 
53
57
  You may set the key along with other config settings:
54
58
 
55
- AlchemyAPI.configure do |config|
56
- config.apikey = "xxxxxxxxxxxxxxxxxx"
57
- config.output_mode = :xml # not yet supported
58
- end
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
- results = AlchemyAPI.search(:keyword_extraction, :text => "hello world")
68
+ ```ruby
69
+ results = AlchemyAPI.search(:keyword_extraction, text: "hello world")
70
+ ```
63
71
 
64
72
  or
65
73
 
66
- results = AlchemyAPI::KeywordExtraction.new.search(:url => "http://www.alchemyapi.com/")
74
+ ```ruby
75
+ results = AlchemyAPI::KeywordExtraction.new.search(url: 'http://www.alchemyapi.com/')
76
+ ```
67
77
 
68
78
  or
69
79
 
70
- results = AlchemyAPI::KeywordExtraction.new.search(:html => "<html><body>lorem ipsum</body></html>")
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
- "text" => "lorem ipsum",
77
- "relevance" => "0.993164"
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
- 1. Fork it
100
- 2. Create your feature branch (`git checkout -b my-new-feature`)
101
- 3. Commit your changes (`git commit -am 'Added some feature'`)
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 "bundler/gem_tasks"
2
+ require 'bundler/gem_tasks'
3
3
  require 'rake/testtask'
4
+ require 'rubocop/rake_task'
4
5
 
5
- task :default => [:test]
6
+ RuboCop::RakeTask.new(:rubocop)
7
+
8
+ task default: [:rubocop, :test]
6
9
 
7
10
  Rake::TestTask.new do |t|
8
- t.libs.push "lib"
11
+ t.libs.push 'lib'
9
12
  t.test_files = FileList['spec/**/*_spec.rb']
10
13
  t.verbose = true
11
14
  end
@@ -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.x'
20
- gem.add_dependency 'excon', '~> 0.28.x'
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.x'
23
- gem.add_development_dependency 'pry', '~> 0.10.x'
24
- gem.add_development_dependency 'rake', '~> 10.3.x'
25
- gem.add_development_dependency 'minitest-reporters', '~> 1.0.x'
26
- gem.add_development_dependency 'vcr', '~> 2.3.x'
27
- gem.add_development_dependency 'webmock', '~> 1.18.x'
28
- gem.add_development_dependency 'coveralls', '~> 0.7.x'
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
@@ -13,9 +13,7 @@ module AlchemyAPI
13
13
  end
14
14
 
15
15
  def indexer
16
- nil
16
+ 'author'
17
17
  end
18
18
  end
19
19
  end
20
-
21
-
@@ -20,7 +20,7 @@ module AlchemyAPI
20
20
  indexer ? parsed[indexer] : parsed
21
21
  when :xml
22
22
  when :rdf
23
- raise NotImplementedError.new
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
- raise MissingOptionsError.new unless options && options.keys
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
- raise MissingOptionsError.new
55
+ fail MissingOptionsError
59
56
  end
60
57
 
61
58
  def method_prefix
62
59
  case mode
63
- when :text then "Text"
64
- when :url then "URL"
65
- when :html then "HTML"
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
-
@@ -9,8 +9,7 @@ module AlchemyAPI
9
9
  private
10
10
 
11
11
  def indexer
12
- "concepts"
12
+ 'concepts'
13
13
  end
14
14
  end
15
15
  end
16
-
@@ -13,7 +13,7 @@ module AlchemyAPI
13
13
 
14
14
  def self.default_options
15
15
  {
16
- :outputMode => output_mode
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
- raise InvalidOutputMode.new unless valid_output_modes.include?(value.to_s)
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
- ["xml", "json", "rdf", "rel-tag", "rel-tag-raw"]
31
+ ['xml', 'json', 'rdf', 'rel-tag', 'rel-tag-raw']
32
32
  end
33
33
  end
34
34
  end
@@ -9,7 +9,7 @@ module AlchemyAPI
9
9
  private
10
10
 
11
11
  def indexer
12
- "entities"
12
+ 'entities'
13
13
  end
14
14
  end
15
15
  end
@@ -13,7 +13,7 @@ module AlchemyAPI
13
13
  end
14
14
 
15
15
  def indexer
16
- "imageKeywords"
16
+ 'imageKeywords'
17
17
  end
18
18
  end
19
19
  end
@@ -9,7 +9,7 @@ module AlchemyAPI
9
9
  private
10
10
 
11
11
  def indexer
12
- "keywords"
12
+ 'keywords'
13
13
  end
14
14
  end
15
15
  end