https://github.com/tkellen/ruby-ngram
Break words and phrases into ngrams.
https://github.com/tkellen/ruby-ngram
Last synced: 6 months ago
JSON representation
Break words and phrases into ngrams.
- Host: GitHub
- URL: https://github.com/tkellen/ruby-ngram
- Owner: tkellen
- License: mit
- Created: 2013-12-12T15:07:20.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-12T18:53:54.000Z (almost 12 years ago)
- Last Synced: 2025-05-08T21:16:43.265Z (6 months ago)
- Language: Ruby
- Size: 113 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- nlp-with-ruby - ruby-ngram - (NLP Pipeline Subtasks / Phrasal Level Processing)
README
# ngram [](http://travis-ci.org/tkellen/ruby-ngram)
> Break words and phrases into ngrams.
## Setup
```console
gem install ngram
```
## Usage
```ruby
require 'ngram'
# these are default settings
ngram = NGram.new({
:size => 2,
:word_separator => " ",
:padchar => "_"
})
# => #
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.