Ignore:
Timestamp:
Apr 25, 2007, 10:30:39 AM (18 years ago)
Author:
RBRi
Message:

changed to use StringUtilsUnit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/SearchUnit.pas

    r43 r115  
    4949  SysUtils,
    5050  DebugUnit,
    51   ACLStringUtility,
     51  StringUtilsUnit,
    5252  HelpTopic;
    5353
     
    109109  OccurrencePos := CaseInsensitivePos( SearchWord, ReferenceWord );
    110110  if OccurrencePos = 0 then
     111  begin
    111112    // no match
    112113    exit;
     114  end;
    113115
    114116  Result := MatchedWordRelevance( SearchWord, ReferenceWord );
     
    147149  begin
    148150    pDictWord := HelpFile.DictionaryWordPtrs[ DictIndex ];
    149     if StringsSame( SearchWord, pDictWord^ ) then
     151    if StrEqualIgnoringCase( SearchWord, pDictWord^ ) then
    150152      Results[ DictIndex ] := mwExactWord;
    151153  end;
     
    166168  begin
    167169    DictWord := HelpFile.DictionaryWords[ DictIndex ];
    168     if StrStarts( SearchWord, DictWord ) then
     170    if StrStartsWithIgnoringCase( SearchWord, DictWord ) then
    169171      Results[ DictIndex ] := MatchedWordRelevance( SearchWord, DictWord );
    170172  end;
     
    185187  begin
    186188    DictWord := HelpFile.DictionaryWords[ DictIndex ];
    187     if StrEnds( SearchWord, DictWord ) then
     189    if StrEndsWithIgnoringCase( SearchWord, DictWord ) then
    188190      Results[ DictIndex ] := MatchedWordRelevance( SearchWord, DictWord );
    189191  end;
     
    202204  WordRelevance: longint;
    203205  TitleWordRelevance: longint;
    204   P: longint;
    205 begin
     206  tmpTitleWords : TStringList;
     207  i : integer;
     208begin
     209  tmpTitleWords := TStringList.Create;
     210
    206211  // Search topic titles
    207212  for TopicIndex:= 0 to HelpFile.TopicCount - 1 do
     
    210215    pTitle:= Topic.TitlePtr;
    211216    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
    214222    begin
    215       GetNextValue( pTitle^, P, TitleWord, ' ' );
     223      TitleWord := tmpTitleWords[i];
     224
    216225      WordRelevance := CompareWord( SearchWord,
    217226                                    TitleWord );
     
    221230        begin
    222231          // matching the first word is best
    223           if P >= Length( pTitle^ ) then
     232          if i = tmpTitleWords.count-1 then
     233          begin
    224234            // in fact it's the only word
    225235            TitleWordRelevance := mwOnlyTitleWord
    226236                                  * WordRelevance
     237          end
    227238          else
    228239            TitleWordRelevance := mwFirstTitleWord
     
    240251    end;
    241252  end;
     253  tmpTitleWords.Destroy;
    242254end;
    243255
     
    254266  WordRelevance: longint;
    255267  IndexEntryWordRelevance: longint;
    256   P: longint;
    257 begin
     268  tmpIndexWords : TStringList;
     269  i : integer;
     270begin
     271  tmpIndexWords := TStringList.Create;
     272
    258273  for IndexIndex := 0 to HelpFile.Index.Count - 1 do
    259274  begin
     
    261276    pIndexEntry := HelpFile.IndexEntryPtr[ IndexIndex ];
    262277    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
    265283    begin
    266       GetNextValue( pIndexEntry^, P, IndexEntryWord, ' ' );
     284      IndexEntryWord := tmpIndexWords[i];
     285
    267286      WordRelevance := CompareWord( SearchWord,
    268287                                    IndexEntryWord );
     
    272291        begin
    273292          // matching the first word is best
    274           if P >= Length( pIndexEntry^ ) then
     293          if i = tmpIndexWords.count-1 then
     294          begin
    275295            // in fact it's the only word
    276296            IndexEntryWordRelevance := mwOnlyIndexWord
    277297                                       * WordRelevance
     298          end
    278299          else
    279300            IndexEntryWordRelevance := mwFirstIndexWord
     
    291312    end;
    292313  end;
     314
     315  tmpIndexWords.Destroy;
    293316end;
    294317
Note: See TracChangeset for help on using the changeset viewer.