summaryrefslogtreecommitdiff
path: root/ng
diff options
context:
space:
mode:
authorPatrick Simianer <patrick@lilt.com>2026-02-26 10:05:59 +0000
committerPatrick Simianer <patrick@lilt.com>2026-02-26 10:05:59 +0000
commitb31ace79ea5f6b3f279c544cd3a443d6fbf2a24d (patch)
tree31f2b599fa5f6996aeb134390d58deb63eefe04a /ng
parent8805e95ae94d798c6441f7e1b72c90e049563f17 (diff)
overhaulHEADmaster
Diffstat (limited to 'ng')
-rwxr-xr-xng9
1 files changed, 4 insertions, 5 deletions
diff --git a/ng b/ng
index f3a031d..af8015a 100755
--- a/ng
+++ b/ng
@@ -1,19 +1,18 @@
#!/usr/bin/env ruby
-require 'zipf'
-require 'optimist'
+require "zipf"
+require "optimist"
conf = Optimist::options do
banner "ng < <input>"
opt :n, "n for Ngrams", :type => :int, :default => 4
- opt :fix, "Don't output lower order Ngrams.", :type => :bool, :default => false
+ opt :fix, "Do not output lower order Ngrams.", :type => :bool, :default => false
opt :separator, "separte ngrams of a line by this string", :type => :string, :default => "\n"
end
while line = STDIN.gets
a = []
- ngrams(line, conf[:n], conf[:fix]) { |ng| a << ng.join(' ') }
+ ngrams(line, conf[:n], conf[:fix]) { |ng| a << ng.join(" ") }
a.reject! { |i| i.strip.size==0 }
puts a.join conf[:separator] if a.size>0
end
-