Skip to content

Instantly share code, notes, and snippets.

@lucivaldo
Last active March 22, 2023 15:47
Show Gist options
  • Save lucivaldo/47853689945fdddcb94cfb4d323d70c5 to your computer and use it in GitHub Desktop.
Save lucivaldo/47853689945fdddcb94cfb4d323d70c5 to your computer and use it in GitHub Desktop.
Função para converter texto em um array de textos para buscas fuzzy
def text_to_fuzzy_search(text)
first_word, *rest_words = text.split
rest_words_chars = rest_words.map { _1.split('') }
search = first_word.dup
array = [search]
rest_words_chars.each do |chars|
search += " "
chars.each do |ch|
search << ch
array << search.dup
end
end
array
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment