Class: TwitterCldr::Segmentation::WordIterator

Inherits:
SegmentIterator show all
Defined in:
lib/twitter_cldr/segmentation/word_iterator.rb

Constant Summary collapse

DICTIONARY_BREAK_ENGINES =
[
  CjBreakEngine,
  KoreanBreakEngine,
  BurmeseBreakEngine,
  KhmerBreakEngine,
  LaoBreakEngine,
  ThaiBreakEngine
]

Instance Attribute Summary

Attributes inherited from SegmentIterator

#rule_set

Instance Method Summary collapse

Methods inherited from SegmentIterator

#each_segment, #initialize

Constructor Details

This class inherits a constructor from TwitterCldr::Segmentation::SegmentIterator

Instance Method Details

#each_boundary(str, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/twitter_cldr/segmentation/word_iterator.rb', line 22

def each_boundary(str, &block)
  return to_enum(__method__, str) unless block_given?

  # Rather than put a bunch of duplicate logic in
  # each_boundary_helper to make sure we don't yield the same
  # boundary twice, we wrap it in this additional de-duping
  # enumerator and call it a day.
  last_boundary = nil

  each_boundary_helper(str) do |boundary|
    yield boundary if boundary != last_boundary
    last_boundary = boundary
  end
end