opener-pos-tagger 3.0.0 → 3.2.0

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
- SHA1:
3
- metadata.gz: 265d6d03c32e0facbfe14fb9e40b00ef400318a3
4
- data.tar.gz: 744bf220b17323b4167286118d13c138d05a2cf3
2
+ SHA256:
3
+ metadata.gz: 774dcdae5e00e60c2f23bd37ed200b72447da5c32e8656bc82ed5be817f59b69
4
+ data.tar.gz: 6c1938904c3e6d935c3eff89448c66e2952255e1fa4f41a2ca7f784bb2940dd0
5
5
  SHA512:
6
- metadata.gz: 611d76b145ce73e77738a7fa27d4bcffeba2663a079c72762793c7d6aa7fb0b2c19bf2b57b0b3fc9bdfabc01cb9fc05a49b75c4434dfeac0ca25868ca292b993
7
- data.tar.gz: 55e715455ea8bfd992c576ee71ab334bbff12d6499796eaadc9b98d8211a1dfb99a10559be8a438a41a4e91f1d81c1ff3cecdb495748d7a240e9dac8a3018712
6
+ metadata.gz: 71c595655b35c5f2ad9cdd3d6654c611793437f496db80084404bc02cd56c67bdfb9e7055d2b11bcce59b821f71a7f866e49d4e13c161ab0a6535cd822244a25
7
+ data.tar.gz: 9654949d072ea842b00bce46bc487511345d287bdece48bc1fb1f51a7998e621a50ef3aa260fef14387cd98c705e1c80a0aa16511c2d4e47d461b731e594642e
@@ -2,6 +2,6 @@
2
2
 
3
3
  require_relative '../lib/opener/pos_tagger'
4
4
 
5
- cli = Opener::POSTagger::CLI.new(:args => ARGV)
5
+ cli = Opener::POSTagger::CLI.new
6
6
 
7
- cli.run(STDIN.tty? ? nil : STDIN.read)
7
+ cli.run
@@ -4,7 +4,7 @@ require 'opener/daemons'
4
4
 
5
5
  controller = Opener::Daemons::Controller.new(
6
6
  :name => 'opener-pos-tagger',
7
- :exec_path => File.expand_path('../../exec/pos-atgger.rb', __FILE__)
7
+ :exec_path => File.expand_path('../../exec/pos-tagger.rb', __FILE__)
8
8
  )
9
9
 
10
10
  controller.run
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'opener/daemons'
4
4
 
5
- require_relative '../lib/opener/tokenizer'
5
+ require_relative '../lib/opener/pos_tagger'
6
6
 
7
7
  daemon = Opener::Daemons::Daemon.new(Opener::POSTagger)
8
8
 
@@ -1,8 +1,11 @@
1
+ require 'open3'
2
+
3
+ require 'opener/core'
1
4
  require 'opener/pos_taggers/base'
2
5
  require 'opener/pos_taggers/en'
6
+
3
7
  require 'nokogiri'
4
- require 'open3'
5
- require 'optparse'
8
+ require 'slop'
6
9
 
7
10
  require_relative 'pos_tagger/version'
8
11
  require_relative 'pos_tagger/cli'
@@ -44,11 +47,11 @@ module Opener
44
47
  # @param [String] input The input to process.
45
48
  # @return [Array]
46
49
  #
47
- def run(input)
50
+ def run input, params = {}
48
51
  language = language_from_kaf(input)
49
52
 
50
- unless valid_language?(language)
51
- raise ArgumentError, "The specified language (#{language}) is invalid"
53
+ if !language or !valid_language?(language)
54
+ raise Core::UnsupportedLanguageError, language
52
55
  end
53
56
 
54
57
  kernel = language_constant(language).new(:args => options[:args])
@@ -58,20 +61,22 @@ module Opener
58
61
 
59
62
  alias tag run
60
63
 
61
- protected
62
-
63
64
  ##
64
- # Extracts the language from a KAF document.
65
+ # Extracts the language from a KAF document, returns `nil` if no language
66
+ # was found.
65
67
  #
66
68
  # @param [String] input
67
69
  # @return [String]
68
70
  #
69
71
  def language_from_kaf(input)
70
- reader = Nokogiri::XML::Reader(input)
72
+ document = Nokogiri::XML(input)
73
+ language = document.xpath('KAF/@xml:lang')[0]
71
74
 
72
- return reader.read.lang
75
+ return language ? language.to_s : nil
73
76
  end
74
77
 
78
+ private
79
+
75
80
  ##
76
81
  # @param [String] language
77
82
  # @return [Class]
@@ -86,5 +91,6 @@ module Opener
86
91
  def valid_language?(language)
87
92
  return Opener::POSTaggers.const_defined?(language.upcase)
88
93
  end
