Class: TextRank::CharFilter::StripPossessive

Inherits:
Object
  • Object
show all
Defined in:
lib/text_rank/char_filter/strip_possessive.rb

Overview

Character filter to remove apostrophe from possessives.

= Example

StripPosessive.new.filter!("to loathe one's very being and yet to hold it fast") => "to loathe one very being and yet to hold it fast"

Instance Method Summary collapse

Instance Method Details

#filter!(text) ⇒ String

Perform the filter

Parameters:

  • text (String)

Returns:

  • (String)


16
17
18
19
20
# File 'lib/text_rank/char_filter/strip_possessive.rb', line 16

def filter!(text)
  text.gsub!(/([a-z]+)'s\b/) do
    Regexp.last_match(1)
  end
end