10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/mongoid_text_search/keyword_generator.rb', line 10
def clean_keywords(field)
clean_keywords = []
keywords = []
if field.is_a?(String)
keywords = field.squeeze(Separator).split(Separator)
elsif field.is_a?(Array)
keywords = field
end
for keyword in keywords
if keyword.is_a?(String)
clean_keyword = keyword.downcase
clean_keyword.strip!
clean_keyword.gsub!(StripPunctuationRegex, PunctuationReplacement)
if clean_keyword.size > 2 && !IgnoredWords.include?(clean_keyword) && !clean_keywords.include?(clean_keyword)
clean_keywords << clean_keyword
end
end
end
return clean_keywords
end
|