adjectifier 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,40 @@
1
1
  module Adjectifier
2
- def self.extract
3
- []
2
+ def self.extract(text, options = {})
3
+
4
+ adjectives = []
5
+
6
+ # single word sentences
7
+ single_words = %r{
8
+ \A
9
+ ([a-z]+)
10
+ [\.\?\!]?
11
+ \Z
12
+ }xi
13
+
14
+
15
+ # words following 'very'
16
+ very = %r{\bvery\s+([a-z]+)\b}xi
17
+
18
+ # First check to see if text consists of single words
19
+ single_words_match = text.scan(single_words)
20
+
21
+ if single_words_match.size > 0
22
+ single_words_match.each do |word|
23
+ word = word[0].downcase
24
+ adjectives << word unless adjectives.include?(word)
25
+ end
26
+
27
+ # If text doesn't contain just single words, continue on to do more complex searching.
28
+ else
29
+
30
+ text.scan(very) do |match|
31
+ word = match[0].downcase
32
+ adjectives << word unless adjectives.include?(word)
33
+ end
34
+
35
+ end
36
+
37
+
38
+ return adjectives
4
39
  end
5
40
  end
@@ -1,3 +1,3 @@
1
1
  module Adjectifier
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adjectifier
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Frankie Roberto