Class: PresentReplacer
- Inherits:
-
Object
- Object
- PresentReplacer
- Defined in:
- lib/story_time/present_finder.rb
Instance Method Summary collapse
- #find(str) ⇒ Object
-
#initialize ⇒ PresentReplacer
constructor
A new instance of PresentReplacer.
- #replace(text, replacements = {}) ⇒ Object
Constructor Details
#initialize ⇒ PresentReplacer
Returns a new instance of PresentReplacer.
3 4 5 |
# File 'lib/story_time/present_finder.rb', line 3 def initialize() @tgr = ::EngTagger.new end |
Instance Method Details
#find(str) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/story_time/present_finder.rb', line 7 def find(str) tagged = @tgr.(str) present_verbs = @tgr.get_present_verbs(tagged).keys infinitive_verbs = @tgr.get_infinitive_verbs(tagged).keys base_present_verbs = @tgr.get_base_present_verbs(tagged).keys {}.tap do |hs| present_verbs.each do |verb| hs[verb] = verb.verb.conjugate tense: :past, aspect: :perfective, mood: :subjunctive end base_present_verbs.each do |verb| hs[verb] = verb.verb.conjugate tense: :past, aspect: :perfective, mood: :subjunctive end infinitive_verbs.each do |verb| hs[verb] = verb.verb.conjugate tense: :past, aspect: :perfective, mood: :subjunctive end end end |
#replace(text, replacements = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/story_time/present_finder.rb', line 25 def replace(text, replacements = {}) replaced = text.dup replacements.keys.each do |rep| replaced.gsub!(rep, replacements[rep]) end replaced end |