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
- #==(string) ⇒ Object
- #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
#==(string) ⇒ Object
16 17 18 |
# File 'lib/style_scanner/tagged_word.rb', line 16 def ==(string) word == string end |
#adverb? ⇒ Boolean
24 25 26 |
# File 'lib/style_scanner/tagged_word.rb', line 24 def adverb? tag.start_with?("RB") end |
#be_verb? ⇒ Boolean
48 49 50 |
# File 'lib/style_scanner/tagged_word.rb', line 48 def be_verb? verb? && ["is", "was", "been", "be"].include?(tokenized) end |
#determiner? ⇒ Boolean
32 33 34 |
# File 'lib/style_scanner/tagged_word.rb', line 32 def determiner? tag.start_with?("DET") end |
#gerund_verb? ⇒ Boolean
Gerund verb = ING verb
58 59 60 |
# File 'lib/style_scanner/tagged_word.rb', line 58 def gerund_verb? tag == "VBG" && tokenized != "being" end |
#non_structural? ⇒ Boolean
36 37 38 |
# File 'lib/style_scanner/tagged_word.rb', line 36 def non_structural? ! STRUCTURAL_TAGS.include?(tag) end |
#noun? ⇒ Boolean
44 45 46 |
# File 'lib/style_scanner/tagged_word.rb', line 44 def noun? tag.start_with?("NN") end |
#possessive? ⇒ Boolean
40 41 42 |
# File 'lib/style_scanner/tagged_word.rb', line 40 def possessive? ["POS", "PRP", "PRPS"].include?(tag) end |
#preposition? ⇒ Boolean
28 29 30 |
# File 'lib/style_scanner/tagged_word.rb', line 28 def preposition? tag.start_with?("IN") end |
#tokenized ⇒ Object
20 21 22 |
# File 'lib/style_scanner/tagged_word.rb', line 20 def tokenized word.downcase.gsub(/\W/, "") end |
#verb? ⇒ Boolean
52 53 54 55 |
# File 'lib/style_scanner/tagged_word.rb', line 52 def verb? # account for modal verbs like may tag.start_with?("V") || tag == "MD" end |