dandelionapi 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60d3e32d3e0ace88c7ac96380733d7b3968e1175
4
- data.tar.gz: 648a796836193a56970191832d2f617f6616f029
3
+ metadata.gz: e24257bbcc32e368db80064ce40f9ddd15c2c6a8
4
+ data.tar.gz: bc758810bdfb49dbb0767b5f2018e13730ca234d
5
5
  SHA512:
6
- metadata.gz: 38e9f41a10552bb8eb437ac5c5e861d78023258faec7dd6fda4410dea1281b69644936016b45684e4186f0857f41483589532286c88b27cca5909b2633f0ec04
7
- data.tar.gz: d3279f1b0da0686284b87db77f835b94ba90615c5e3cf677b9a17b79cfce495809da31537ec86312bb06cbb97fb43ad2d04b36555e9845f14547f747372ae68f
6
+ metadata.gz: a0408cdf917450acb12259956dd8852654cd154cd0f0fd5b7d482a7773c305985fd3300677a62461903d7d52eee1357215c5efd6372c641f10298dee607a74ea
7
+ data.tar.gz: b9696acda5c66d2c2c5cd17817010b52d88adc09f3bb23340a157b70c5db8312e291c07096145a0ecb76e8b1adb1d66847ab8548db614928a85fc67352c1075d
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- *.gem
10
+ *.gem
11
+ .DS_Store
@@ -8,6 +8,3 @@ rvm:
8
8
  - rbx-2.4.1
9
9
  - rbx-2.5.2
10
10
  before_install: gem install bundler -v 1.10.5
11
- addons:
12
- code_climate:
13
- repo_token: c29ce9f7996f73f58b0d180bf8f0432e1f7ab65950bef51e33bc44e1db244d8d
data/README.md CHANGED
@@ -31,23 +31,44 @@ end
31
31
 
