opener-pos-tagger 2.1.0 → 2.1.1

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: 07f3de5037f2f39ec57ee5876be849250cfccbc4
4
- data.tar.gz: 142309416cc14524f49cef9a9049697891475211
3
+ metadata.gz: 80ec8069d4c1890a8d2b7ecdaa701c19d0734870
4
+ data.tar.gz: 532bf8459370aeb8d8156caa4f3a07231a6efb7e
5
5
  SHA512:
6
- metadata.gz: 42ef72b680c15793b8fe89664399821662a05cc456b758230567f947dfbba4f16b3a36045b01d1f24be40afdc1c5a4464d8d1d390314a36f7566fe3588c84b6c
7
- data.tar.gz: 4dc50eec3b12499aa368dcf59b8cebd746f14f5fab0fcbed8a4aa5d5102917bbce853a3a137e2f400f0761c82c75dd7b1befa33280bdcf1bd7828fab9932ba2c
6
+ metadata.gz: e607af97829002ff07f436e300f7aa5facc1ce0675fbe31736ce3d5a322cf5479f96cbf8615be4acd003289558056489d3652e362b0802e6c69af47f8bb717c5
7
+ data.tar.gz: cf05156f800dd0a7c10dcf4e03e88b8adf2776d24e15e065b6b5ceab6b1fd4e8217b443a917d91bab6bed15bafabaabb483265fad59417705b2b7e41a9769a8b
data/README.md CHANGED
@@ -5,11 +5,7 @@ Component that wraps the different existing POS Taggers.
5
5
 
6
6
  ### Confused by some terminology?
7
7
 
