/* File: speller_main.cpp Copyright 2009 Chris Tonkinson (cmtonkinson@gmail.com) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ /** * @file speller_main.cpp * @author Chris Tonkinson (cmtonkinson@gmail.com) * @date May 2009 * @brief Test driver for the Speller and SpellerException classes. */ #include #include #include #include "speller.h" int main( int argc, char* argv[], char* envp[] ) { try { Speller* speller = NULL; std::vector suggestions; speller = new Speller(); speller->config( "dict-dir", "." ); speller->config( "lang", "en_US" ); speller->config( "ignore-case", "true" ); speller->config( "ignore-accents", "true" ); speller->config( "run-together", "false" ); speller->config( "sug-split-char", "" ); speller->config( "sug-mode", "bad-spellers" ); speller->init(); for ( int i = 1; i < argc; ++i ) { if ( speller->check( argv[i] ) ) { printf( "%s is OK\n", argv[i] ); } else { suggestions = speller->suggest( argv[i] ); printf( "%d suggestions for %s:", suggestions.size(), argv[i] ); for ( std::vector::const_iterator it = suggestions.begin(); it != suggestions.end(); ++it ) { printf( "%s, ", it->c_str() ); } printf( "recommended replacement for %s: %s\n", argv[i], speller->recommend( argv[i] ) ); } } delete speller; } catch ( SpellerException se ) { fprintf( stderr, "SpellerException: %s\n", se.message().c_str() ); } return EXIT_SUCCESS; }