|
/*
Copyright: 2000
Author: Matthew T Gullett
Email: gullettm@yahoo.com
Name: CFPSSpellCheckEngine
Part of: Spell Checking Engine 1 of 1
Requires: USMain.dic, [USUser.dic], [USCommon.dic]
DESCRIPTION
----------------------------------------------------------
This class is designed to implement a phonetic spell
checking engine with support for US English (and probably
UK english) It implements a simple interface for accessing
spell checking functions. It is designed to be very fast
with support for a user dictionary and a common misspelling
dictionary to improve performance and user perception.
INFO:
----------------------------------------------------------
This class is provided -as is-. No warranty as to the
function or performance of this class is provided either
written or implied.
You may freely use this code and modify it as necessary,
as long as this header is unmodified and credit is given
to the author in the application(s) in which it is
incorporated.
*/
#if !defined(AFX_FPSSPELLCHECKENGINE_H__9CDCF81C_0F4A_11D3_9EAF_444553540000__INCLUDED_)
#define AFX_FPSSPELLCHECKENGINE_H__9CDCF81C_0F4A_11D3_9EAF_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef struct FPSSPELL_MAINDIC_ALPOSTAG
{
BOOL bPresent;
long lFirstRecord;
long lLastRecord;
long lStartPos;
long lLen;
} FPSSPELL_MAINDIC_ALPOS;
#define FPSSPELL_MAIN_RECORD_LEN 36
#define FPSSPELL_MAIN_RECORD_LEN_NOCRLF 34
#define FPSSPELL_MIN_CACHE_SIZE 360000
#define FPSSPELL_DEFAULT_CACHE_SIZE 360000
#define FPSSPELL_MAIN_WORD_MAX_LEN 18
#define FPSSPELL_MAX_WORD_LEN_DIFF 3
class CFPSSpellCheckEngine
{
public:
CFPSSpellCheckEngine();
virtual ~CFPSSpellCheckEngine();
// ***************************************************
// program specific functions
virtual BOOL FindWord (LPCSTR lpszWord, CStringList& PossibleMatches);
virtual BOOL InitEngine();
virtual void SetDictionaries (LPCSTR lpszMain, LPCSTR lpszUser, LPCSTR lpszCommonUse);
virtual long GetRecordCount();
// ***************************************************
// user interact functions
virtual void AddWord (LPCSTR lpszWord);
virtual void IgnoreWord (LPCSTR lpszWord);
// ***************************************************
// DD maintance functions
virtual BOOL SaveWordFile (LPCSTR lpszFileName);
virtual void BuildMainDIC (LPCSTR lpszWordFile, LPCSTR lpszDICFile);
// ***************************************************
// parsing algorithms
virtual void PhoneticWord (char* szInput, char* szOutput);
virtual char GetFirstVowel(char* szWord, int& iVowelPos);
virtual int GetSylableCount (char* szWord);
virtual void MetaphoneEx(char *szInput, char *szOutput, int iMaxLen = 6);
virtual int GetVowelCount(char* szWord);
protected:
virtual void RemoveVowelsAndDups(char *szInput, char *szOutput);
virtual BOOL CheckEndings(LPCSTR lpszW1, int iLen1, LPCSTR lpszW2, int iLen2);
virtual BOOL IsWordMatch(char *szWord1, int iWord1Len, char *szWord2, int iWord2Len);
virtual BOOL IsMetaphoneMatch(char* szMeta1, char* szMeta2);
virtual void FindMatchingWords (LPCSTR lpszWord, CStringList& Matches);
virtual BOOL GetRecord(long lRecord, char *szWord);
virtual BOOL FindWordMain (LPCSTR lpszWordToFind);
virtual void CacheCommonUseWords();
virtual void CacheUserDic();
virtual void CacheWords();
virtual BOOL IsSylableCountsOK (int iWord, int iRecord);
virtual BOOL IsWordLenOK (int iWordLen, int iRecordWordLen);
virtual long GetRecordPos (long lRecord);
virtual BOOL IsVowel (char szChar);
virtual void TrimRight (char* szText);
virtual BOOL GetRecord (long lRecord, char* szWord, char* szMetaphon, int & iSylableCount, char* szPhonetic);
virtual void CacheWordLocations();
CString m_strMainDic;
CString m_strUserDic;
CString m_strCmnUseDic;
CMapStringToString m_UserDic;
CMapStringToString m_CmnUseDic;
CMapStringToString m_RecentFinds;
int m_iMainHandle;
char* m_pMainBuffer;
long m_lMainLen;
long m_lCacheStartPos;
long m_lCacheLen;
CString m_strTempWord;
FPSSPELL_MAINDIC_ALPOS m_LocationCache[255];
char* m_pWordCache;
long m_lWordsSearched;
long m_lComparisonsMade;
private:
void RemoveVowels (char* szInput, char* szOutput);
};
#endif // !defined(AFX_FPSSPELLCHECKENGINE_H__9CDCF81C_0F4A_11D3_9EAF_444553540000__INCLUDED_)
|
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.
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
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.