diff options
Diffstat (limited to 'ng')
| -rwxr-xr-x | ng | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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 - |
