Module: Ucode::Coordinator::Enrichment::Segmentation

Defined in:
lib/ucode/coordinator/enrichment/segmentation.rb

Overview

UAX #29 text segmentation: Grapheme / Word / Sentence break class.

Class Method Summary collapse

Class Method Details

.enrich(cp, indices) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/ucode/coordinator/enrichment/segmentation.rb', line 9

def enrich(cp, indices)
  grapheme = lookup_value(cp, indices.grapheme_break)
  word = lookup_value(cp, indices.word_break)
  sentence = lookup_value(cp, indices.sentence_break)
  return if grapheme.nil? && word.nil? && sentence.nil?

  cp.break_segmentation ||= Ucode::Models::CodePoint::BreakSegmentation.new
  apply_values(cp.break_segmentation, grapheme, word, sentence)
end