The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Game::WordBrain::Speller - Spell Checks Words

SYNOPSIS

    # Create new Spell Checker
    my $speller = Game::WordBrain::Speller->new({
        word_list => '/path/to/wordlist',   # Optional
    });

    # Test if a word is valid
    my $word = 'nerds';
    if( $speller->is_valid_word( $word ) ) {
        print "Looks like a valid word";
    }
    else {
        print "Nope, not a real word";
    }

DESCRIPTION

Originally Game::WordBrain made use of Text::Aspell as a speller. The problem was that Text:Aspell provided much more functionalty (and many more dependencies) then what Game::WordBrain really needed. Hence, Game::WordBrain::Speller was born.

This module loads a wordlist into memory and exposes a method to spellcheck words.

ATTRIBUTES

word_list

Path to a new line delimited word list. If not provided, the wordlist provided with this distrubtion will be used.

METHODS

new

    my $speller = Game::WordBrain::Speller->new({
        word_list => '/path/to/wordlist',  # Optional
    });

If the word_list is not specified the bundled wordlist will be used.

Returns an instance of Game::WordBrain::Speller.

is_valid_word

    my $speller = Game::WordBrain::Speller->...;

    if( $speller->is_valid_word( 'nerds' ) ) {
        print 'This is a real word';
    }
    else {
        print 'Nope, not really a word.';
    }

Spell checks a word. Returns a truthy value if the provided word is valid, falsey if it does not.