Class: JiebaRb::Keyword
- Inherits:
-
Object
- Object
- JiebaRb::Keyword
- Defined in:
- lib/jieba-rb.rb
Constant Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Keyword
constructor
A new instance of Keyword.
Constructor Details
#initialize(opts = {}) ⇒ Keyword
Returns a new instance of Keyword.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jieba-rb.rb', line 35 def initialize opts = {} valid_modes = [:tf_idf] if mode = opts[:mode] raise "Mode must be one of :tf_idf" unless valid_modes.include? mode else mode = :tf_idf #default end jieba_dict = opts[:jieba_dict] || DEFAULT_JIEBA_DICT hmm_dict = opts[:hmm_dict] || DEFAULT_HMM_DICT idf_path = opts[:idf] || DEFAULT_IDF stop_words_path = opts[:stop_words] || DEFAULT_STOP_WORDS user_dict = opts[:user_dict] || "" user_dict = DEFAULT_USER_DICT if user_dict == :default _init mode, jieba_dict, hmm_dict, idf_path, stop_words_path, user_dict end |