Class: Krikri::Enrichments::StripEndingPunctuation
- Inherits:
-
Object
- Object
- Krikri::Enrichments::StripEndingPunctuation
- Includes:
- Audumbla::FieldEnrichment
- Defined in:
- lib/krikri/enrichments/strip_ending_punctuation.rb
Overview
Strip ending punctuation
StripEndingPunctuation.new
.enrich_value("moomin!...!;,.",)
# => "moomin"
Leaves quotation marks and closing parentheses & brackets. Also leaves periods when they follow a one or two letter abbreviation.
Instance Method Summary collapse
Instance Method Details
#enrich_value(value) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/krikri/enrichments/strip_ending_punctuation.rb', line 14 def enrich_value(value) return value unless value.is_a? String value.gsub!(/[^\p{Alnum}\'\"\)\]\}]*$/, '') unless value.match /\s+[a-z]{1,2}\.$/i value end |