-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtrouble.rb
executable file
·35 lines (31 loc) · 1.19 KB
/
trouble.rb
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
27
28
29
30
31
32
33
34
35
#! /usr/bin/env ruby
phases = ARGV.empty? ? %w{tagged binarised labelled fixed_rc fixed_adverbs fixed_np} : ARGV
STDIN.each_with_index {|line, i|
if i != 0 and i % 10 == 0
STDOUT.write "Continue? "
case gets
when "n"
exit
end
end
line.chomp!
(line =~ /(\d+):(\d+)\((\d+)\)/) || (line =~ /(\d+),(\d+),(\d+)/) || (line =~ /(\d{1,2}).*?(\d{1,2}).*?(\d+)/)
sec, doc, deriv = $1.to_i, $2.to_i, $3.to_i
doc_name = "chtb_%02d%02d.fid" % [sec, doc]
pdf_name = "wsj_%02d%02d.%02d.pdf" % [sec, doc, deriv]
section_name = "%02d" % sec
puts "Making %d:%d(%d)..." % [sec, doc, deriv]
`./make_all.sh #{doc_name}:#{$3}`
phases.each {|phase|
if ["tagged", "binarised"].include? phase
`./t -q -D #{phase}_dots #{phase}/#{doc_name}:#{$3} 2>&1`
else
`./t -q -D #{phase}_dots -R PrefacedPTBReader #{phase}/#{doc_name}:#{$3} 2>&1`
end
}
open_cmd = "open -a /Applications/Preview.app "
dot_files = phases.map {|phase| "#{phase}_dots/#{section_name}/#{pdf_name}"}.select {|file| test ?f, file}
open_cmd += dot_files.join(' ')
puts open_cmd
system open_cmd
}