Break words and phrases into ngrams.
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore first commit Dec 12, 2013
.irbrc
.rspec
.travis.yml
CHANGELOG.md
Gemfile
LICENSE.md
README.md
Rakefile
ngram.gemspec

README.md

ngram Build Status

Break words and phrases into ngrams.

Setup

gem install ngram

Usage

require 'ngram'

# these are default settings
ngram = NGram.new({
  :size => 2,
  :word_separator => " ",
  :padchar => "_"
})
# => #<NGram:0x10d9877f0 @padchar="_", @separator=" ", @size=2>

ngram.parse('test')
# => ["__", "_t", "te", "es", "st", "t_", "__"]
ngram.parse('test phrase')
# => [["_t", "te", "es", "st", "t_"], ["_p", "ph", "hr", "ra", "as", "se", "e_"]]

Copyright (c) 2013 Tyler Kellen. See LICENSE for further details.