Class QuestionMatcher
java.lang.Object
org.ek9lang.assist.QuestionMatcher
Fuzzy matcher for Q&A questions.
Tokenizes input, resolves synonyms, and scores against registered questions
using Levenshtein distance on individual words.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA question paired with its match score. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindBestMatches(String input, QuestionRegistry registry) Find the best matching questions using default max results (3).findBestMatches(String input, QuestionRegistry registry, int maxResults) Find the best matching questions for the given input text.findByCategory(String input, QuestionRegistry registry) Find a category whose name fuzzy-matches the input.findScoredMatches(String input, QuestionRegistry registry, int maxResults) Find best matches with scores, so callers can distinguish best from also-relevant.(package private) intscore(Set<String> inputTokens, QuestionAndAnswer candidate) Score how well the input tokens match a candidate question.
-
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
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
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
Find a category whose name fuzzy-matches the input. Returns the matching category's questions, or empty list if no match.
-