Changeset 115 for trunk/NewView/SearchUnit.pas
- Timestamp:
- Apr 25, 2007, 10:30:39 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/SearchUnit.pas
r43 r115 49 49 SysUtils, 50 50 DebugUnit, 51 ACLStringUtility,51 StringUtilsUnit, 52 52 HelpTopic; 53 53 … … 109 109 OccurrencePos := CaseInsensitivePos( SearchWord, ReferenceWord ); 110 110 if OccurrencePos = 0 then 111 begin 111 112 // no match 112 113 exit; 114 end; 113 115 114 116 Result := MatchedWordRelevance( SearchWord, ReferenceWord ); … … 147 149 begin 148 150 pDictWord := HelpFile.DictionaryWordPtrs[ DictIndex ]; 149 if Str ingsSame( SearchWord, pDictWord^ ) then151 if StrEqualIgnoringCase( SearchWord, pDictWord^ ) then 150 152 Results[ DictIndex ] := mwExactWord; 151 153 end; … … 166 168 begin 167 169 DictWord := HelpFile.DictionaryWords[ DictIndex ]; 168 if StrStarts ( SearchWord, DictWord ) then170 if StrStartsWithIgnoringCase( SearchWord, DictWord ) then 169 171 Results[ DictIndex ] := MatchedWordRelevance( SearchWord, DictWord ); 170 172 end; … … 185 187 begin 186 188 DictWord := HelpFile.DictionaryWords[ DictIndex ]; 187 if StrEnds ( SearchWord, DictWord ) then189 if StrEndsWithIgnoringCase( SearchWord, DictWord ) then 188 190 Results[ DictIndex ] := MatchedWordRelevance( SearchWord, DictWord ); 189 191 end; … … 202 204 WordRelevance: longint; 203 205 TitleWordRelevance: longint; 204 P: longint; 205 begin 206 tmpTitleWords : TStringList; 207 i : integer; 208 begin 209 tmpTitleWords := TStringList.Create; 210 206 211 // Search topic titles 207 212 for TopicIndex:= 0 to HelpFile.TopicCount - 1 do … … 210 215 pTitle:= Topic.TitlePtr; 211 216 TitleWordIndex := 0; 212 P := 1; 213 while P < Length( pTitle^ ) do 217 218 tmpTitleWords.Clear; 219 StrExtractStringsQuoted(tmpTitleWords, pTitle^); 220 221 for i := 0 to tmpTitleWords.count-1 do 214 222 begin 215 GetNextValue( pTitle^, P, TitleWord, ' ' ); 223 TitleWord := tmpTitleWords[i]; 224 216 225 WordRelevance := CompareWord( SearchWord, 217 226 TitleWord ); … … 221 230 begin 222 231 // matching the first word is best 223 if P >= Length( pTitle^ ) then 232 if i = tmpTitleWords.count-1 then 233 begin 224 234 // in fact it's the only word 225 235 TitleWordRelevance := mwOnlyTitleWord 226 236 * WordRelevance 237 end 227 238 else 228 239 TitleWordRelevance := mwFirstTitleWord … … 240 251 end; 241 252 end; 253 tmpTitleWords.Destroy; 242 254 end; 243 255 … … 254 266 WordRelevance: longint; 255 267 IndexEntryWordRelevance: longint; 256 P: longint; 257 begin 268 tmpIndexWords : TStringList; 269 i : integer; 270 begin 271 tmpIndexWords := TStringList.Create; 272 258 273 for IndexIndex := 0 to HelpFile.Index.Count - 1 do 259 274 begin … … 261 276 pIndexEntry := HelpFile.IndexEntryPtr[ IndexIndex ]; 262 277 IndexEntryWordIndex := 0; 263 P := 1; 264 while P < Length( pIndexEntry^ ) do 278 279 tmpIndexWords.Clear; 280 StrExtractStringsQuoted(tmpIndexWords, pIndexEntry^); 281 282 for i := 0 to tmpIndexWords.count-1 do 265 283 begin 266 GetNextValue( pIndexEntry^, P, IndexEntryWord, ' ' ); 284 IndexEntryWord := tmpIndexWords[i]; 285 267 286 WordRelevance := CompareWord( SearchWord, 268 287 IndexEntryWord ); … … 272 291 begin 273 292 // matching the first word is best 274 if P >= Length( pIndexEntry^ ) then 293 if i = tmpIndexWords.count-1 then 294 begin 275 295 // in fact it's the only word 276 296 IndexEntryWordRelevance := mwOnlyIndexWord 277 297 * WordRelevance 298 end 278 299 else 279 300 IndexEntryWordRelevance := mwFirstIndexWord … … 291 312 end; 292 313 end; 314 315 tmpIndexWords.Destroy; 293 316 end; 294 317
Note:
See TracChangeset
for help on using the changeset viewer.