lymbix 0.4.1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +2 -0
- data/LICENSE +3 -1
- data/README +14 -4
- data/lib/lymbix/base.rb +38 -19
- data/lib/lymbix/request.rb +2 -1
- metadata +5 -4
data/Changelog
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
v0.4.3 - can now specify which api_version to use
|
2
|
+
v0.4.2 - added reference_id to all methods using version 2.2 BETA
|
1
3
|
v0.4.1 - added reference_id param to flag_response
|
2
4
|
v0.4.0 - re-factored whole gem, implemented methods for 2.1 version
|
3
5
|
v0.3.7 - added endpoint attribute to Base for companies implementation
|
data/LICENSE
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
Copyright (c) 2010, Lymbix Inc.
|
2
|
+
|
3
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
data/README
CHANGED
@@ -1,14 +1,24 @@
|
|
1
1
|
= Lymbix
|
2
2
|
|
3
|
-
Lymbix
|
3
|
+
Lymbix is an easy to use wrapper for the Lymbix Tone API service to tonalize a phrase or passage.
|
4
4
|
|
5
|
-
|
5
|
+
To install the Lymbix gem see command below:
|
6
|
+
|
7
|
+
gem install lymbix
|
6
8
|
|
7
|
-
|
9
|
+
It is possible to tonalize a phrase like:
|
8
10
|
|
11
|
+
lymbix = Lymbix::Base.new(authentication_key)
|
12
|
+
lymbix.api_version = 2.1 (available in gem version 0.4.3)
|
13
|
+
lymbix.tonalize("I like ruby.")
|
14
|
+
|
15
|
+
|
16
|
+
To be able to access this resource - please go to <a href="http://www.toneapi.com">ToneAPI.com</a> and create an account. You need to agree to the licensing terms, and your account needs to be approved. Once approved, you will be able to get your authentication key.
|
17
|
+
|
18
|
+
Note: The Lymbix gem requires the rest-client gem version >= 1.4.2
|
9
19
|
|
10
20
|
== Authors and credits
|
11
21
|
|
12
|
-
Authors:: Pat Roy, Josh Merchant
|
22
|
+
Authors:: Pat Roy, Josh Merchant, Matthew Lagacé, Mathieu Dargavel, Maxime Santerre
|
13
23
|
Copyright:: Lymbix Inc
|
14
24
|
License:: Subject to licensing terms - see http://www.toneapi.com
|
data/lib/lymbix/base.rb
CHANGED
@@ -9,50 +9,69 @@ To begin using the base class, you must get your authentication key provided fro
|
|
9
9
|
|
10
10
|
class Base
|
11
11
|
# The user's authentication key
|
12
|
-
attr_accessor :auth_key
|
12
|
+
attr_accessor :auth_key, :api_version
|
13
13
|
|
14
14
|
def initialize(auth_key)
|
15
15
|
@auth_key = auth_key
|
16
|
+
@api_version = 2.1
|
16
17
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
|
19
|
+
def terms_lookup(article)
|
20
|
+
response = request(:post, 'terms_lookup',{:article => article}, {:accept => "application/json"}).data
|
21
|
+
end
|
22
|
+
|
23
|
+
# Tonalizes text using version 2.1,2.2 of ToneAPI
|
24
|
+
def tonalize(article, return_fields = nil, accept_type = nil, article_reference_id = nil)
|
25
|
+
return_fields = [] if return_fields == nil
|
26
|
+
accept_type = "application/json" if accept_type == nil
|
27
|
+
article_reference_id = "" if article_reference_id == nil
|
28
|
+
response = request(:post, 'tonalize',{:article => article, :return_fields => return_fields.to_json, :reference_id => article_reference_id.to_s}, {:accept => accept_type}).data
|
23
29
|
end
|
24
30
|
|
25
31
|
# Tonalizes text using version 2.0 of ToneAPI
|
26
32
|
def tonalize_article(article, accept_type = "application/json")
|
27
|
-
@
|
33
|
+
@api_version = 2.0
|
28
34
|
response = request(:post, 'tonalize_article',{:article => article}, {:accept => accept_type}).data
|
29
35
|
end
|
30
36
|
|
31
37
|
# Tonalizes mutliple articles using version 2.1 of ToneAPI. With the return_fields param you can now specify which field to get back from the API.
|
32
|
-
def tonalize_multiple(articles, return_fields =
|
33
|
-
|
34
|
-
accept_type
|
35
|
-
|
36
|
-
|
38
|
+
def tonalize_multiple(articles, return_fields = nil, accept_type = nil, article_reference_ids = nil)
|
39
|
+
return_fields = [] if return_fields == nil
|
40
|
+
accept_type = "application/json" if accept_type == nil
|
41
|
+
article_reference_ids = [] if article_reference_ids == nil
|
42
|
+
article_reference_ids.each_with_index {|article,index| article_reference_ids[index] = article.to_s} if article_reference_ids.size > 0
|
43
|
+
response = request(:post, 'tonalize_multiple',{:articles => articles.to_json, :return_fields => return_fields.to_json, :article_reference_ids => article_reference_ids.to_json}, {:accept => accept_type}).data
|
37
44
|
end
|
38
45
|
|
39
46
|
# Tonalizes article using version 2.1 of ToneAPI. With the return_fields param you can now specify which field to get back from the API.
|
40
47
|
# The detailed response includes the tonalization data for the article and all sentences found in the article
|
41
|
-
def tonalize_detailed(article, return_fields =
|
42
|
-
|
43
|
-
accept_type
|
44
|
-
|
48
|
+
def tonalize_detailed(article, return_fields = nil, accept_type = nil, article_reference_id = nil)
|
49
|
+
return_fields = [] if return_fields == nil
|
50
|
+
accept_type = "application/json" if accept_type == nil
|
51
|
+
article_reference_id = "" if article_reference_id == nil
|
52
|
+
response = request(:post, 'tonalize_detailed',{:article => article, :return_fields => return_fields.to_json, :article_reference_id => article_reference_id}, {:accept => accept_type}).data
|
45
53
|
end
|
46
54
|
|
47
55
|
# Flags a phrase to be re-evaluated
|
48
56
|
def flag_response(reference_id, phrase, api_method_requested, api_version, callback_url = nil)
|
49
|
-
@version = 2.1
|
50
57
|
response = request(:post, 'flag_response', {:reference_id => reference_id, :phrase => phrase, :api_method_requested => api_method_requested, :api_version => api_version, :callback_url => callback_url}).data
|
51
58
|
end
|
52
59
|
|
53
60
|
private
|
54
61
|
def request(action, method, data, headers = {})
|
55
|
-
Lymbix::Request.new(action, method, {:app_id => @app_id, :auth_key => @auth_key, :version => @
|
62
|
+
Lymbix::Request.new(action, method, {:app_id => @app_id, :auth_key => @auth_key, :version => @api_version, :accept_type => headers[:accept]}, data).run
|
63
|
+
end
|
64
|
+
|
65
|
+
def article_reference_ids_xml(article_reference_ids)
|
66
|
+
xml = "<?xml version='1.0' encoding='utf-8' ?>"
|
67
|
+
xml << "<article_reference_ids>"
|
68
|
+
article_reference_ids.each {|field| xml << "<article_reference_id>" + field + "</article_reference_id>"}
|
69
|
+
xml << "</article_reference_ids>"
|
70
|
+
xml
|
71
|
+
end
|
72
|
+
|
73
|
+
def article_reference_ids_json(article_reference_ids)
|
74
|
+
article_reference_ids.to_json
|
56
75
|
end
|
57
76
|
|
58
77
|
def return_fields_xml(return_fields)
|
data/lib/lymbix/request.rb
CHANGED
@@ -15,7 +15,8 @@ module Lymbix
|
|
15
15
|
|
16
16
|
def connection
|
17
17
|
options = {}
|
18
|
-
options[:
|
18
|
+
options[:timeout] = 0
|
19
|
+
options[:headers] = {:USER_AGENT => "Lymbix Gem - 0.4.2", :accept => self.header_hash[:accept_type], :AUTHENTICATION => self.header_hash[:auth_key], :VERSION => self.header_hash[:version]}
|
19
20
|
RestClient::Resource.new(self.url, options)
|
20
21
|
end
|
21
22
|
|
metadata
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lymbix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Patrick Roy
|
14
14
|
- Josh Merchant
|
15
15
|
- Mathieu Dargavel
|
16
16
|
- "Matthew Lagac\xC3\xA9"
|
17
|
+
- Maxime Santerre
|
17
18
|
autorequire:
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
21
|
|
21
|
-
date: 2010-
|
22
|
+
date: 2010-02-16 00:00:00 -04:00
|
22
23
|
default_executable:
|
23
24
|
dependencies: []
|
24
25
|
|