diff options
author | Patrick Simianer <p@simianer.de> | 2014-01-29 19:14:08 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-01-29 19:14:08 +0100 |
commit | 68acbb9a0c7967cb90a7e3756fc94fdd8a73d154 (patch) | |
tree | 3b445131dcb203e94473ae1d8aa82a1798585276 /add_seg | |
parent | 49158e721bfaf6423dca9fc633873218f691c83a (diff) |
make use of nlp_ruby, LICENSE
Diffstat (limited to 'add_seg')
-rwxr-xr-x | add_seg | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -2,30 +2,24 @@ require 'trollop' - STDIN.set_encoding 'utf-8' STDOUT.set_encoding 'utf-8' -def usage - puts "addseg [--nogz] [--loo] [--grammar] <path to grammars dir>\n" - exit 1 -end -opts = Trollop::options do - opt :grammar, "(Abs) path of folder containing grammar.", :type => :string, :short => '-g', :required => true +cfg = Trollop::options do + opt :grammar, "(Absolute) path of folder containing grammars.", :type => :string, :short => '-g', :required => true opt :loo, "leave one out", :type => :bool, :default => false opt :start_id, "start with this id", :type => :int, :default => 0, :short => '-i' opt :nogz, "grammar files not gzipped", :type => :bool, :default => false end - -i = opts[:start_id] +i = cfg[:start_id] while line = STDIN.gets ext = '.gz' - ext = '' if opts[:nogz] + ext = '' if cfg[:nogz] s = "<seg" - if opts[:loo] then s += " exclude=\"#{i}\"" end - if opts[:grammar] then s += " grammar=\"#{opts[:grammar]}/grammar.#{i}#{ext}\"" end + if cfg[:loo] then s += " exclude=\"#{i}\"" end + if cfg[:grammar] then s += " grammar=\"#{cfg[:grammar]}/grammar.#{i}#{ext}\"" end puts s + " id=\"#{i}\"> #{line.strip} </seg>" i+=1 end |