89
- end # POSTagger
90
- end # Opener
94
+
95
+ end
96
+ end
@@ -1,72 +1,57 @@
1
- require 'optparse'
2
-
3
1
  module Opener
4
2
  class POSTagger
5
3
  ##
6
- # CLI wrapper around {Opener::POSTagger} using OptionParser.
4
+ # CLI wrapper around {Opener::POSTagger} using Slop.
7
5
  #
8
- # @!attribute [r] options
9
- # @return [Hash]
10
- # @!attribute [r] option_parser
11
- # @return [OptionParser]
6
+ # @!attribute [r] parser
7
+ # @return [Slop]
12
8
  #
13
9
  class CLI
14
- attr_reader :options, :option_parser
10
+ attr_reader :parser
11
+
12
+ def initialize
13
+ @parser = configure_slop
14
+ end
15
15
 
16
16
  ##
17
- # @param [Hash] options
17
+ # @param [Array] argv
18
18
  #
19
- def initialize(options = {})
20
- @options = DEFAULT_OPTIONS.merge(options)
19
+ def run(argv = ARGV)
20
+ parser.parse(argv)
21
+ end
21
22
 
22
- @option_parser = ::OptionParser.new do |opts|
23
- opts.program_name = 'pos-tagger'
24
- opts.summary_indent = ' '
23
+ ##
24
+ # @return [Slop]
25
+ #
26
+ def configure_slop
27
+ return Slop.new(:strict => false, :indent => 2, :help => true) do
28
+ banner 'Usage: pos-tagger [OPTIONS]'
25
29
 
26
- opts.on('-h', '--help', 'Shows this help message') do
27
- show_help
28
- end
30
+ separator <<-EOF.chomp
29
31
 
30
- opts.on('-v', '--version', 'Shows the current version') do
31
- show_version
32
- end
32
+ About:
33
33
 
34
- opts.separator <<-EOF
34
+ POS tagger component with support for various languages such as Dutch and
35
+ English. This component reads input from STDIN.
35
36
 
36
- Examples:
37
+ Example:
37
38
 
38
- cat example.kaf | #{opts.program_name}
39
+ cat some_file.kaf | pos-tagger
39
40
  EOF
40
- end
41
- end
42
-
43
- ##
44
- # @param [String] input
45
- #
46
- def run(input)
47
- option_parser.parse!(options[:args])
48
-
49
- tagger = POSTagger.new(options)
50
-
51
- stdout = tagger.run(input)
52
41
 
53
- puts stdout
54
- end
42
+ separator "\nOptions:\n"
55
43
 
56
- private
44
+ on :v, :version, 'Shows the current version' do
45
+ abort "pos-tagger v#{VERSION} on #{RUBY_DESCRIPTION}"
46
+ end
57
47
 
58
- ##
59
- # Shows the help message and exits the program.
60
- #
61
- def show_help
62
- abort option_parser.to_s
63
- end
48
+ run do |opts, args|
49
+ tagger = POSTagger.new(:args => args)
50
+ input = STDIN.tty? ? nil : STDIN.read
64
51
 
65
- ##
66
- # Shows the version and exits the program.
67
- #
68
- def show_version
69
- abort "#{option_parser.program_name} v#{VERSION} on #{RUBY_DESCRIPTION}"
52
+ puts tagger.run(input)
53
+ end
54
+ end
70
55
  end
71
56
  end # CLI
72
57
  end # POSTagger
@@ -1,5 +1,7 @@
1
1
  module Opener
2
2
  class POSTagger
3
- VERSION = '3.0.0'
3
+
4
+ VERSION = '3.2.0'
5
+
4
6
  end
5
7
  end
@@ -7,7 +7,6 @@ Gem::Specification.new do |gem|
7
7
  gem.summary = 'Gem that wraps up the different existing pos-taggers'
8
8
  gem.description = gem.summary
9
9
  gem.homepage = 'http://opener-project.github.com/'
10
- gem.has_rdoc = "yard"
11
10
  gem.required_ruby_version = ">= 1.9.2"
12
11
 
13
12
  gem.license = 'Apache 2.0'
@@ -26,14 +25,14 @@ Gem::Specification.new do |gem|
26
25
  gem.add_dependency 'opener-pos-tagger-base', ['~> 2.0', '>= 2.1.0']
27
26
  gem.add_dependency 'opener-pos-tagger-en-es', ['~> 2.0', '>= 2.0.2']
28
27
 
29
- gem.add_dependency 'nokogiri'
30
28
  gem.add_dependency 'opener-webservice', '~> 2.0'
31
29
  gem.add_dependency 'opener-daemons', '~> 2.1'
32
- gem.add_dependency 'opener-core', '~> 2.0'
30
+ gem.add_dependency 'opener-core', '~> 2.3'
31
+
32
+ gem.add_dependency 'nokogiri'
33
+ gem.add_dependency 'slop', '~> 3.5'
33
34
 
