Interactive Parsing

version 3 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Metrics Core Algorithm

    Section - Find the Best Match

    Include (-

    [ BestMatch
        input_buffer
        dict_word_index
        best_score best_word_index
        ;
        best_word_index = -1;
        
        for (dict_word_index = 0 : dict_word_index < dictlen : dict_word_index ++)
        {
            score = CompareWithIndexedDictionaryWord(input_buffer, dict_word_index);
            if (score > best_score)
            {
                best_score = score;
                best_word_index = dict_word_index;
            }
        }
        
        if (best_word_index > -1)
        {
            print "The best match is '", (address) WordFromIndex(best_word_index), "'.^";
        }
        else
        {
            print "No match found.";
        }
    ];

    -).