diff options
Diffstat (limited to 'merge_ttable')
-rwxr-xr-x | merge_ttable | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/merge_ttable b/merge_ttable new file mode 100755 index 0000000..7c58c5f --- /dev/null +++ b/merge_ttable @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +require 'nlp_ruby' +require 'trollop' + + +def main + cfg = Trollop::options do + opt :f, "f files", :type => :string, :required => true + opt :e, "e files", :type => :string, :required => true + end + + f_files = cfg[:f].split + e_files = cfg[:e].split + + h = {} + f_files.each_with_index { |fn,i| + fa = ReadFile.readlines_strip fn + ea = ReadFile.readlines_strip e_files[i] + fa.each_with_index { |fw,j| + if h.has_key? fw + h[fw] << ea[j] + else + h[fw] = [ea[j]] + end + } + } + + h.each_pair { |f,ea| + puts "#{f}\t#{ea.first}" + } +end + + +main + |