Click here to Skip to main content
11,412,345 members (68,562 online)
Click here to Skip to main content
Add your own
alternative version

A Spell Checking Engine

, 5 Feb 2001
A free spell checking engine for use in your C++ applications. Includes the current US English dictionary
// **********************************************************
// FPS Spell Checking Engine
// Date created: 01-20-2001
// Author: Matthew T Gullett
//		   gullettm@yahoo.com
// (c) 2001
//
// This header file is used to include support for the
// spell checking engine in an application.
// **********************************************************

#ifndef __FPSSPELLCHECKER_SUPPORT__
#define __FPSSPELLCHECKER_SUPPORT__

// ************************************************
// define constant values to be used in engine
#define FPSSPELLCHECK_MAXWORDLEN		18
#define FPSSPELLCHECK_MAXMETALEN		8
#define FPSSPELLCHECK_MAXREDUCEDLEN		8

#define FPSDICHEADER_CODE			"FPSSPELL 1.0"
#define FPSDICHEADER_AUTHOR			"MATTHEW T GULLETT"
#define FPSDICHEADER_LANG_ENGLISH	"English (US)"
#define FPSDICHEADER_COMPRESS_NONE		0

#define FPSSPELLCHECK_ERROR_NONE					0
#define FPSSPELLCHECK_ERROR_MEMORY					1
#define FPSSPELLCHECK_ERROR_EXCEPTION				2
#define FPSSPELLCHECK_ERROR_CUSTOM					100
// ************************************************


// this structure defines the dictionary file header
// to be used in all dictionaries (except the common
// use dictionary)
typedef struct FPSDICHEADERTAG
{
	char szBeginCode[20];
	char szAuthor[50];
	char szDateCreated[12];
	char szDateUpdated[12];
	char szLanguage[20];
	UINT uiCompress;
	char szFiller[250];
	char szEndCode[20];
} FPSDICHEADER;

// this struct defines the records used in dictionary
// files
typedef struct FPSDICWORDTAG
{
	char szWord[FPSSPELLCHECK_MAXWORDLEN+1];
	char szMetaphone[FPSSPELLCHECK_MAXMETALEN+1];
	char szReduced[FPSSPELLCHECK_MAXREDUCEDLEN+1];
	BOOL bCaseSensitive;
	int iWordLen;
} FPSDICWORD;

// this struct is used by the engine for sorting
// the suggestion list in order by edit-distance
typedef struct FPSSPELLCHECK_WORDINFOTAG
{
	CString strWord;
	int iDiff;
} FPSSPELLCHECK_WORDINFO;

// include all necessary classes+support stuff
#include "afxtempl.h"
#include "FPSDictionary.h"
#include "FPSSpellCheckEngineOptions.h"
#include "FPSSpellCheckEngine.h"
#include "FPSSpellingEditCtrl.h"

// these are generic support functions used by many
// of the classes. 
// TECH NOTE: Some of these functions need to be
// (eventually) wrapped into a language specific class
// container.
BOOL IsVowel(const char szChar);
void TrimRight(char *szText);
void MetaphoneEx(const char *szInput, char *szOutput, int iMaxLen = 6);
int EditDistance(const char *szWord1, const char *szWord2) ;
inline BOOL IsCharMatch(const char c1, const char c2);
BOOL IsNumber(LPCSTR lpszWord) ;
void SortMatches(LPCSTR lpszBadWord, CStringList &Matches);
void RemoveVowels(const char *szInput, char *szOutput);
void RemoveVowelsAndDups(const char *szInput, char *szOutput);
BOOL IsWordMatch(const char *szWord1, int iWord1Len, const char *szWord2, int iWord2Len);
BOOL ConatainsUpperCase(LPCSTR lpszWord);
BOOL IsOK(int iCode);
BOOL IsWordBreak(char cThisChar);
int GetVowelCount(const char* szWord);

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Matt Gullett
Web Developer
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.5 | Last Updated 6 Feb 2001
Article Copyright 2001 by Matt Gullett
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid