anchor.diff:  {$mode objfpc}{$H+}
   
   // NewView - a new OS/2 Help Viewer
  -// Copyright 2001 Aaron Lawrence (aaronl at consultant dot com)
  +// Copyright 2003 Aaron Lawrence (aaronl at consultant dot com)
   // This software is released under the Gnu Public License - see readme.txt
   
   Interface
  
positive.code:   IndexIndex: longint;
    IndexEntry: string;
    IndexEntryWord: string;
    Topic: TTopic;
    IndexEntryWordIndex: longint;
    WordRelevance: longint;
    IndexEntryWordRelevance: longint;
  begin
    for IndexIndex:= 0 to HelpFile.Index.Count - 1 do
    begin
      Topic:= HelpFile.Index.Objects[ IndexIndex ] as TTopic;
      IndexEntry:= HelpFile.Index[ IndexIndex ];
      IndexEntryWordIndex := 0;
      while IndexEntry <> '' do
      begin
        IndexEntryWord:= ExtractNextValue( IndexEntry, ' ' );
        WordRelevance := CompareWord( SearchWord, IndexEntryWord );
        if WordRelevance > 0 then
        begin
          if IndexEntryWordIndex = 0 then
            // matching the first word is best
            IndexEntryWordRelevance := mwFirstIndexWord * WordRelevance
          else
            IndexEntryWordRelevance := mwIndexWord * WordRelevance;
          inc( Results^[ Topic.Index ], IndexEntryWordRelevance );
        end;
        inc( IndexEntryWordIndex );
      end;
    end;
  end;
  
  // Utility function used in decompression of search table.
  // Updates the appropriate entry in Results array.
  // The word being matched is given in DictIndex and is
  // used to count the actual occurrences of the word
  // within the topic
  {procedure AddTopicFoundInTopicText( TopicIndex: int16;
                                      Results: Int32ArrayPointer;
                                       DictIndex: longint;
                                                WordRelevance: longint );
  var
    Topic: TTopic;
    Relevance: longint;
  begin
    Topic:= _Topics[ TopicIndex ];
    Relevance := mwTopicTextWord
              * Topic.CountWord( DictIndex )
              * WordRelevance;
    inc( Results^[ TopicIndex ], Relevance );
  
  end;}
  
  // ------------------------------------------------------
  
  
negative.code:   TitleWordIndex: longint;
    WordRelevance: longint;
    TitleWordRelevance: longint;
    tmpTitleWords : TStringList;
    i : integer;
  begin
    tmpTitleWords := TStringList.Create;
  
    // Search topic titles
    for TopicIndex := 0 to HelpFile.TopicCount - 1 do
    begin
      Topic := HelpFile.Topics[ TopicIndex ];
      Title:= Topic.Title;
      TitleWordIndex := 0;
  
      tmpTitleWords.Clear;
      StrExtractStringsQuoted(tmpTitleWords, Title);
  
      for i := 0 to tmpTitleWords.count-1 do
      begin
        TitleWord := tmpTitleWords[i];
  
        WordRelevance := CompareWord( SearchWord,
                                      TitleWord );
        if WordRelevance > 0 then
        begin
          if TitleWordIndex = 0 then
          begin
            // matching the first word is best
            if i = tmpTitleWords.count-1 then
            begin
              // in fact it's the only word
              TitleWordRelevance := mwOnlyTitleWord * WordRelevance
            end
            else
              TitleWordRelevance := mwFirstTitleWord * WordRelevance
          end
          else
          begin
            TitleWordRelevance := mwTitleWord * WordRelevance;
          end;
          inc( Results^[ Topic.Index ], TitleWordRelevance );
        end;
        inc( TitleWordIndex );
      end;
    end;
    tmpTitleWords.Free;
  end;
  
  // Search index entries for given searchword
  