summaryrefslogtreecommitdiff
path: root/add_seg
blob: 684a2364b201210b7572761c275ad263258ba4e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env ruby

require 'trollop'

STDIN.set_encoding 'utf-8'
STDOUT.set_encoding 'utf-8'


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 = cfg[:start_id]
while line = STDIN.gets
  ext = '.gz'
  ext = '' if cfg[:nogz]
  s = "<seg"
  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