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.
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.
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:
int secor.Init("dictionary", "codes");
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, "
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.
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 "
If the word is not correct, "
getSuggestions" can be used to create a list of suggestions.
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 "
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:
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".