Module: CppjiebaRb

Defined in:
lib/cppjieba_rb.rb,
lib/cppjieba_rb/segment.rb,
lib/cppjieba_rb/version.rb,
ext/cppjieba_rb/cppjieba_rb.c

Defined Under Namespace

Classes: Segment

Constant Summary collapse

EXT_BASE =
File.join(File.dirname(__FILE__), '..', 'ext', 'cppjieba', 'dict')
DICT_PATH =
File.join(EXT_BASE, 'jieba.dict.utf8')
HMM_DICT_PATH =
File.join(EXT_BASE, 'hmm_model.utf8')
USER_DICT =
File.join(EXT_BASE, 'user.dict.utf8')
IDF_PATH =
File.join(EXT_BASE, 'idf.utf8')
STOP_WORD_PATH =
File.join(EXT_BASE, 'stop_words.utf8')
VERSION =
'0.3.1'

Class Method Summary collapse

Class Method Details

.extract_keyword(str, top_n) ⇒ Object



13
14
15
# File 'lib/cppjieba_rb.rb', line 13

def self.extract_keyword(str, top_n)
  internal.extract_keyword(str, top_n)
end

.filter_stop_word(arr) ⇒ Object



25
26
27
# File 'lib/cppjieba_rb.rb', line 25

def self.filter_stop_word(arr)
  arr.reject { |w| internal.stop_word?(w) }
end

.internalObject



30
31
32
33
34
35
36
# File 'lib/cppjieba_rb.rb', line 30

def internal
  @backend ||= CppjiebaRb::Internal.new(DICT_PATH,
                                        HMM_DICT_PATH,
                                        USER_DICT,
                                        IDF_PATH,
                                        STOP_WORD_PATH)
end

.segment(str, opts = nil) ⇒ Object



17
18
19
# File 'lib/cppjieba_rb.rb', line 17

def self.segment(str, opts = nil)
  CppjiebaRb::Segment.new(opts).segment(str)
end

.segment_tag(str) ⇒ Object



21
22
23
# File 'lib/cppjieba_rb.rb', line 21

def self.segment_tag(str)
  internal.segment_tag(str)
end