Class: StyleScanner::TaggedWord
- Inherits:
-
Object
- Object
- StyleScanner::TaggedWord
- Defined in:
- lib/style_scanner/tagged_word.rb
Constant Summary collapse
- STRUCTURAL_TAGS =
TODO add tests for all the new methods added here.
%{ WRB WPS WP WDT UH TO SYM PRPS CC DET EX IN LS PDT POS PRP PRPS }
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#word ⇒ Object
readonly
Returns the value of attribute word.
Instance Method Summary collapse
- #adverb? ⇒ Boolean
- #be_verb? ⇒ Boolean
- #determiner? ⇒ Boolean
-
#gerund_verb? ⇒ Boolean
Gerund verb = ING verb.
-
#initialize(tag, word) ⇒ TaggedWord
constructor
A new instance of TaggedWord.
- #non_structural? ⇒ Boolean
- #noun? ⇒ Boolean
- #possessive? ⇒ Boolean
- #preposition? ⇒ Boolean
- #tokenized ⇒ Object
- #verb? ⇒ Boolean
Constructor Details
#initialize(tag, word) ⇒ TaggedWord
Returns a new instance of TaggedWord.
11 12 13 14 |
# File 'lib/style_scanner/tagged_word.rb', line 11 def initialize(tag, word) @tag = tag.upcase @word = word end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
9 10 11 |
# File 'lib/style_scanner/tagged_word.rb', line 9 def tag @tag end |
#word ⇒ Object (readonly)
Returns the value of attribute word.
9 10 11 |
# File 'lib/style_scanner/tagged_word.rb', line 9 def word @word end |
Instance Method Details
#adverb? ⇒ Boolean
20 21 22 |
# File 'lib/style_scanner/tagged_word.rb', line 20 def adverb? tag.start_with?("RB") end |
#be_verb? ⇒ Boolean
44 45 46 |
# File 'lib/style_scanner/tagged_word.rb', line 44 def be_verb? verb? && ["is", "was", "been", "be"].include?(tokenized) end |
#determiner? ⇒ Boolean
28 29 30 |
# File 'lib/style_scanner/tagged_word.rb', line 28 def determiner? tag.start_with?("DET") end |
#gerund_verb? ⇒ Boolean
Gerund verb = ING verb
53 54 55 |
# File 'lib/style_scanner/tagged_word.rb', line 53 def gerund_verb? tag == "VBG" && tokenized != "being" end |
#non_structural? ⇒ Boolean
32 33 34 |
# File 'lib/style_scanner/tagged_word.rb', line 32 def non_structural? ! STRUCTURAL_TAGS.include?(tag) end |
#noun? ⇒ Boolean
40 41 42 |
# File 'lib/style_scanner/tagged_word.rb', line 40 def noun? tag.start_with?("NN") end |
#possessive? ⇒ Boolean
36 37 38 |
# File 'lib/style_scanner/tagged_word.rb', line 36 def possessive? ["POS", "PRP", "PRPS"].include?(tag) end |
#preposition? ⇒ Boolean
24 25 26 |
# File 'lib/style_scanner/tagged_word.rb', line 24 def preposition? tag.start_with?("IN") end |
#tokenized ⇒ Object
16 17 18 |
# File 'lib/style_scanner/tagged_word.rb', line 16 def tokenized word.downcase.gsub(/\W/, "") end |
#verb? ⇒ Boolean
48 49 50 |
# File 'lib/style_scanner/tagged_word.rb', line 48 def verb? tag.start_with?("V") end |