Created
August 14, 2009 18:28
-
-
Save automatthew/168001 to your computer and use it in GitHub Desktop.
like ngrams, but for phrases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'enumerator' | |
max = ARGV[0].to_i || 5 | |
while string = STDIN.gets | |
bits = string.chomp.split | |
(2..max).each do |i| | |
bits.each_cons(i) do |nlog| | |
puts nlog.join(" ") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment