Skip to content
Break words and phrases into ngrams.
Ruby
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.gitignore
.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.

You can’t perform that action at this time.