Ruby extension for Cppjieba
Add this line to your application's Gemfile:
gem 'jieba_rb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jieba_rb
Mix Segment mode (HMM with Max Prob, default):
require 'jieba_rb'
seg = JiebaRb::Segment.new # equivalent to "JiebaRb::Segment.new mode: :mix"
words = seg.cut "令狐冲是云计算行业的专家"
# 令狐冲 是 云 计算 行业 的 专家
Mix Segment mode with user-defined dictionary:
seg = JiebaRb::Segment.new mode: :mix, user_dict: "ext/cppjieba/dict/user.dict.utf8"
words = seg.cut "令狐冲是云计算行业的专家"
# 令狐冲 是 云计算 行业 的 专家
HMM or Max probability (mp) Segment mode:
seg = JiebaRb::Segment.new mode: :hmm # or mode: :mp
words = seg.cut "令狐冲是云计算行业的专家"
- Fork it ( http://github.com//jieba_rb/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request