-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix some bugs, update README, turn into a gem, add some tests
- Loading branch information
Showing
5 changed files
with
52 additions
and
12 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
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
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
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 @@ | ||
require 'minitest/autorun' | ||
require_relative '../lib/symspell' | ||
|
||
class SymSpellTest < Minitest::Test | ||
def setup | ||
@edit_distance_max = 2 | ||
end | ||
|
||
def subject | ||
@subject ||= SymSpell.new(@edit_distance_max).tap do |subject| | ||
subject.create_dictionary 'tests/words.txt' | ||
end | ||
end | ||
def test_lookup_correctly_spelled_word | ||
assert_equal 'andrew', subject.lookup('andrew').first.term | ||
end | ||
|
||
def test_lookup_misspelt_word | ||
assert_equal 'andrew', subject.lookup('andre').first.term | ||
end | ||
|
||
def test_lookup_fails_to_find_match | ||
assert_equal nil, subject.lookup('amigon').first | ||
end | ||
|
||
def test_lookup_finds_match_after_turning_up_edit_distance | ||
@edit_distance_max = 3 | ||
assert_equal 'imogen', subject.lookup('amigon').first.term | ||
end | ||
end | ||
|
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,7 @@ | ||
mark | ||
john | ||
peter | ||
mary | ||
andrew | ||
imogen | ||
|