34
35
  gem.add_development_dependency 'rspec'
35
- gem.add_development_dependency 'cucumber'
36
36
  gem.add_development_dependency 'pry'
37
37
  gem.add_development_dependency 'rake'
38
38
  end
39
-
metadata CHANGED
@@ -1,191 +1,191 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-pos-tagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.2.0
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-11-24 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: opener-pos-tagger-base
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- - - '>='
21
- - !ruby/object:Gem::Version
22
- version: 2.1.0
23
14
  requirement: !ruby/object:Gem::Requirement
24
15
  requirements:
25
- - - ~>
16
+ - - "~>"
26
17
  - !ruby/object:Gem::Version
27
18
  version: '2.0'
28
- - - '>='
19
+ - - ">="
29
20
  - !ruby/object:Gem::Version
30
21
  version: 2.1.0
22
+ name: opener-pos-tagger-base
31
23
  prerelease: false
32
24
  type: :runtime
33
- - !ruby/object:Gem::Dependency
34
- name: opener-pos-tagger-en-es
35
25
  version_requirements: !ruby/object:Gem::Requirement
36
26
  requirements:
37
- - - ~>
27
+ - - "~>"
38
28
  - !ruby/object:Gem::Version
39
29
  version: '2.0'
40
- - - '>='
30
+ - - ">="
41
31
  - !ruby/object:Gem::Version
42
- version: 2.0.2
32
+ version: 2.1.0
33
+ - !ruby/object:Gem::Dependency
43
34
  requirement: !ruby/object:Gem::Requirement
44
35
  requirements:
45
- - - ~>
36
+ - - "~>"
46
37
  - !ruby/object:Gem::Version
47
38
  version: '2.0'
48
- - - '>='
39
+ - - ">="
49
40
  - !ruby/object:Gem::Version
50
41
  version: 2.0.2
42
+ name: opener-pos-tagger-en-es
51
43
  prerelease: false
52
44
  type: :runtime
53
- - !ruby/object:Gem::Dependency
54
- name: nokogiri
55
45
  version_requirements: !ruby/object:Gem::Requirement
56
46
  requirements:
57
- - - '>='
47
+ - - "~>"
58
48
  - !ruby/object:Gem::Version
59
- version: '0'
49
+ version: '2.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.0.2
53
+ - !ruby/object:Gem::Dependency
60
54
  requirement: !ruby/object:Gem::Requirement
61
55
  requirements:
62
- - - '>='
56
+ - - "~>"
63
57
  - !ruby/object:Gem::Version
64
- version: '0'
58
+ version: '2.0'
59
+ name: opener-webservice
65
60
  prerelease: false
66
61
  type: :runtime
67
- - !ruby/object:Gem::Dependency
68
- name: opener-webservice
69
62
  version_requirements: !ruby/object:Gem::Requirement
70
63
  requirements:
71
- - - ~>
64
+ - - "~>"
72
65
  - !ruby/object:Gem::Version
73
66
  version: '2.0'
67
+ - !ruby/object:Gem::Dependency
74
68
  requirement: !ruby/object:Gem::Requirement
75
69
  requirements:
76
- - - ~>
70
+ - - "~>"
77
71
  - !ruby/object:Gem::Version
78
- version: '2.0'
72
+ version: '2.1'
73
+ name: opener-daemons
79
74
  prerelease: false
80
75
  type: :runtime
81
- - !ruby/object:Gem::Dependency
82
- name: opener-daemons
83
76
  version_requirements: !ruby/object:Gem::Requirement
84
77
  requirements:
85
- - - ~>
78
+ - - "~>"
86
79
  - !ruby/object:Gem::Version
87
80
  version: '2.1'
81
+ - !ruby/object:Gem::Dependency
88
82
  requirement: !ruby/object:Gem::Requirement
89
83
  requirements:
90
- - - ~>
84
+ - - "~>"
91
85
  - !ruby/object:Gem::Version
92
- version: '2.1'
86
+ version: '2.3'
87
+ name: opener-core
93
88
  prerelease: false
94
89
  type: :runtime
95
- - !ruby/object:Gem::Dependency
96
- name: opener-core
97
90
  version_requirements: !ruby/object:Gem::Requirement
98
91
  requirements:
99
- - - ~>
92
+ - - "~>"
100
93
  - !ruby/object:Gem::Version
101
- version: '2.0'
94
+ version: '2.3'
95
+ - !ruby/object:Gem::Dependency
102
96
  requirement: !ruby/object:Gem::Requirement
103
97
  requirements:
104
- - - ~>
98
+ - - ">="
105
99
  - !ruby/object:Gem::Version
106
- version: '2.0'
100
+ version: '0'
101
+ name: nokogiri
107
102
  prerelease: false
