Class: PragmaticSegmenter::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/pragmatic_segmenter/processor.rb

Overview

This class processing segmenting the text.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(language: Languages::Common) ⇒ Processor

Returns a new instance of Processor.



17
18
19
# File 'lib/pragmatic_segmenter/processor.rb', line 17

def initialize(language: Languages::Common)
  @language = language
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



16
17
18
# File 'lib/pragmatic_segmenter/processor.rb', line 16

def text
  @text
end

Instance Method Details

#process(text:) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pragmatic_segmenter/processor.rb', line 21

def process(text:)
  @text = List.new(text: text).add_line_break
  replace_abbreviations
  replace_numbers
  replace_continuous_punctuation
  replace_periods_before_numeric_references
  Rule.apply(@text, @language::Abbreviations::WithMultiplePeriodsAndEmailRule)
  Rule.apply(@text, @language::GeoLocationRule)
  Rule.apply(@text, @language::FileFormatRule)
  split_into_segments
end