opener-tree-tagger 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWI0Y2U0NjQzNjY4NTQ0ZGMxNGVhMDUwNTk2NjUwN2I4ZDRjNWY5Mw==
5
- data.tar.gz: !binary |-
6
- Y2UxNjJjNGRkYTk2NzgwYzdmYWU0NmIzMTI5MjEyYjA0YzY0N2MzOQ==
2
+ SHA1:
3
+ metadata.gz: d54024e12317abbe3e3e0f11aae1247dc716d22c
4
+ data.tar.gz: a09740aaf6aa89d485aa4cd3979c181bfbcde4f0
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NWY3ZjcxZWI5ZGNkNzY3ZWRhYzQxZTY0MWM0YzE1OTBkZWE3Njk0ZWY5ZmZi
10
- ZTdiMzkyZjFiMTgwNzZlYWEyNGE5ZWJiNjY5NTVlNmQ0Mjg2Mzg4ZDJkZTAz
11
- ZjE5MDkwNGY0NDRkYWU4ODBlYmIyYzQ3MDY3ODkxYjRkMmQyZjc=
12
- data.tar.gz: !binary |-
13
- NDUzNDRmOWRjMzYxYWQxYjc3ZTdiZTEyMGVlZGFmZDFlZGQwYjUxNDMxNjU5
14
- NDZiMDQ3ODA5YmRmN2Q2YjJhNmIyOGM5ODE3NWYwNjVkMGYyNGE4YjY3NTA5
15
- M2MyNzBhYmU1M2E1NTliNWQzNTRjOTk0MWVmZDBkNDE5ZGE3NzE=
6
+ metadata.gz: 98443d1157140fbd3e09f68b4b3c197a5b71c8f56cc44cfb12de78497a936c8adb46f3d0f96861eaf2418f11aa2cf3693a92c0f83d99c4c310f2757755cfb8d7
7
+ data.tar.gz: 303e26f30155295957db217e581a3902be96d35af9386c9993dbf3df4fe3160aff4c9db577316be4c3d841e6fe5c0bfe7b27ee4a503b3485c653cd276fda2842
data/README.md CHANGED
@@ -101,7 +101,7 @@ The component is a fat wrapper around the actual language technology core. You c
101
101
  Where to go from here
102
102
  ---------------------
103
103
 
