Sha256: 8589756fc8543ac54c8d75a13f1a78a05b5a56c2563bf9f5b727823ee118d19e
Contents?: true
Size: 600 Bytes
Versions: 2
Compression:
Stored size: 600 Bytes
Contents
# frozen_string_literal: true module CppjiebaRb # Sentence segmentation 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cppjieba_rb-0.4.4 | lib/cppjieba_rb/segment.rb |
cppjieba_rb-0.4.3 | lib/cppjieba_rb/segment.rb |