opener-coreference 1.0.3 → 1.0.4

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: d7d548066b2b01126731767de74d0d65b6d4e97e
4
- data.tar.gz: da1251f7753ba64023a08530e5eec5297885e248
3
+ metadata.gz: a4c0ed7263d9611c6b45b61763fb537123f6c013
4
+ data.tar.gz: 23d975c528e4b83344dd00b3340a0d87839a47ea
5
5
  SHA512:
6
- metadata.gz: ca8028edf7ed4ca51ff9c566cd6b4446b94d4f39aebf39d9ecc0fb841b8a03000eea9898d98c9380a90f293f027f7f48739f579e9e90cb5f2d8b7208f5025f69
7
- data.tar.gz: 4dbee8e088a0fe050813c3e0ad05dfe13dd39b73ac5259355bdcf39eb094ba21c28e92e635d15f18ee3e24d8a5a727497e1390bba2b54728576a8674de3e36f4
6
+ metadata.gz: 372ac8cd1630f9273577caf8a5731e64c9566ce246ef98ab49a16a22a18caeffd841d6dd7511f589525ad648497026b149cc928e6cf081cdfa16908a3cff15a8
7
+ data.tar.gz: ea6b8eee06116d21c78c052a5e6d84aba32dc7becfc56626bfb6b6e0dc07cd92644dc97ee682787be08334e0d7419cd6a67e8cc9a3bbd7a9da4224427fc60274
data/README.md CHANGED
@@ -11,11 +11,8 @@ The implementation is a result of a collaboration between the IXA NLP <http://ix
11
11
 
12
12
  ### Confused by some terminology?
13
13
 
