opener-tree-tagger 4.0.0 → 4.1.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
2
  SHA1:
3
- metadata.gz: be445f3932e633ffbe7c11fd31393801c72cc025
4
- data.tar.gz: f3900dd4dd481cac768268bed936db806dfa710c
3
+ metadata.gz: 17794acc1c73c9e2734d93fc7ad30343262806cd
4
+ data.tar.gz: 8382d7a3f899f08568a9c021ef97199c00f4f24d
5
5
  SHA512:
6
- metadata.gz: a3abb1d49a7e01e084b6c4b451405586f6e83ce67ff1c086d5965bb6b906b1687e748ca7a3312a26e2d431c10b48a716ea892a72b882dcdde1a70e0dcf8d4f4f
7
- data.tar.gz: bae2c53f3f670d810b53e35cf126791a09f6106b0841c3b24d90165abb91a0c4234be6d4606dff2a63a721bf3129a665355aa2e307cd38934f698bd2e2cc3095
6
+ metadata.gz: ee5d95a22c467df609e58065aafc0962ef7dc9c12726c936dd5439786edce6330658096b01e91a1f2c3b43f022c36cee241f27ce83ccf481166faf5f6886780b
7
+ data.tar.gz: 64fdfc566d03364ff5f7ce483fdaffe521b06c2b06355c089b7c222a8dac0b30146eadf1e8c8d536e4dad8cb24b90276e81a824a8b08ec28aef405a3d0107e23
@@ -2,6 +2,6 @@
2
2
 
3
3
  require_relative '../lib/opener/tree_tagger'
4
4
 
5
- cli = Opener::TreeTagger::CLI.new(ARGV)
5
+ cli = Opener::TreeTagger::CLI.new
6
6
 
7
- puts cli.run(STDIN.tty? ? nil : STDIN.read)
7
+ cli.run
@@ -1,5 +1,5 @@
1
1
  require 'open3'
2
- require 'optparse'
2
+ require 'slop'
3
3
  require 'nokogiri'
4
4
 
5
5
  require_relative 'tree_tagger/version'
@@ -1,67 +1,64 @@
1
1
  module Opener
2
2
  class TreeTagger
3
+ ##
4
+ # CLI wrapper around {Opener::TreeTagger} using Slop.
5
+ #
6
+ # @!attribute [r] parser
7
+ # @return [Slop]
8
+ #
3
9
  class CLI
4
- attr_reader :argv, :options, :option_parser
10
+ attr_reader :parser
11
+
12
+ def initialize
13
+ @parser = configure_slop
14
+ end
5
15
 
6
16
  ##
7
17
  # @param [Array] argv
8
- # @param [Hash] options
9
18
  #
10
- def initialize(argv, options = {})
11
- @argv = argv
12
- @options = DEFAULT_OPTIONS.merge(options)
19
+ def run(argv = ARGV)
20
+ parser.parse(argv)
21
+ end
13
22
 
14
- @option_parser = OptionParser.new do |opts|
15
- opts.program_name = 'tree-tagger'
16
- 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: tree-tagger [OPTIONS]'
17
29
 
18
- opts.separator "\nOptions:\n\n"
30
+ separator <<-EOF.chomp
19
31
 
20
- opts.on('-l', '--log', 'Enable logging to STDERR') do
21
- @options[:logging] = true
22
- end
32
+ About:
23
33
 
24
- opts.on('--no-time', 'Disables adding of timestamps') do
25
- @options[:args] << '--no-time'
26
- end
27
-
28
- opts.separator <<-EOF
34
+ Rule base POS tagging using TreeTagger, supports various languages such as
35
+ Dutch and English. This command reads input from STDIN.
29
36
 
30
- Examples:
37
+ Example:
31
38
 
32
- cat example.kaf | #{opts.program_name} # Basic usage
33
- cat example.kaf | #{opts.program_name} -l # Logs information to STDERR
39
+ cat some_file.kaf | tree-tagger
34
40
  EOF
35
- end
36
- end
37
41
 
38
- ##
39
- # @param [String] input
40
- #
41
- def run(input)
42
- option_parser.parse!(argv)
42
+ separator "\nOptions:\n"
43
43
 
44
- tagger = TreeTagger.new(options)
44
+ on :v, :version, 'Shows the current version' do
45
+ abort "tree-tagger v#{VERSION} on #{RUBY_DESCRIPTION}"
46
+ end
45
47
 
46
- puts tagger.run(input)
47
- end
48
+ on :'no-time', 'Disables adding of dynamic timestamps'
48
49
 
49
- private
50
+ run do |opts, args|
51
+ if opts[:'no-time']
52
+ args = args + ['--no-time']
53
+ end
50
54
 
51
- ##
52
- # Shows the help message and exits the program.
53
- #
54
- def show_help
55
- abort option_parser.to_s
56
- end
55
+ tagger = TreeTagger.new(:args => args)
56
+ input = STDIN.tty? ? nil : STDIN.read
57
57
 
58
- ##
59
- # Shows the version and exits the program.
60
- #
61
- def show_version
62
- abort "#{option_parser.program_name} v#{VERSION} on #{RUBY_DESCRIPTION}"
58
+ puts tagger.run(input)
59
+ end
60
+ end
63
61
  end
64
- end
65
- end
66
- end
67
-
62
+ end # CLI
63
+ end # TreeTagger
64
+ end # Opener
@@ -1,5 +1,5 @@
1
1
  module Opener
2
2
  class TreeTagger
3
- VERSION = '4.0.0'
3
+ VERSION = '4.1.0'
4
4
  end
5
5
  end
@@ -34,6 +34,7 @@ Gem::Specification.new do |gem|
34
34
  gem.add_dependency 'rake'
35
35
  gem.add_dependency 'nokogiri'
36
36
  gem.add_dependency 'cliver'
37
+ gem.add_dependency 'slop', '~> 3.5'
37
38
 
38
39
  gem.add_development_dependency 'rspec', '~> 3.0'
39
40
  gem.add_development_dependency 'cucumber'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener-tree-tagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubenIzquierdo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-24 00:00:00.000000000 Z
12
+ date: 2014-11-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: opener-daemons
@@ -95,6 +95,20 @@ dependencies:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: slop
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '3.5'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '3.5'
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: rspec
100
114
  requirement: !ruby/object:Gem::Requirement