src/utils/bot-utils.js
/**
   * Makes an array of suggestions based on the similarity to the given string, sorts in the order of similarity.
   * @param  {string}        text                 the target text
   * @param  {Array<string>} availableSuggestions the array of available suggestions
   * @param  {number}        maxSuggestions       max number of suggestions to make
   * @return {Array<string>}                      the sorted array of suggestions
   */
Makes an array of suggestions based on the similarity to the given string, sorts in the order of similarity.
@param  {string}        text                 the target text
@param  {Array} availableSuggestions the array of available suggestions
@param  {number}        maxSuggestions       max number of suggestions to make
@return {Array}                      the sorted array of suggestions
Makes an array of suggestions based on the similarity to the given string sorts in the order of similarity . @param { string } text the target text @param { Array } availableSuggestions the array of available suggestions @param { number } maxSuggestions max number of suggestions to make @return { Array } the sorted array of suggestions
static makeSuggestions(text, availableSuggestions, maxSuggestions) {
    if (maxSuggestions === undefined || maxSuggestions <= 0) {
      maxSuggestions = DefaultMaxSuggestions;
    }
    const suggestions = [];
    const ratings = stringSimilarity.findBestMatch(text, availableSuggestions).ratings;
    ratings.sort((a, b) => (a.rating > b.rating ? -1 : b.rating > a.rating ? 1 : 0));
    for (let i = 0; i < maxSuggestions; i++) {
      suggestions.push(ratings[i].target);
    }
    return suggestions;
  }
static makeSuggestions ( text , availableSuggestions , maxSuggestions ) { if ( maxSuggestions === undefined || maxSuggestions <= 0 ) { maxSuggestions = DefaultMaxSuggestions ; } const suggestions = [ ] ; const ratings = stringSimilarity . findBestMatch ( text , availableSuggestions ) . ratings ; ratings . sort ( ( a , b ) => ( a . rating > b . rating ? - 1 : b . rating > a . rating ? 1 : 0 ) ) ; for ( let i = 0 ; i < maxSuggestions ; i ++ ) { suggestions . push ( ratings [ i ] . target ) ; } return suggestions ; }
Makes an array of suggestions based on the similarity to the given string, sorts in the order of similarity.
Makes an array of suggestions based on the similarity to the given string sorts in the order of similarity .