104
- * [Check the project websitere](http://opener-project.github.io)
104
+ * [Check the project website](http://opener-project.github.io)
105
105
  * [Checkout the webservice](http://opener.olery.com/tree-tagger)
106
106
 
107
107
  Report problem/Get help
@@ -1,8 +1,10 @@
1
1
  require 'open3'
2
2
  require 'optparse'
3
+ require 'nokogiri'
3
4
 
4
5
  require_relative 'tree_tagger/version'
5
6
  require_relative 'tree_tagger/cli'
7
+ require_relative 'tree_tagger/error_layer'
6
8
 
7
9
  module Opener
8
10
  class TreeTagger
@@ -29,15 +31,13 @@ module Opener
29
31
  end
30
32
 
31
33
  def run(input)
32
- stdout, stderr, process = capture(input)
33
-
34
- if process.success?
35
- STDERR.puts(stderr) unless stderr.empty?
36
- else
37
- abort stderr
38
- end
39
-
40
- return stdout, stderr, process
34
+ begin
35
+ stdout, stderr, process = capture(input)
36
+ raise stderr unless process.success?
37
+ return stdout
38
+ rescue Exception => error
39
+ return ErrorLayer.new(input, error.message, self.class).add
40
+ end
41
41
  end
42
42
 
43
43
  def capture(input)
@@ -0,0 +1,88 @@
1
+ module Opener
2
+ class TreeTagger
3
+ ##
4
+ # Add Error Layer to KAF file instead of throwing an error.
5
+ #
6
+ class ErrorLayer
7
+ attr_accessor :input, :document, :error, :klass
8
+
9
+ def initialize(input, error, klass)
10
+ @input = input.to_s
11
+ # Make sure there is always a document, even if it is empty.
12
+ @document = Nokogiri::XML(input) rescue Nokogiri::XML(nil)
13
+ @error = error
14
+ @klass = klass
15
+ end
16
+
17
+ def add
18
+ if is_xml?
19
+ unless has_errors_layer?
20
+ add_errors_layer
21
+ end
22
+ else
23
+ add_root
24
+ add_text
25
+ add_errors_layer
26
+ end
27
+ add_error
28
+
29
+ xml = !!document.encoding ? document.to_xml : document.to_xml(:encoding => "UTF-8")
30
+
31
+ return xml
32
+ end
33
+
34
+ ##
35
+ # Check if the document is a valid XML file.
36
+ #
37
+ def is_xml?
38
+ !!document.root
39
+ end
40
+
41
+ ##
42
+ # Add root element to the XML file.
43
+ #
44
+ def add_root
45
+ root = Nokogiri::XML::Node.new "KAF", document
46
+ document.add_child(root)
47
+ end
48
+
49
+ ##
50
+ # Check if the document already has an errors layer.
51
+ #
52
+ def has_errors_layer?
53
+ !!document.at('errors')
54
+ end
55
+
56
+ ##
57
+ # Add errors element to the XML file.
58
+ #
59
+ def add_errors_layer
60
+ node = Nokogiri::XML::Node.new "errors", document
61
+ document.root.add_child(node)
62
+ end
63
+
64
+ ##
65
+ # Add the text file incase it is not a valid XML document. More
66
+ # info for debugging.
67
+ #
68
+ def add_text
69
+ node = Nokogiri::XML::Node.new "raw", document
70
+ node.inner_html = input
71
+ document.root.add_child(node)
72
+
73
+ end
74
+
75
+ ##
76
+ # Add the actual error to the errors layer.
77
+ #
78
+ def add_error
79
+ node = document.at('errors')
80
+ error_node = Nokogiri::XML::Node.new "error", node
81
+ error_node['class'] = "#{klass.to_s} #{klass::VERSION}"
82
+ error_node.inner_html = error
83
+ node.add_child(error_node)
84
+ end
85
+
86
+ end # ErrorLayer
87
+ end # TreeTagger
88
+ end # Opener
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class TreeTagger
3
- VERSION = "3.0.1"
3
+ VERSION = "3.0.2"
4
4
  end
5
5
  end
@@ -30,6 +30,7 @@ Gem::Specification.new do |gem|
30
30
  gem.add_dependency 'httpclient'
31
31
  gem.add_dependency 'puma'
32
32
  gem.add_dependency 'opener-webservice'
33
+ gem.add_dependency 'nokogiri'
33
34
 
34
35
  gem.add_development_dependency 'rspec'
35
36
  gem.add_development_dependency 'cucumber'
metadata CHANGED
@@ -1,143 +1,157 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-tree-tagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubenIzquierdo
8
8
  - sparkboxx
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-23 00:00:00.000000000 Z
12
+ date: 2014-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: opener-daemons
16
- requirement: !ruby/object:Gem::Requirement
16
+ version_requirements: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ! '>='
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
21
+ requirement: !ruby/object:Gem::Requirement
24
22
  requirements:
25
- - - ! '>='
23
+ - - '>='
26
24
  - !ruby/object:Gem::Version
27
25
  version: '0'
26
+ prerelease: false
27
+ type: :runtime
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: opener-build-tools
30
- requirement: !ruby/object:Gem::Requirement
30
+ version_requirements: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ! '>='
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: 0.2.7
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
38
36
  requirements:
39
- - - ! '>='
37
+ - - '>='
40
38
  - !ruby/object:Gem::Version
41
39
  version: 0.2.7
40
+ prerelease: false
41
+ type: :runtime
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
44
49
  requirement: !ruby/object:Gem::Requirement
45
50
  requirements:
46
- - - ! '>='
51
+ - - '>='
47
52
  - !ruby/object:Gem::Version
48
53
  version: '0'
49
- type: :runtime
50
54
  prerelease: false
55
+ type: :runtime
56
+ - !ruby/object:Gem::Dependency
57
+ name: sinatra
51
58
  version_requirements: !ruby/object:Gem::Requirement
52
59
  requirements:
53
- - - ! '>='
60
+ - - '>='
54
61
  - !ruby/object:Gem::Version
55
62
  version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: sinatra
58
63
  requirement: !ruby/object:Gem::Requirement
59
64
  requirements:
60
- - - ! '>='
65
+ - - '>='
61
66
  - !ruby/object:Gem::Version
62
67
  version: '0'
63
- type: :runtime
64
68
  prerelease: false
69
+ type: :runtime
70
+ - !ruby/object:Gem::Dependency
71
+ name: httpclient
65
72
  version_requirements: !ruby/object:Gem::Requirement
66
73
  requirements:
67
- - - ! '>='
74
+ - - '>='
68
75
  - !ruby/object:Gem::Version
69
76
  version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: httpclient
72
77
  requirement: !ruby/object:Gem::Requirement
73
78
  requirements:
74
- - - ! '>='
79
+ - - '>='
75
80
  - !ruby/object:Gem::Version
76
81
  version: '0'
77
- type: :runtime
78
82
  prerelease: false
83
+ type: :runtime
84
+ - !ruby/object:Gem::Dependency
85
+ name: puma
79
86
  version_requirements: !ruby/object:Gem::Requirement
80
87
  requirements:
81
- - - ! '>='
88
+ - - '>='
82
89
  - !ruby/object:Gem::Version
83
90
  version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: puma
86
91
  requirement: !ruby/object:Gem::Requirement
87
92
  requirements:
88
- - - ! '>='
93
+ - - '>='
89
94
  - !ruby/object:Gem::Version
90
95
  version: '0'
91
- type: :runtime
92
96
  prerelease: false
97
+ type: :runtime
98
+ - !ruby/object:Gem::Dependency
99
+ name: opener-webservice
93
100
  version_requirements: !ruby/object:Gem::Requirement
94
101
  requirements:
95
- - - ! '>='
102
+ - - '>='
96
103
  - !ruby/object:Gem::Version
97
104
  version: '0'
98
- - !ruby/object:Gem::Dependency
99
- name: opener-webservice
100
105
  requirement: !ruby/object:Gem::Requirement
101
106
  requirements:
102
- - - ! '>='
107
+ - - '>='
103
108
  - !ruby/object:Gem::Version
104
109
  version: '0'
105
- type: :runtime
106
110
  prerelease: false
111
+ type: :runtime
112
+ - !ruby/object:Gem::Dependency
113
+ name: nokogiri
107
114
  version_requirements: !ruby/object:Gem::Requirement
108
115
  requirements:
109
- - - ! '>='
116
+ - - '>='
110
117
  - !ruby/object:Gem::Version
111
118
  version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: rspec
114
119
  requirement: !ruby/object:Gem::Requirement
115
120
  requirements:
116
- - - ! '>='
121
+ - - '>='
117
122
  - !ruby/object:Gem::Version
118
123
  version: '0'
119
- type: :development
120
124
  prerelease: false
125
+ type: :runtime
126
+ - !ruby/object:Gem::Dependency
127
+ name: rspec
121
128
  version_requirements: !ruby/object:Gem::Requirement
122
129
  requirements:
123
- - - ! '>='
130
+ - - '>='
124
131
  - !ruby/object:Gem::Version
125
132
  version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: cucumber
128
133
  requirement: !ruby/object:Gem::Requirement
129
134
  requirements:
130
- - - ! '>='
135
+ - - '>='
131
136
  - !ruby/object:Gem::Version
132
137
  version: '0'
133
- type: :development
134
138
  prerelease: false
139
+ type: :development
140
+ - !ruby/object:Gem::Dependency
141
+ name: cucumber
135
142
  version_requirements: !ruby/object:Gem::Requirement
136
143
  requirements:
137
- - - ! '>='
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - '>='
138
150
  - !ruby/object:Gem::Version
139
151
  version: '0'
140
- description: ! 'Ruby wrapped KAF based Tree Tagger for 6 languages '
152
+ prerelease: false
153
+ type: :development
154
+ description: 'Ruby wrapped KAF based Tree Tagger for 6 languages '
141
155
  email:
142
156
  - ruben.izquierdobevia@vu.nl
143
157
  - wilco@olery.com
@@ -149,6 +163,11 @@ extensions:
149
163
  - ext/hack/Rakefile
150
164
  extra_rdoc_files: []
151
165
  files:
166
+ - README.md
167
+ - bin/tree-tagger
168
+ - bin/tree-tagger-daemon
169
+ - bin/tree-tagger-server
170
+ - config.ru
152
171
  - core/dutch.map.treetagger.kaf.csv
153
172
  - core/english.map.treetagger.kaf.csv
154
173
  - core/french.map.treetagger.kaf.csv
@@ -160,41 +179,37 @@ files:
160
179
  - exec/tree-tagger.rb
161
180
  - ext/hack/Rakefile
162
181
  - ext/hack/support.rb
182
+ - lib/opener/tree_tagger.rb
163
183
  - lib/opener/tree_tagger/cli.rb
184
+ - lib/opener/tree_tagger/error_layer.rb
164
185
  - lib/opener/tree_tagger/public/markdown.css
165
186
  - lib/opener/tree_tagger/server.rb
166
187
  - lib/opener/tree_tagger/version.rb
167
188
  - lib/opener/tree_tagger/views/index.erb
168
189
  - lib/opener/tree_tagger/views/result.erb
169
- - lib/opener/tree_tagger.rb
170
- - config.ru
171
190
  - opener-tree-tagger.gemspec
172
191
  - pre_install_requirements.txt
173
- - README.md
174
- - bin/tree-tagger
175
- - bin/tree-tagger-daemon
176
- - bin/tree-tagger-server
177
192
  homepage: http://opener-project.github.com/
178
193
  licenses: []
179
194
  metadata: {}
180
- post_install_message:
195
+ post_install_message:
181
196
  rdoc_options: []
182
197
  require_paths:
183
198
  - lib
184
199
  required_ruby_version: !ruby/object:Gem::Requirement
185
200
  requirements:
186
- - - ! '>='
201
+ - - '>='
187
202
  - !ruby/object:Gem::Version
188
203
  version: '0'
189
204
  required_rubygems_version: !ruby/object:Gem::Requirement
190
205
  requirements:
191
- - - ! '>='
206
+ - - '>='
192
207
  - !ruby/object:Gem::Version
193
208
  version: '0'
194
209
  requirements: []
195
- rubyforge_project:
196
- rubygems_version: 2.1.11
197
- signing_key:
210
+ rubyforge_project:
211
+ rubygems_version: 2.2.2
212
+ signing_key:
198
213
  specification_version: 4
199
214
  summary: Ruby wrapped KAF based Tree Tagger for 6 languages
200
215
  test_files: []