summaryrefslogtreecommitdiff
path: root/train_test_split
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2015-11-12 13:57:07 +0100
committerPatrick Simianer <p@simianer.de>2015-11-12 13:57:07 +0100
commit5c2833c505dda0d1646b8f8c1e62abd391f0401e (patch)
tree0259c7c2bdb531c09587a744869848d87f4bbd9e /train_test_split
parentef282dbe4fef1b0ae0c8544f0bb84ba674c68de7 (diff)
parent8151031373c08ccd714a99f50783eafcb54d2010 (diff)
Merge branch 'master' of github.com:pks/scripts
Diffstat (limited to 'train_test_split')
-rwxr-xr-xtrain_test_split12
1 files changed, 6 insertions, 6 deletions
diff --git a/train_test_split b/train_test_split
index db56de9..4d8153a 100755
--- a/train_test_split
+++ b/train_test_split
@@ -3,20 +3,20 @@
require 'zipf'
require 'trollop'
-cfg = Trollop::options do
+conf = Trollop::options do
opt :foreign, "foreign file", :type => :string, :required => true
opt :english, "english file", :type => :string, :required => true
opt :size, "one size", :type => :int, :required => true
opt :repeat, "number of repetitions", :type => :int, :default => 1
opt :prefix, "prefix for output files", :type => :string
end
-fn = cfg[:foreign]
+fn = conf[:foreign]
fn_ext = fn.split('.').last
f = ReadFile.readlines fn
-en = cfg[:english]
+en = conf[:english]
en_ext = en.split('.').last
e = ReadFile.readlines en
-size = cfg[:size]
+size = conf[:size]
nlines_f = `wc -l #{fn}`.split()[0].to_i
nlines_e = `wc -l #{en}`.split()[0].to_i
if nlines_f != nlines_e
@@ -24,10 +24,10 @@ if nlines_f != nlines_e
exit 1
end
-prefix = cfg[:prefix]
+prefix = conf[:prefix]
a = (0..nlines_e-1).to_a
i = 0
-cfg[:repeat].times {
+conf[:repeat].times {
b = a.sample(size)
ax = a.reject{|j| b.include? j}
`mkdir split_#{i}`