diff options
author | Patrick Simianer <p@simianer.de> | 2014-02-27 14:49:43 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-02-27 14:49:43 +0100 |
commit | 38862b7e0cde7ac7285169c10e1377357ea24488 (patch) | |
tree | c53047c1da75884bfc172b4c1a4c8c6c5db7158e | |
parent | 3756592b47f61c78a9461e041176e99990b320ab (diff) |
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 + |