14
- This software is part of a larger collection of natural language processing
15
- tools known as "the OpeNER project". You can find more information about the
16
- project at [the OpeNER portal](http://opener-project.github.io). There you can
17
- also find references to terms like KAF (an XML standard to represent linguistic
18
- annotations in texts), component, cores, scenario's and pipelines.
14
+ This software is part of a larger collection of natural language processing tools known as "the OpeNER project". You can find more information about the project at [the OpeNER portal](http://opener-project.github.io). There you can also find references to terms like KAF (an XML standard to represent linguistic annotations in texts), component, cores, scenario's and pipelines.
15
+
19
16
 
20
17
  Quick Use Example
21
18
  -----------------
@@ -24,13 +21,11 @@ Installing the coreference can be done by executing:
24
21
 
25
22
  gem install opener-coreference
26
23
 
27
- Please bare in mind that all components in OpeNER take KAF as an input and
28
- output KAF by default.
24
+ Please bare in mind that all components in OpeNER take KAF as an input and output KAF by default.
29
25
 
30
26
  ### Command line interface
31
27
 
32
- You should now be able to call the coreference as a regular shell
33
- command: by its name. Once installed the gem normalyl sits in your path so you can call it directly from anywhere.
28
+ You should now be able to call the coreference as a regular shell command: by its name. Once installed the gem normalyl sits in your path so you can call it directly from anywhere.
34
29
 
35
30
  This aplication reads a text from standard input in order to identify the language.
36
31
 
@@ -62,26 +57,20 @@ You can launch a language identification webservice by executing:
62
57
 
63
58
  coreference-server
64
59
 
65
- This will launch a mini webserver with the webservice. It defaults to port 9292,
66
- so you can access it at <http://localhost:9292>.
60
+ This will launch a mini webserver with the webservice. It defaults to port 9292, so you can access it at <http://localhost:9292>.
67
61
 
68
- To launch it on a different port provide the `-p [port-number]` option like
69
- this:
62
+ To launch it on a different port provide the `-p [port-number]` option like this:
70
63
 
71
64
  coreference-server -p 1234
72
65
 
73
66
  It then launches at <http://localhost:1234>
74
67
 
75
- Documentation on the Webservice is provided by surfing to the urls provided
76
- above. For more information on how to launch a webservice run the command with
77
- the ```-h``` option.
68
+ Documentation on the Webservice is provided by surfing to the urls provided above. For more information on how to launch a webservice run the command with the ```-h``` option.
78
69
 
79
70
 
80
71
  ### Daemon
81
72
 
82
- Last but not least the coreference comes shipped with a daemon that
83
- can read jobs (and write) jobs to and from Amazon SQS queues. For more
84
- information type:
73
+ Last but not least the coreference comes shipped with a daemon that can read jobs (and write) jobs to and from Amazon SQS queues. For more information type:
85
74
 
86
75
  coreference-daemon -h
87
76
 
@@ -89,8 +78,7 @@ information type:
89
78
  Description of dependencies
90
79
  ---------------------------
91
80
 
92
- This component runs best if you run it in an environment suited for OpeNER
93
- components. You can find an installation guide and helper tools in the [OpeNER installer](https://github.com/opener-project/opener-installer) and an
81
+ This component runs best if you run it in an environment suited for OpeNER components. You can find an installation guide and helper tools in the [OpeNER installer](https://github.com/opener-project/opener-installer) and an
94
82
  [installation guide on the Opener Website](http://opener-project.github.io/getting-started/how-to/local-installation.html)
95
83
 
96
84
  At least you need the following system setup:
@@ -103,12 +91,7 @@ At least you need the following system setup:
103
91
  Adapting CorefGraph-en to your language
104
92
  ---------------------------------------
105
93
 
106
- There are a number of changes needed to be made to make CorefGraph works for
107
- other languages. Although we have try to keep the language dependent features
108
- to a minimum, you will still need to create some dictionaries for your own
109
- language and make some very minor changes in the code. Here is the list of very
110
- file in the Corefgraph module that needs to be changed. Every change except
111
- one (see below) to be done in the **$project/core/corefgraph/resources** directory:
94
+ There are a number of changes needed to be made to make CorefGraph works for other languages. Although we have try to keep the language dependent features to a minimum, you will still need to create some dictionaries for your own language and make some very minor changes in the code. Here is the list of very file in the Corefgraph module that needs to be changed. Every change except one (see below) to be done in the **$project/core/corefgraph/resources** directory:
112
95
 
113
96
  * dictionaries/$lang\_determiners.py
114
97
  * dictionaries/$lang\_pronouns.py
@@ -137,22 +120,21 @@ one (see below) to be done in the **$project/core/corefgraph/resources** directo
137
120
  The Core
138
121
  --------
139
122
 
140
- The component is a fat wrapper around the actual language technology core. You
141
- can find the core technolies in the following repositories:
123
+ The component is a fat wrapper around the actual language technology core. You can find the core technolies in the following repositories:
142
124
 
143
125
  * [Coreference-base](https://github.com/opener-project/coreference-base)
144
126
 
145
127
  Where to go from here
146
128
  ---------------------
147
129
 
148
- * [Check the project websitere](http://opener-project.github.io)
130
+ * [Check the project website](http://opener-project.github.io)
149
131
  * [Checkout the webservice](http://opener.olery.com/coreference)
150
132
 
151
133
  Report problem/Get help
152
134
  -----------------------
153
135
 
154
- If you encounter problems, please email <support@opener-project.eu> or leave an
155
- issue in the [issue tracker](https://github.com/opener-project/coreference/issues).
136
+ If you encounter problems, please email <support@opener-project.eu> or leave an issue in the
137
+ [issue tracker](https://github.com/opener-project/coreference/issues).
156
138
 
157
139
 
158
140
  Contributing
@@ -4,6 +4,7 @@ require 'nokogiri'
4
4
 
5
5
  require_relative 'coreference/version'
6
6
  require_relative 'coreference/cli'
7
+ require_relative 'coreference/error_layer'
7
8
 
8
9
  module Opener
9
10
  class Coreference
@@ -37,16 +38,22 @@ module Opener
37
38
  # @return [Array]
38
39
  #
39
40
  def run(input)
40
- language = language_from_kaf(input)
41
- args = options[:args].dup
41
+ begin
42
+ language = language_from_kaf(input)
43
+ args = options[:args].dup
42
44
 
43
- if language_constant_defined?(language)
44
- kernel = language.new(:args => args)
45
- else
46
- kernel = Coreferences::Base.new(:args => args, :language => language)
45
+ if language_constant_defined?(language)
46
+ kernel = language.new(:args => args)
47
+ else
48
+ kernel = Coreferences::Base.new(:args => args, :language => language)
49
+ end
50
+ stdout, stderr, process = kernel.run(input)
51
+ raise stderr unless process.success?
52
+ return stdout
53
+
54
+ rescue Exception => error
55
+ return ErrorLayer.new(input, error.message, self.class).add
47
56
  end
48
-
49
- return kernel.run(input)
50
57
  end
51
58
 
52
59
  protected
@@ -57,13 +57,7 @@ Supported Languages (taken from kaf lang element):
57
57
 
58
58
  stdout, stderr, process = tokenizer.run(input)
59
59
 
60
- if process.success?
61
- puts stdout
62
-
63
- STDERR.puts(stderr) unless stderr.empty?
64
- else
65
- abort stderr
66
- end
60
+ puts stdout
67
61
  end
68
62
 
69
63
  private
@@ -0,0 +1,88 @@
1
+ module Opener
2
+ class Coreference
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 # Coreference
88
+ end # Opener
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class Coreference
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,147 +1,147 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-coreference
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - development@olery.com
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-23 00:00:00.000000000 Z
11
+ date: 2014-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
15
- requirement: !ruby/object:Gem::Requirement
15
+ version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
20
+ requirement: !ruby/object:Gem::Requirement
23
21
  requirements:
24
- - - "~>"
22
+ - - ~>
25
23
  - !ruby/object:Gem::Version
26
24
  version: '1.4'
25
+ prerelease: false
26
+ type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: httpclient
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
29
34
  requirement: !ruby/object:Gem::Requirement
30
35
  requirements:
31
- - - ">="
36
+ - - '>='
32
37
  - !ruby/object:Gem::Version
33
38
  version: '0'
34
- type: :runtime
35
39
  prerelease: false
40
+ type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
36
43
  version_requirements: !ruby/object:Gem::Requirement
37
44
  requirements:
38
- - - ">="
45
+ - - '>='
39
46
  - !ruby/object:Gem::Version
40
47
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: nokogiri
43
48
  requirement: !ruby/object:Gem::Requirement
44
49
  requirements:
45
- - - ">="
50
+ - - '>='
46
51
  - !ruby/object:Gem::Version
47
52
  version: '0'
48
- type: :runtime
49
53
  prerelease: false
54
+ type: :runtime
55
+ - !ruby/object:Gem::Dependency
56
+ name: opener-coreference-base
50
57
  version_requirements: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ">="
59
+ - - '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: opener-coreference-base
57
62
  requirement: !ruby/object:Gem::Requirement
58
63
  requirements:
59
- - - ">="
64
+ - - '>='
60
65
  - !ruby/object:Gem::Version
61
66
  version: '0'
62
- type: :runtime
63
67
  prerelease: false
68
+ type: :runtime
69
+ - !ruby/object:Gem::Dependency
70
+ name: opener-webservice
64
71
  version_requirements: !ruby/object:Gem::Requirement
65
72
  requirements:
66
- - - ">="
73
+ - - '>='
67
74
  - !ruby/object:Gem::Version
68
75
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: opener-webservice
71
76
  requirement: !ruby/object:Gem::Requirement
72
77
  requirements:
73
- - - ">="
78
+ - - '>='
74
79
  - !ruby/object:Gem::Version
75
80
  version: '0'
76
- type: :runtime
77
81
  prerelease: false
82
+ type: :runtime
83
+ - !ruby/object:Gem::Dependency
84
+ name: puma
78
85
  version_requirements: !ruby/object:Gem::Requirement
79
86
  requirements:
80
- - - ">="
87
+ - - '>='
81
88
  - !ruby/object:Gem::Version
82
89
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: puma
85
90
  requirement: !ruby/object:Gem::Requirement
86
91
  requirements:
87
- - - ">="
92
+ - - '>='
88
93
  - !ruby/object:Gem::Version
89
94
  version: '0'
90
- type: :runtime
91
95
  prerelease: false
96
+ type: :runtime
97
+ - !ruby/object:Gem::Dependency
98
+ name: opener-daemons
92
99
  version_requirements: !ruby/object:Gem::Requirement
93
100
  requirements:
94
- - - ">="
101
+ - - '>='
95
102
  - !ruby/object:Gem::Version
96
103
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: opener-daemons
99
104
  requirement: !ruby/object:Gem::Requirement
100
105
  requirements:
101
- - - ">="
106
+ - - '>='
102
107
  - !ruby/object:Gem::Version
103
108
  version: '0'
104
- type: :runtime
105
109
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
110
+ type: :runtime
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: opener-core
113
- requirement: !ruby/object:Gem::Requirement
113
+ version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.1.2
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
118
+ requirement: !ruby/object:Gem::Requirement
121
119
  requirements:
122
- - - ">="
120
+ - - '>='
123
121
  - !ruby/object:Gem::Version
124
122
  version: 0.1.2
123
+ prerelease: false
124
+ type: :runtime
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rake
127
- requirement: !ruby/object:Gem::Requirement
127
+ version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
132
+ requirement: !ruby/object:Gem::Requirement
135
133
  requirements:
136
- - - ">="
134
+ - - '>='
137
135
  - !ruby/object:Gem::Version
138
136
  version: '0'
137
+ prerelease: false
138
+ type: :development
139
139
  description: Gem that wraps the coreference code
140
- email:
140
+ email:
141
141
  executables:
142
142
  - coreference
143
- - coreference-server
144
143
  - coreference-daemon
144
+ - coreference-server
145
145
  extensions: []
146
146
  extra_rdoc_files: []
147
147
  files:
@@ -153,33 +153,33 @@ files:
153
153
  - exec/coreference.rb
154
154
  - lib/opener/coreference.rb
155
155
  - lib/opener/coreference/cli.rb
156
+ - lib/opener/coreference/error_layer.rb
156
157
  - lib/opener/coreference/public/markdown.css
157
158
  - lib/opener/coreference/server.rb
158
159
  - lib/opener/coreference/version.rb
159
160
  - lib/opener/coreference/views/index.erb
160
161
  - opener-coreference.gemspec
161
- homepage:
162
+ homepage:
162
163
  licenses: []
163
164
  metadata: {}
164
- post_install_message:
165
+ post_install_message:
165
166
  rdoc_options: []
166
167
  require_paths:
167
168
  - lib
168
169
  required_ruby_version: !ruby/object:Gem::Requirement
169
170
  requirements:
170
- - - ">="
171
+ - - '>='
171
172
  - !ruby/object:Gem::Version
172
173
  version: 1.9.2
173
174
  required_rubygems_version: !ruby/object:Gem::Requirement
174
175
  requirements:
175
- - - ">="
176
+ - - '>='
176
177
  - !ruby/object:Gem::Version
177
178
  version: '0'
178
179
  requirements: []
179
- rubyforge_project:
180
+ rubyforge_project:
180
181
  rubygems_version: 2.2.2
181
- signing_key:
182
+ signing_key:
182
183
  specification_version: 4
183
184
  summary: Gem that wraps the coreference code
184
185
  test_files: []
185
- has_rdoc: yard