Class: TextRank::CharFilter::UndoContractions
- Inherits:
-
Object
- Object
- TextRank::CharFilter::UndoContractions
- Defined in:
- lib/text_rank/char_filter/undo_contractions.rb
Overview
Character filter to convert English contractions into their expanded form.
= Example
UndoContractions.new.filter!("You're a bitter man. That's because I've lived.") => "You are a bitter man. That is because I have lived."
Constant Summary collapse
- CONTRACTIONS =
List of English contractions to undo
YAML.load_file(File.('undo_contractions.yml', __dir__))
Instance Method Summary collapse
-
#filter!(text) ⇒ String
Perform the filter.
Instance Method Details
#filter!(text) ⇒ String
Perform the filter
19 20 21 22 23 |
# File 'lib/text_rank/char_filter/undo_contractions.rb', line 19 def filter!(text) text.gsub!(/[a-z']+/) do |word| CONTRACTIONS[word] || word end end |