Class: StyleScanner::Sentence
- Inherits:
-
Object
- Object
- StyleScanner::Sentence
- Extended by:
- Forwardable
- Defined in:
- lib/style_scanner/sentence.rb
Instance Attribute Summary collapse
-
#problems ⇒ Object
readonly
Returns the value of attribute problems.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #add_problem(problem) ⇒ Object
- #adverbs ⇒ Object
- #contains?(word, option_modifications = {}) ⇒ Boolean
- #find_problems_by_type(problem_type) ⇒ Object
-
#initialize(text) ⇒ Sentence
constructor
A new instance of Sentence.
- #tagged_words ⇒ Object
- #to_s ⇒ Object
- #user_friendly_readout ⇒ Object
- #with_problems? ⇒ Boolean
Constructor Details
#initialize(text) ⇒ Sentence
Returns a new instance of Sentence.
9 10 11 12 |
# File 'lib/style_scanner/sentence.rb', line 9 def initialize(text) @text = text @problems = [] end |
Instance Attribute Details
#problems ⇒ Object (readonly)
Returns the value of attribute problems.
7 8 9 |
# File 'lib/style_scanner/sentence.rb', line 7 def problems @problems end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/style_scanner/sentence.rb', line 7 def text @text end |
Instance Method Details
#add_problem(problem) ⇒ Object
38 39 40 |
# File 'lib/style_scanner/sentence.rb', line 38 def add_problem(problem) problems << problem end |
#adverbs ⇒ Object
22 23 24 |
# File 'lib/style_scanner/sentence.rb', line 22 def adverbs part_of_speech("RB") end |
#contains?(word, option_modifications = {}) ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/style_scanner/sentence.rb', line 26 def contains?(word, option_modifications = {}) = {:strip_case => true}.merge(option_modifications) text_to_scan = text text_to_scan = stemmed_verbs if [:stem_verbs] text_to_scan = text_to_scan.downcase if [:strip_case] text_to_scan.match(/\b#{word}\b/) end |
#find_problems_by_type(problem_type) ⇒ Object
14 15 16 |
# File 'lib/style_scanner/sentence.rb', line 14 def find_problems_by_type(problem_type) @problems.select {|problem| problem.class == problem_type} end |
#tagged_words ⇒ Object
18 19 20 |
# File 'lib/style_scanner/sentence.rb', line 18 def tagged_words tagger.tagged_words end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/style_scanner/sentence.rb', line 46 def to_s "Sentence Obj: text: #{text} problems: #{problems}" end |
#user_friendly_readout ⇒ Object
34 35 36 |
# File 'lib/style_scanner/sentence.rb', line 34 def user_friendly_readout problems.flatten.map(&:user_friendly_readout) if with_problems? end |
#with_problems? ⇒ Boolean
42 43 44 |
# File 'lib/style_scanner/sentence.rb', line 42 def with_problems? problems.any? end |