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 +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +0 -3
- data/README.md +24 -3
- data/dandelionapi.gemspec +1 -0
- data/lib/dandelionapi.rb +21 -0
- data/lib/dandelionapi/sentiment_analysis.rb +25 -0
- data/lib/dandelionapi/version.rb +1 -1
- data/rubygem.png +0 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e24257bbcc32e368db80064ce40f9ddd15c2c6a8
|
4
|
+
data.tar.gz: bc758810bdfb49dbb0767b5f2018e13730ca234d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0408cdf917450acb12259956dd8852654cd154cd0f0fd5b7d482a7773c305985fd3300677a62461903d7d52eee1357215c5efd6372c641f10298dee607a74ea
|
7
|
+
data.tar.gz: b9696acda5c66d2c2c5cd17817010b52d88adc09f3bb23340a157b70c5db8312e291c07096145a0ecb76e8b1adb1d66847ab8548db614928a85fc67352c1075d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
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.
|
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/)**:
|
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)
|
data/dandelionapi.gemspec
CHANGED
data/lib/dandelionapi.rb
CHANGED
@@ -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
|
data/lib/dandelionapi/version.rb
CHANGED
data/rubygem.png
CHANGED
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.
|
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-
|
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
|