Class: Srx::Engine
- Inherits:
-
Object
- Object
- Srx::Engine
- Defined in:
- lib/srx/engine.rb
Overview
Engine for performing SRX segmenting
Instance Attribute Summary collapse
- #data ⇒ Data readonly
Instance Method Summary collapse
-
#initialize(data, format: :text) ⇒ Engine
constructor
A new instance of Engine.
- #segment(str, language:) ⇒ Array<String>
Constructor Details
Instance Attribute Details
Instance Method Details
#segment(str, language:) ⇒ Array<String>
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/srx/engine.rb', line 19 def segment(str, language:) results = [] rules = rules(language) plain_text, markups = @format.extract_markups(str) pos = 0 breaks_by_pos(plain_text, rules).each do |break_pos, _| results << build_segment!(plain_text, markups, pos, break_pos) pos = break_pos end results end |