summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2015-01-07 18:47:50 +0100
committerPatrick Simianer <p@simianer.de>2015-01-07 18:47:50 +0100
commitcf0bf046e51a4a76315b8c964fabc8e641eb91fe (patch)
treec2746bc11a2a33007636f98c96bded350e264f40
parente0b634754d1bef33dc8e72509c6990cccc32745a (diff)
select_from, max_len
-rwxr-xr-xmax_len16
-rwxr-xr-xselect_from19
2 files changed, 35 insertions, 0 deletions
diff --git a/max_len b/max_len
new file mode 100755
index 0000000..69013b5
--- /dev/null
+++ b/max_len
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+
+require 'zipf'
+
+max = ARGV[0].to_i
+
+i = 0
+while line = STDIN.gets
+ if tokenize(line).size <= max
+ puts i
+ else
+ STDERR.write line
+ end
+ i += 1
+end
+
diff --git a/select_from b/select_from
new file mode 100755
index 0000000..14fbc9e
--- /dev/null
+++ b/select_from
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+require 'zipf'
+
+accept = {}
+
+f = ReadFile.new ARGV[0]
+f.readlines_strip.each { |line|
+ accept[line.strip.to_i] = true
+}
+
+i = 0
+while line = STDIN.gets
+ if accept[i]
+ STDOUT.write line
+ end
+ i += 1
+end
+