module

Norvig

Inherits NumberTools < WordTools < Hasher

Norvig is an algorithm designed by Peter Norvig to demonstrate how a spell corrector works

Constants

BIG_BOOK = "data/big_en_book.txt"

BIG_BOOK is a book with alot of english words in it

LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

LETTERS are all the letters in the english language

NORVIG_WORDS = hasher(file_formatter(BIG_BOOK))

NORVIG_WORDS is a hash map of all the words in the big book as keys and how often they have appeared as values

Instance methods

corrector_one(word : String)

corrector takes in a miss spelt word as a string and corrects the spelling error of one letter

Source
corrector_two(word : String)
Source
known(words : Array)
Source
probability(word : String)

probaility takes in a known word as a string and returns the probility of that word to be used in any piece of text

Source