2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/adjectifier.rb', line 2
def self.(text, options = {})
adjectives = []
single_words = %r{
\A
([a-z]+)
[\.\?\!]?
\Z
}xi
very = %r{\bvery\s+([a-z]+)\b}xi
single_words_match = text.scan(single_words)
if single_words_match.size > 0
single_words_match.each do |word|
word = word[0].downcase
adjectives << word unless adjectives.include?(word)
end
else
text.scan(very) do |match|
word = match[0].downcase
adjectives << word unless adjectives.include?(word)
end
end
return adjectives
end
|