/*@@@ File: stopword.cxx Version: 1.00 Description: Class STOPWORD - Stop word list Author: Nassib Nassar, nrn@cnidr.org @@@*/ #include #include #include #include "isearch.hxx" #include "stopword.hxx" STOPWORD::STOPWORD( //@ManMemo: Name of file to be mapped to this object. const STRING& FileName ) { // Initialize state variables Changed = GDT_FALSE; Sorted = GDT_TRUE; // Try to open the file FILE* Fp = fopen(FileName, "rb"); if (Fp) { // Get file size fseek(Fp, 0, SEEK_END); TotalEntries = ftell(Fp) / MaxStopWordLength; fseek(Fp, 0, SEEK_SET); BlockPtr = new CHR[TotalEntries * MaxStopWordLength]; fread(BlockPtr, 1, TotalEntries * MaxStopWordLength, Fp); fclose(Fp); } else { BlockPtr = 0; TotalEntries = 0; } SwFileName = FileName; } static int StopwordCompareWords( //@ManMemo: First word to compare. const void* Word1, //@ManMemo: Second word to compare. const void* Word2 ) { return StrCaseCmp((CHR*)Word1, (CHR*)Word2); } INT STOPWORD::AddWords( //@ManMemo: List of words to be added to stop word list. const STRLIST& WordList ) { INT Total = WordList.GetTotalEntries(); if (Total > 0) { INT x; STRING Sw; // First remove entries that are already in the list STRLIST NewWordList; CHR AWord[MaxStopWordLength]; for (x=1; x<=Total; x++) { WordList.GetEntry(x, &Sw); Sw.GetCString(AWord, MaxStopWordLength); if (IsStopWord(AWord) == GDT_FALSE) { NewWordList.AddEntry(Sw); } } // Now add them Total = NewWordList.GetTotalEntries(); INT OldTotalEntries = TotalEntries; Resize(TotalEntries + Total); for (x=0; x