-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1d7eda
commit 49ee9e9
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ Gemfile.lock | |
doc/* | ||
pkg/* | ||
coverage/* | ||
vendor/* |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Changelog | ||
|
||
## v0.2.0 | ||
|
||
### Added | ||
|
||
- Add `tokenizer` option to `Document` class | ||
|
||
The value is an object with a `tokenize` method that accepts a string and returns an array of `Token` instances. | ||
|
||
For example, to use [natto](https://rubygems.org/gems/natto) instead of [unicode_utils](https://rubygems.org/gems/unicode_utils) for Japanese, install MeCab (`brew install mecab`), and then: | ||
|
||
```ruby | ||
require 'natto' | ||
|
||
class Tokenizer | ||
def initialize | ||
@nm = Natto::MeCab.new | ||
end | ||
|
||
def tokenize(text) | ||
@nm.enum_parse(text).map do |node| | ||
Token.new(node) | ||
end | ||
end | ||
end | ||
|
||
document = TfIdfSimilarity::Document.new("こんにちは世界", tokenizer: tokenizer) | ||
``` | ||
|
||
- Add `to_s` method to `Token` class, to use less memory than chaining `lowercase_filter` with `classic_filter` |