diff options
author | Patrick Simianer <p@simianer.de> | 2013-12-06 20:42:57 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2013-12-06 20:42:57 +0100 |
commit | 1dcf5842ce8a684a4943d3a67a8eb1c210359851 (patch) | |
tree | 113ae24402424f2f9948b396b0e59f287c3834b4 | |
parent | 6ecd51da61a574f95ed7d914917d883d4d17f06a (diff) |
fixed ng
-rwxr-xr-x | ng | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -5,7 +5,7 @@ def ngrams_it(s, n, fix=false) a.each_with_index { |tok, i| tok.strip! 0.upto([n-1, a.size-i-1].min) { |m| - yield a[i..i+m] if !(fix^(a[i..i+m].size==n)) + yield a[i..i+m] if !(fix||(a[i..i+m].size>n)) } } end @@ -30,7 +30,7 @@ if __FILE__ == $0 require 'trollop' opts = Trollop::options do opt :n, "Ngrams", :type => :int, :default => 4 - opt :fix, "Don't output lower order Ngrams.", :type => :bool, :default => true + opt :fix, "Don't output lower order Ngrams.", :type => :bool, :default => false opt :separator, "separte ngrams of a line by this string", :type => :string, :default => "\n" end usage if not [0,2,4,6].include? ARGV.size |