Click here to Skip to main content
15,895,746 members
Articles / Programming Languages / C++
Article

Secor Spell checker

Rate me:
Please Sign up or sign in to vote.
4.11/5 (8 votes)
18 Oct 2004GPL33 min read 31.8K   1.4K   19   4
Interactive spell check system.

Introduction

Secor is an interactive spell check system. It was designed to test a technique which uses the Trigram method as a filter to reduce the size of the dictionary. Once the selection is done, an edit distance method is used to rank the list of words. The algorithm will keep only those words whose distance is minimum and they will be presented as suggestions to replace the wrong word.

Technical

Usually these algorithms are included in an application, so this system was designed as an API (Application Programming Interface) that provide an easy way to include a spell checker in your application.

The Secor library contains one main class and several complementary classes. This main class is Secor and is used to set the initial configuration and to check if a word is in the dictionary, and coming up with suggestions if this word wasn't spelled correctly.

Usage

To use Secor in your application, you must include the files named "estructuras.h" and "secor.h". To link the project, you must add the file named "secor.lib" into the "Object/library modules" option in "Project Settings".

When your application first starts, you should create a Secor class and configure it with the command:

Secor secor;
int secor.Init("dictionary", "codes");

The Init function has two parameters: "dictionary" specifies the name and path of the file with the dictionary and "code" specifies the name and path of the file with the trigrams codes. If for some reason the configuration process fails, Init will return "-1", otherwise, "0".

Once the configuration process is finished you can start to use the spell checker. The first step is to verify if a word is correct by looking for it in the dictionary.

bool isCorrect("word");

If the word is in the dictionary, the function will return "true" and it can be considered correct, but if the word isn't in the dictionary, the word is considered wrong and will return "false".

If the word is not correct, "getSuggestions" can be used to create a list of suggestions.

int getSuggestions("wrong_word");

This function will return the number of found suggestions. To be able to see them you must use the command "getNextSuggestion"; this function will return one by one the suggestions found by the last command.

int getNextSuggestion(char *suggestion);

This way, each time you use this function you will get the next suggestion until the list gets to the end, when this happens the function will return "-1", otherwise, it will return "0".

Finally there is one last function to talk about. It is not part of the spell checking process but it is very important. This API has the ability to import a new dictionary, this can be done by using the command:

int ImportDict("list_words")

"list_words" specifies the name and path of the file that stores the list of word that will be used to create the new dictionary; besides, this function will create a file with the trigrams codes that are necessary to work with this new dictionary.

The new dictionary will have ".dic" extension and the trigram codes file will have the extension ".tri".

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer Particular
Argentina Argentina
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionerror message while integration.. Pin
Pro_Dev18-Jul-12 20:56
Pro_Dev18-Jul-12 20:56 
GeneralUseful project Pin
Franc Morales24-Jul-08 20:33
Franc Morales24-Jul-08 20:33 
GeneralRe: Useful project Pin
Pro_Dev18-Jul-12 20:55
Pro_Dev18-Jul-12 20:55 
GeneralRe: Useful project Pin
Diego Barrientos19-Jul-12 3:31
Diego Barrientos19-Jul-12 3:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.