suggest::util

Function full_keyword

source
pub fn full_keyword(query: &str, keywords: &[impl AsRef<str>]) -> String
Expand description

Given a list of keywords for a suggestion, returns a phrase that best completes the user’s query. This function uses two heuristics to pick the best match:

  1. Find the first keyword in the list that has at least one more word than the query, then trim the keyword up to the end of that word.
  2. If there isn’t a keyword with more words, pick the keyword that forms the longest suffix of the query. This might be the query itself.