8
- This software is part of a larger collection of natural language processing
9
- tools known as "the OpeNER project". You can find more information about the
10
- project at [the OpeNER portal](http://opener-project.github.io). There you can
11
- also find references to terms like KAF (an XML standard to represent linguistic
12
- annotations in texts), component, cores, scenario's and pipelines.
8
+ 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.
13
9
 
14
10
  Quick Use Example
15
11
  -----------------
@@ -18,13 +14,11 @@ Installing the pos-tagger can be done by executing:
18
14
 
19
15
  gem install opener-pos-tagger
20
16
 
21
- Please bare in mind that all components in OpeNER take KAF as an input and
22
- output KAF by default.
17
+ Please bare in mind that all components in OpeNER take KAF as an input and output KAF by default.
23
18
 
24
19
  ### Command line interface
25
20
 
26
- You should now be able to call the POS tagger as a regular shell
27
- command: by its name. Once installed the gem normalyl sits in your path so you can call it directly from anywhere.
21
+ You should now be able to call the POS tagger 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.
28
22
 
29
23
  This aplication reads a text from standard input in order to identify the language.
30
24
 
@@ -74,8 +68,7 @@ Will result in
74
68
  </span>
75
69
  </term>
76
70
  <term lemma="text" morphofeat="FM" pos="O" tid="t_5" type="open">
77
- <span>
78
- <target id="w5"/>
71
+ <span> <target id="w5"/>
79
72
  </span>
80
73
  </term>
81
74
  </terms>
@@ -87,34 +80,27 @@ You can launch a language identification webservice by executing:
87
80
 
88
81
  pos-tagger-server
89
82
 
90
- This will launch a mini webserver with the webservice. It defaults to port 9292,
91
- so you can access it at <http://localhost:9292>.
83
+ This will launch a mini webserver with the webservice. It defaults to port 9292, so you can access it at <http://localhost:9292>.
92
84
 
93
- To launch it on a different port provide the `-p [port-number]` option like
94
- this:
85
+ To launch it on a different port provide the `-p [port-number]` option like this:
95
86
 
96
87
  pos-tagger-server -p 1234
97
88
 
98
89
  It then launches at <http://localhost:1234>
99
90
 
100
- Documentation on the Webservice is provided by surfing to the urls provided
101
- above. For more information on how to launch a webservice run the command with
102
- the ```-h``` option.
91
+ 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.
103
92
 
104
93
 
105
94
  ### Daemon
106
95
 
107
- Last but not least the POS tagger comes shipped with a daemon that
108
- can read jobs (and write) jobs to and from Amazon SQS queues. For more
109
- information type:
96
+ Last but not least the POS tagger comes shipped with a daemon that can read jobs (and write) jobs to and from Amazon SQS queues. For more information type:
110
97
 
111
98
  pos-tagger-daemon -h
112
99
 
113
100
  Description of dependencies
114
101
  ---------------------------
115
102
 
116
- This component runs best if you run it in an environment suited for OpeNER
117
- components. You can find an installation guide and helper tools in the [OpeNER installer](https://github.com/opener-project/opener-installer) and an [installation guide on the Opener Website](http://opener-project.github.io/getting-started/how-to/local-installation.html)
103
+ 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 [installation guide on the Opener Website](http://opener-project.github.io/getting-started/how-to/local-installation.html)
118
104
 
119
105
  At least you need the following system setup:
120
106
 
@@ -135,22 +121,22 @@ Language Extension
135
121
  The Core
136
122
  --------
137
123
 
138
- The component is a fat wrapper around the actual language technology core. You
139
- can find the core technolies in the following repositories:
124
+ The component is a fat wrapper around the actual language technology core. You can find the core technolies in the following repositories:
125
+
140
126
  <https://github.com/opener-project/?query=pos>
141
127
  <https://github.com/opener-project/?query=pos>
142
128
 
143
129
  Where to go from here
144
130
  ---------------------
145
131
 
146
- * [Check the project websitere](http://opener-project.github.io)
132
+ * [Check the project website](http://opener-project.github.io)
147
133
  * [Checkout the webservice](http://opener.olery.com/pos-tagger)
148
134
 
149
135
  Report problem/Get help
150
136
  -----------------------
151
137
 
152
- If you encounter problems, please email <support@opener-project.eu> or leave an
153
- issue in the [issue tracker](https://github.com/opener-project/pos-tagger/issues).
138
+ If you encounter problems, please email <support@opener-project.eu> or leave an issue in the
139
+ [issue tracker](https://github.com/opener-project/pos-tagger/issues).
154
140
 
155
141
 
156
142
  Contributing
@@ -6,6 +6,7 @@ require 'optparse'
6
6
 
7
7
  require_relative 'pos_tagger/version'
8
8
  require_relative 'pos_tagger/cli'
9
+ require_relative 'pos_tagger/error_layer'
9
10
 
10
11
  module Opener
11
12
  ##
@@ -45,15 +46,19 @@ module Opener
45
46
  # @return [Array]
46
47
  #
47
48
  def run(input)
48
- language = language_from_kaf(input)
49
+ begin
50
+ language = language_from_kaf(input)
49
51
 
50
- unless valid_language?(language)
51
- raise ArgumentError, "The specified language (#{language}) is invalid"
52
- end
52
+ unless valid_language?(language)
53
+ raise ArgumentError, "The specified language (#{language}) is invalid"
54
+ end
53
55
 
54
- kernel = language_constant(language).new(:args => options[:args])
56
+ kernel = language_constant(language).new(:args => options[:args])
55
57
 
56
- return kernel.run(input)
58
+ return kernel.run(input)
59
+ rescue Exception => error
60
+ return ErrorLayer.new(input, error.message, self.class).add
61
+ end
57
62
  end
58
63
 
59
64
  alias tag run
@@ -0,0 +1,85 @@
1
+ module Opener
2
+ class POSTagger
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
+ return document.to_xml(:encoding => "UTF-8")
29
+ end
30
+
31
+ ##
32
+ # Check if the document is a valid XML file.
33
+ #
34
+ def is_xml?
35
+ !!document.root
36
+ end
37
+
38
+ ##
39
+ # Add root element to the XML file.
40
+ #
41
+ def add_root
42
+ root = Nokogiri::XML::Node.new "KAF", document
43
+ document.add_child(root)
44
+ end
45
+
46
+ ##
47
+ # Check if the document already has an errors layer.
48
+ #
49
+ def has_errors_layer?
50
+ !!document.at('errors')
51
+ end
52
+
53
+ ##
54
+ # Add errors element to the XML file.
55
+ #
56
+ def add_errors_layer
57
+ node = Nokogiri::XML::Node.new "errors", document
58
+ document.root.add_child(node)
59
+ end
60
+
61
+ ##
62
+ # Add the text file incase it is not a valid XML document. More
63
+ # info for debugging.
64
+ #
65
+ def add_text
66
+ node = Nokogiri::XML::Node.new "raw", document
67
+ node.inner_html = input
68
+ document.root.add_child(node)
69
+
70
+ end
71
+
72
+ ##
73
+ # Add the actual error to the errors layer.
74
+ #
75
+ def add_error
76
+ node = document.at('errors')
77
+ error_node = Nokogiri::XML::Node.new "error", node
78
+ error_node['class'] = "#{klass.to_s} #{klass::VERSION}"
79
+ error_node.inner_html = error
80
+ node.add_child(error_node)
81
+ end
82
+
83
+ end # ErrorLayer
84
+ end # POSTagger
85
+ end # Opener
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class POSTagger
3
- VERSION = "2.1.0"
3
+ VERSION = "2.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-pos-tagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - development@olery.com
8
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: opener-pos-tagger-base
@@ -209,6 +209,7 @@ files:
209
209
  - exec/pos-tagger.rb
210
210
  - lib/opener/pos_tagger.rb
211
211
  - lib/opener/pos_tagger/cli.rb
212
+ - lib/opener/pos_tagger/error_layer.rb
212
213
  - lib/opener/pos_tagger/public/markdown.css
213
214
  - lib/opener/pos_tagger/server.rb
214
215
  - lib/opener/pos_tagger/version.rb
@@ -239,4 +240,3 @@ signing_key:
239
240
  specification_version: 4
240
241
  summary: Gem that wraps up the different existing pos-taggers
241
242
  test_files: []
242
- has_rdoc: yard