From b31ace79ea5f6b3f279c544cd3a443d6fbf2a24d Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Thu, 26 Feb 2026 10:05:59 +0000 Subject: overhaul --- ng | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'ng') 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 < " 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 - -- cgit v1.2.3