Sha256: fa00d6be4ba478cf35ce562c0ce36d4cbab2478f3119dae12cacd9ade4c6d424
Contents?: true
Size: 825 Bytes
Versions: 26
Compression:
Stored size: 825 Bytes
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 module TwitterCldr module Segmentation class SegmentIterator attr_reader :rule_set def initialize(rule_set) @rule_set = rule_set end def each_segment(str) return to_enum(__method__, str) unless block_given? each_boundary(str).each_cons(2) do |start, stop| yield str[start...stop], start, stop end end def each_boundary(str, &block) return to_enum(__method__, str) unless block_given? # implicit start of text boundary yield 0 cursor = create_cursor(str) rule_set.each_boundary(cursor, &block) end private def create_cursor(str) Cursor.new(str) end end end end
Version data entries
26 entries across 26 versions & 1 rubygems