Sha256: 3ca99fb552a18462d1673a8061f227546d04824a85232eae63a7f895839d1536

Contents?: true

Size: 542 Bytes

Versions: 9

Compression:

Stored size: 542 Bytes

Contents

module CppjiebaRb
  class Segment
    VALID_MODES = %i[mix hmm mp query full].freeze

    def initialize(opts = nil)
      opts ||= {}
      unless opts[:mode].nil? || VALID_MODES.include?(opts[:mode])
        raise ArgumentError, "The mode is #{opts[:mode]}. It should be one of :mix :hmm :mp"
      end

      @mode = opts[:mode] || :mix
      @max_word_length = opts[:max_word_length] || 8
      @hmm = opts[:hmm] || true
    end

    def segment(str)
      CppjiebaRb.internal.segment(str, @mode, @max_word_length, @hmm)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cppjieba_rb-0.4.2 lib/cppjieba_rb/segment.rb
cppjieba_rb-0.4.1 lib/cppjieba_rb/segment.rb
cppjieba_rb-0.4.0 lib/cppjieba_rb/segment.rb
cppjieba_rb-0.3.3 lib/cppjieba_rb/segment.rb
cppjieba_rb-0.3.1 lib/cppjieba_rb/segment.rb
cppjieba_rb-0.3.0 lib/cppjieba_rb/segment.rb
cppjieba_rb-0.2.3 lib/cppjieba_rb/segment.rb
cppjieba_rb-0.2.2 lib/cppjieba_rb/segment.rb
cppjieba_rb-0.2.1 lib/cppjieba_rb/segment.rb