Class QuestionMatcher

java.lang.Object
org.ek9lang.assist.QuestionMatcher

public class QuestionMatcher extends Object
Fuzzy matcher for Q&A questions. Tokenizes input, resolves synonyms, and scores against registered questions using Levenshtein distance on individual words.
  • Constructor Details

    • QuestionMatcher

      public QuestionMatcher()
  • Method Details

    • findBestMatches

      public List<QuestionAndAnswer> findBestMatches(String input, QuestionRegistry registry, int maxResults)
      Find the best matching questions for the given input text.
    • findBestMatches

      public List<QuestionAndAnswer> findBestMatches(String input, QuestionRegistry registry)
      Find the best matching questions using default max results (3).
    • findScoredMatches

      public List<QuestionMatcher.ScoredQuestion> findScoredMatches(String input, QuestionRegistry registry, int maxResults)
      Find best matches with scores, so callers can distinguish best from also-relevant.
    • score

      int score(Set<String> inputTokens, QuestionAndAnswer candidate)
      Score how well the input tokens match a candidate question. Lower score means better match. Matches against searchableTokens (keywords + alternates + migration context) for breadth, but uses keywords.size() for the ratio penalty so richly-documented QAs are not penalised.
    • findByCategory

      public List<QuestionAndAnswer> findByCategory(String input, QuestionRegistry registry)
      Find a category whose name fuzzy-matches the input. Returns the matching category's questions, or empty list if no match.