108
103
  type: :runtime
109
- - !ruby/object:Gem::Dependency
110
- name: rspec
111
104
  version_requirements: !ruby/object:Gem::Requirement
112
105
  requirements:
113
- - - '>='
106
+ - - ">="
114
107
  - !ruby/object:Gem::Version
115
108
  version: '0'
109
+ - !ruby/object:Gem::Dependency
116
110
  requirement: !ruby/object:Gem::Requirement
117
111
  requirements:
118
- - - '>='
112
+ - - "~>"
119
113
  - !ruby/object:Gem::Version
120
- version: '0'
114
+ version: '3.5'
115
+ name: slop
121
116
  prerelease: false
122
- type: :development
123
- - !ruby/object:Gem::Dependency
124
- name: cucumber
117
+ type: :runtime
125
118
  version_requirements: !ruby/object:Gem::Requirement
126
119
  requirements:
127
- - - '>='
120
+ - - "~>"
128
121
  - !ruby/object:Gem::Version
129
- version: '0'
122
+ version: '3.5'
123
+ - !ruby/object:Gem::Dependency
130
124
  requirement: !ruby/object:Gem::Requirement
131
125
  requirements:
132
- - - '>='
126
+ - - ">="
133
127
  - !ruby/object:Gem::Version
134
128
  version: '0'
129
+ name: rspec
135
130
  prerelease: false
136
131
  type: :development
137
- - !ruby/object:Gem::Dependency
138
- name: pry
139
132
  version_requirements: !ruby/object:Gem::Requirement
140
133
  requirements:
141
- - - '>='
134
+ - - ">="
142
135
  - !ruby/object:Gem::Version
143
136
  version: '0'
137
+ - !ruby/object:Gem::Dependency
144
138
  requirement: !ruby/object:Gem::Requirement
145
139
  requirements:
146
- - - '>='
140
+ - - ">="
147
141
  - !ruby/object:Gem::Version
148
142
  version: '0'
143
+ name: pry
149
144
  prerelease: false
150
145
  type: :development
151
- - !ruby/object:Gem::Dependency
152
- name: rake
153
146
  version_requirements: !ruby/object:Gem::Requirement
154
147
  requirements:
155
- - - '>='
148
+ - - ">="
156
149
  - !ruby/object:Gem::Version
157
150
  version: '0'
151
+ - !ruby/object:Gem::Dependency
158
152
  requirement: !ruby/object:Gem::Requirement
159
153
  requirements:
160
- - - '>='
154
+ - - ">="
161
155
  - !ruby/object:Gem::Version
162
156
  version: '0'
157
+ name: rake
163
158
  prerelease: false
164
159
  type: :development
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
165
  description: Gem that wraps up the different existing pos-taggers
166
166
  email:
167
167
  executables:
168
- - pos-tagger-server
169
168
  - pos-tagger
170
169
  - pos-tagger-daemon
170
+ - pos-tagger-server
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
+ - LICENSE.txt
175
+ - README.md
176
+ - bin/pos-tagger
177
+ - bin/pos-tagger-daemon
178
+ - bin/pos-tagger-server
179
+ - config.ru
180
+ - exec/pos-tagger.rb
174
181
  - lib/opener/pos_tagger.rb
175
- - lib/opener/pos_tagger/version.rb
176
- - lib/opener/pos_tagger/server.rb
177
182
  - lib/opener/pos_tagger/cli.rb
178
183
  - lib/opener/pos_tagger/public/markdown.css
184
+ - lib/opener/pos_tagger/server.rb
185
+ - lib/opener/pos_tagger/version.rb
179
186
  - lib/opener/pos_tagger/views/index.erb
180
187
  - lib/opener/pos_tagger/views/result.erb
181
- - config.ru
182
188
  - opener-pos-tagger.gemspec
183
- - README.md
184
- - LICENSE.txt
185
- - exec/pos-tagger.rb
186
- - bin/pos-tagger-server
187
- - bin/pos-tagger
188
- - bin/pos-tagger-daemon
189
189
  homepage: http://opener-project.github.com/
190
190
  licenses:
191
191
  - Apache 2.0
@@ -196,19 +196,18 @@ require_paths:
196
196
  - lib
197
197
  required_ruby_version: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - '>='
199
+ - - ">="
200
200
  - !ruby/object:Gem::Version
201
201
  version: 1.9.2
202
202
  required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  requirements:
204
- - - '>='
204
+ - - ">="
205
205
  - !ruby/object:Gem::Version
206
206
  version: '0'
207
207
  requirements: []
208
208
  rubyforge_project:
209
- rubygems_version: 2.1.9
209
+ rubygems_version: 2.7.9
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: Gem that wraps up the different existing pos-taggers
213
213
  test_files: []
214
- has_rdoc: yard