32
32
  _Methods references are taken from [Dandelion API's documentation](https://dandelion.eu/docs/)._
33
33
 
34
- **[Entity Extraction API](https://dandelion.eu/docs/api/datatxt/nex/v1/)**: is a named entity extraction & linking API that performs very well even on short texts, on which many other similar services do not. dataTXT-NEX currently works on English, French, German, Italian and Portuguese texts. With this API you will be able to automatically tag your texts, extracting Wikipedia entities and enriching your data.
34
+ **[Entity Extraction API](https://dandelion.eu/docs/api/datatxt/nex/v1/)**: This is a named entity extraction & linking API that performs very well even on short texts, on which many other similar services do not. It currently works on English, French, German, Italian and Portuguese texts. With this API you will be able to automatically tag your texts, extracting Wikipedia entities and enriching your data.
35
35
 
36
36
  ```
37
37
  element = Dandelionapi::EntityExtraction.new
38
38
  response = element.analyze(text: "This is a test")
39
39
  ```
40
40
 
41
- **[Text Similarity API](https://dandelion.eu/docs/api/datatxt/sim/v1/)**: is a semantic sentence similarity API optimized on short sentences. With this API you will be able to compare two sentences and get a score of their semantic similarity. It works even if the two sentences don't have any word in common.
41
+ **[Text Similarity API](https://dandelion.eu/docs/api/datatxt/sim/v1/)**: This API is a semantic sentence similarity API optimized on short sentences. With this API you will be able to compare two sentences and get a score of their semantic similarity. It works even if the two sentences don't have any word in common.
42
42
 
43
43
  ```
44
44
  element = Dandelionapi::TextSimilarity.new
45
45
  response = element.analyze(text1: "This is a test", text2: "This is another test")
46
46
  ```
47
47
 
48
- **[Language Detection API](https://dandelion.eu/docs/api/datatxt/li/v1/)**: is a simple language identification API; it is a tool that may be useful when dealing with texts, so we decided to open it to all our users. It currently supports more than 50 languages.
48
+ **[Language Detection API](https://dandelion.eu/docs/api/datatxt/li/v1/)**:
49
+ Language Detection API is a simple language identification API; it is a tool that may be useful when dealing with texts, so we decided to open it to all our users. It currently supports more than 96 languages.
49
50
 
50
51
  ```
51
52
  element = Dandelionapi::LanguageDetection.new
52
53
  response = element.analyze(text: "Questo è un test")
53
54
  ```
55
+
56
+ **[Sentiment Analysis API](https://dandelion.eu/docs/api/datatxt/sent/v1/)**: This API analyses a text and tells whether the expressed opinion is positive, negative, or neutral. Given a short sentence, it returns a label representing the identified sentiment, along with a numeric score ranging from strongly positive (1.0) to extremely negative (-1.0).
57
+
58
+ ```
59
+ element = Dandelionapi::SentimentAnalysis.new
60
+ response = element.analyze(text: "I'm really disappointed")
61
+ ```
62
+
63
+ ## About the DandelionAPI project
64
+
65
+ This library is part of a larger group of libraries used to explore best strategies to build packages among multiple languages. Each library is written using conventions about coding style, filesystem structure, testing, documentation and distribution typical of the language enviroment but preserve the library main concepts. This version use the following conventions:
66
+
67
+ - Tested using [RSpec](http://rspec.info/)
68
+ - Documented using [YARD](http://yardoc.org/)
69
+ - Packed using [Bundler](http://bundler.io/) and [Gem](https://rubygems.org/)
70
+ - Distributed over [RubyGems](https://rubygems.org/) as [dandelionapi](https://rubygems.org/gems/dandelionapi)
71
+
72
+ ----
73
+
74
+ Here is the complete list of libraries available: [Ruby](https://github.com/zenkay/dandelionapi-ruby), [PHP](https://github.com/zenkay/dandelionapi-php), [Node](https://github.com/zenkay/dandelionapi-node)
@@ -31,4 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "webmock", "~> 1.21"
32
32
  spec.add_development_dependency "simplecov", "~> 0.10"
33
33
  spec.add_development_dependency "coveralls", "~> 0.8"
34
+ spec.add_development_dependency "yard", "~> 0.8"
34
35
  end
@@ -6,20 +6,41 @@ require "dandelionapi/base"
6
6
  require "dandelionapi/entity_extraction"
7
7
  require "dandelionapi/text_similarity"
8
8
  require "dandelionapi/language_detection"
9
+ require "dandelionapi/sentiment_analysis"
9
10
 
10
11
  module Dandelionapi
12
+
13
+ # Class method to set up configuration parameters
14
+ #
15
+ # @example
16
+ # Dandelionapi.configure do |c|
17
+ # c.app_id = "test"
18
+ # end
19
+ #
11
20
  def self.configure(&block)
12
21
  yield @config ||= Configuration.new
13
22
  end
14
23
 
24
+ # Return configuration parameters
25
+ #
26
+ # @example
27
+ # Dandelionapi.config.app_id
28
+ #
15
29
  def self.config
16
30
  @config
17
31
  end
18
32
 
33
+ # Container for configuration parameters
34
+ #
19
35
  class Configuration
20
36
  attr_accessor :app_id, :app_key, :endpoint
21
37
  end
22
38
 
39
+ # Exception raised for connection error
40
+ #
23
41
  class BadResponse < Exception; end
42
+
43
+ # Exception raised when a mandatory parameter is missing
44
+ #
24
45
  class MissingParameters < Exception; end
25
46
  end
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+
3
+ require "faraday"
4
+ require "faraday_middleware"
5
+ require "json"
6
+
7
+ module Dandelionapi
8
+
9
+ class SentimentAnalysis < Base
10
+
11
+ ENDPOINT = "/datatxt/sent/v1"
12
+
13
+ attr_accessor :text, :url, :html, :html_fragment, :lang
14
+
15
+ def analyze(options)
16
+
17
+ raise MissingParameters.new("Please provide one of the following parameters: text, url, html or html_fragment") if ([:text, :url, :html, :html_fragment] & options.keys).empty?
18
+
19
+ params = options
20
+ call(ENDPOINT, params)
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Dandelionapi
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dandelionapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Mostosi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-04 00:00:00.000000000 Z
11
+ date: 2015-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -148,6 +148,20 @@ dependencies:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0.8'
151
+ - !ruby/object:Gem::Dependency
152
+ name: yard
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '0.8'
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: '0.8'
151
165
  description: 'Ruby Gem for Dandelion API service. Available endpoint: Entity Extraction,
152
166
  Text Similarity and Language Detection'
153
167
  email:
@@ -171,6 +185,7 @@ files:
171
185
  - lib/dandelionapi/base.rb
172
186
  - lib/dandelionapi/entity_extraction.rb
173
187
  - lib/dandelionapi/language_detection.rb
188
+ - lib/dandelionapi/sentiment_analysis.rb
174
189
  - lib/dandelionapi/text_similarity.rb
175
190
  - lib/dandelionapi/version.rb
176
191
  - rubygem.png