diff options
author | Patrick Simianer <p@simianer.de> | 2015-05-29 09:17:43 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-05-29 09:17:43 +0200 |
commit | 181c0bd79b0e7db2891047305dc87d20ca04097b (patch) | |
tree | 186f5030cf6b269dbdd4f599c634c8df71d12a72 /split_kbest | |
parent | af156ba147ed29c2e4b02bc24533e5286902a84a (diff) |
add_ln: add line numbers, filter_features: filter text reps of sparse vectors, split_*: split kbest lists and by line
Diffstat (limited to 'split_kbest')
-rwxr-xr-x | split_kbest | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/split_kbest b/split_kbest new file mode 100755 index 0000000..ab425b0 --- /dev/null +++ b/split_kbest @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby + +require 'zipf' + +def write_kbest l, fn + f = WriteFile.new fn + f.write l.join("") + f.close +end + +dir = ARGV[0] +i = 0 +l = [] +while line = STDIN.gets + j = line.split.first.to_i + if j == 0 && l.size > 0 + write_kbest l, "#{dir}/#{i}.gz" + l = [] + i += 1 + end + l << line +end +write_kbest l, "#{dir}/#{i}.gz" # last one + |