calais 0.0.8 → 0.0.9
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.
- data/CHANGELOG.markdown +9 -0
- data/Gemfile +11 -0
- data/VERSION.yml +3 -2
- data/lib/calais.rb +7 -5
- data/lib/calais/client.rb +7 -5
- data/spec/calais/client_spec.rb +1 -1
- metadata +38 -18
data/CHANGELOG.markdown
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 0.0.9
|
4
|
+
|
5
|
+
* updates related to API changes
|
6
|
+
* community patches to support bundler, support ruby 1.9
|
7
|
+
|
8
|
+
## 0.0.8
|
9
|
+
|
10
|
+
* community patches to use nokogiri
|
11
|
+
|
3
12
|
## 0.0.7
|
4
13
|
* verified 4.0 API
|
5
14
|
* moved gem packaging to `jeweler` and documentation to `yard`
|
data/Gemfile
ADDED
data/VERSION.yml
CHANGED
data/lib/calais.rb
CHANGED
@@ -9,8 +9,10 @@ require 'nokogiri'
|
|
9
9
|
require 'json'
|
10
10
|
require 'curb'
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
if RUBY_VERSION.to_f < 1.9
|
13
|
+
$KCODE = "UTF8"
|
14
|
+
require 'jcode'
|
15
|
+
end
|
14
16
|
|
15
17
|
$:.unshift File.expand_path(File.dirname(__FILE__)) + '/calais'
|
16
18
|
|
@@ -24,8 +26,8 @@ module Calais
|
|
24
26
|
|
25
27
|
AVAILABLE_CONTENT_TYPES = {
|
26
28
|
:xml => 'text/xml',
|
27
|
-
:text => 'text/txt',
|
28
29
|
:html => 'text/html',
|
30
|
+
:htmlraw => 'text/htmlraw',
|
29
31
|
:raw => 'text/raw'
|
30
32
|
}
|
31
33
|
|
@@ -36,8 +38,8 @@ module Calais
|
|
36
38
|
:json => 'application/json'
|
37
39
|
}
|
38
40
|
|
39
|
-
KNOWN_ENABLES = ['GenericRelations']
|
40
|
-
KNOWN_DISCARDS = ['er/Company', 'er/Geo']
|
41
|
+
KNOWN_ENABLES = ['GenericRelations', 'SocialTags']
|
42
|
+
KNOWN_DISCARDS = ['er/Company', 'er/Geo', 'er/Product']
|
41
43
|
|
42
44
|
MAX_RETRIES = 5
|
43
45
|
HTTP_TIMEOUT = 60
|
data/lib/calais/client.rb
CHANGED
@@ -6,7 +6,7 @@ module Calais
|
|
6
6
|
|
7
7
|
# processing directives
|
8
8
|
attr_accessor :content_type, :output_format, :reltag_base_url, :calculate_relevance, :omit_outputting_original_text
|
9
|
-
attr_accessor :metadata_enables, :metadata_discards
|
9
|
+
attr_accessor :store_rdf, :metadata_enables, :metadata_discards
|
10
10
|
|
11
11
|
# user directives
|
12
12
|
attr_accessor :allow_distribution, :allow_search, :external_id, :submitter
|
@@ -47,9 +47,11 @@ module Calais
|
|
47
47
|
processing_node = Nokogiri::XML::Node.new('c:processingDirectives', document)
|
48
48
|
processing_node['c:contentType'] = AVAILABLE_CONTENT_TYPES[@content_type] if @content_type
|
49
49
|
processing_node['c:outputFormat'] = AVAILABLE_OUTPUT_FORMATS[@output_format] if @output_format
|
50
|
+
processing_node['c:calculateRelevanceScore'] = 'false' if @calculate_relevance == false
|
50
51
|
processing_node['c:reltagBaseURL'] = @reltag_base_url.to_s if @reltag_base_url
|
51
52
|
|
52
|
-
processing_node['c:enableMetadataType'] = @metadata_enables.join('
|
53
|
+
processing_node['c:enableMetadataType'] = @metadata_enables.join(',') unless @metadata_enables.empty?
|
54
|
+
processing_node['c:docRDFaccessible'] = @store_rdf if @store_rdf
|
53
55
|
processing_node['c:discardMetadata'] = @metadata_discards.join(';') unless @metadata_discards.empty?
|
54
56
|
processing_node['c:omitOutputtingOriginalText'] = 'true' if @omit_outputting_original_text
|
55
57
|
|
@@ -84,7 +86,7 @@ module Calais
|
|
84
86
|
raise 'unknown content type' unless AVAILABLE_CONTENT_TYPES.keys.include?(@content_type) if @content_type
|
85
87
|
raise 'unknown output format' unless AVAILABLE_OUTPUT_FORMATS.keys.include?(@output_format) if @output_format
|
86
88
|
|
87
|
-
%w[calculate_relevance allow_distribution allow_search].each do |variable|
|
89
|
+
%w[calculate_relevance store_rdf allow_distribution allow_search].each do |variable|
|
88
90
|
value = self.send(variable)
|
89
91
|
unless NilClass === value || TrueClass === value || FalseClass === value
|
90
92
|
raise "expected a boolean value for #{variable} but got #{value}"
|
@@ -93,11 +95,11 @@ module Calais
|
|
93
95
|
|
94
96
|
@metadata_enables ||= []
|
95
97
|
unknown_enables = Set.new(@metadata_enables) - KNOWN_ENABLES
|
96
|
-
raise "unknown metadata enables: #{unknown_enables.
|
98
|
+
raise "unknown metadata enables: #{unknown_enables.to_a.inspect}" unless unknown_enables.empty?
|
97
99
|
|
98
100
|
@metadata_discards ||= []
|
99
101
|
unknown_discards = Set.new(@metadata_discards) - KNOWN_DISCARDS
|
100
|
-
raise "unknown metadata discards: #{unknown_discards.
|
102
|
+
raise "unknown metadata discards: #{unknown_discards.to_a.inspect}" unless unknown_discards.empty?
|
101
103
|
end
|
102
104
|
|
103
105
|
def do_request(post_fields)
|
data/spec/calais/client_spec.rb
CHANGED
@@ -45,7 +45,7 @@ describe Calais::Client, :params_xml do
|
|
45
45
|
client.external_id = Digest::SHA1.hexdigest(client.content)
|
46
46
|
client.submitter = 'calais.rb'
|
47
47
|
|
48
|
-
client.params_xml.should == %[<c:params xmlns:c="http://s.opencalais.com/1/pred/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\n <c:processingDirectives c:contentType="text/xml" c:outputFormat="application/json" c:reltagBaseURL="http://opencalais.com" c:enableMetadataType="GenericRelations" c:discardMetadata="er/Company;er/Geo"/>\n <c:userDirectives c:allowDistribution="true" c:allowSearch="true" c:externalID="1a008b91e7d21962e132bc1d6cb252532116a606" c:submitter="calais.rb"/>\n</c:params>]
|
48
|
+
client.params_xml.should == %[<c:params xmlns:c="http://s.opencalais.com/1/pred/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\n <c:processingDirectives c:contentType="text/xml" c:outputFormat="application/json" c:reltagBaseURL="http://opencalais.com" c:enableMetadataType="GenericRelations,SocialTags" c:discardMetadata="er/Company;er/Geo;er/Product"/>\n <c:userDirectives c:allowDistribution="true" c:allowSearch="true" c:externalID="1a008b91e7d21962e132bc1d6cb252532116a606" c:submitter="calais.rb"/>\n</c:params>]
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calais
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Abhay Kumar
|
@@ -9,39 +14,51 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-04-14 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: nokogiri
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 3
|
30
|
+
- 3
|
23
31
|
version: 1.3.3
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: json
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 1
|
44
|
+
- 3
|
33
45
|
version: 1.1.3
|
34
|
-
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
35
48
|
- !ruby/object:Gem::Dependency
|
36
49
|
name: curb
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
52
|
requirements:
|
41
53
|
- - ">="
|
42
54
|
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
- 1
|
58
|
+
- 4
|
43
59
|
version: 0.1.4
|
44
|
-
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
45
62
|
description: A Ruby interface to the Calais Web Service
|
46
63
|
email: info@opensynapse.net
|
47
64
|
executables: []
|
@@ -52,6 +69,7 @@ extra_rdoc_files:
|
|
52
69
|
- README.markdown
|
53
70
|
files:
|
54
71
|
- CHANGELOG.markdown
|
72
|
+
- Gemfile
|
55
73
|
- MIT-LICENSE
|
56
74
|
- README.markdown
|
57
75
|
- Rakefile
|
@@ -73,20 +91,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
91
|
requirements:
|
74
92
|
- - ">="
|
75
93
|
- !ruby/object:Gem::Version
|
94
|
+
segments:
|
95
|
+
- 0
|
76
96
|
version: "0"
|
77
|
-
version:
|
78
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
98
|
requirements:
|
80
99
|
- - ">="
|
81
100
|
- !ruby/object:Gem::Version
|
101
|
+
segments:
|
102
|
+
- 0
|
82
103
|
version: "0"
|
83
|
-
version:
|
84
104
|
requirements: []
|
85
105
|
|
86
106
|
rubyforge_project: calais
|
87
|
-
rubygems_version: 1.3.
|
107
|
+
rubygems_version: 1.3.6
|
88
108
|
signing_key:
|
89
|
-
specification_version:
|
109
|
+
specification_version: 3
|
90
110
|
summary: A Ruby interface to the Calais Web Service
|
91
111
|
test_files:
|
92
112
|
- spec/calais/client_spec.rb
|