Last active
March 22, 2023 15:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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