Sha256: d7c0dec00cd0f56076dd7742705aa28ea91271ec45dd196be3ebe97029957d43
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# encoding: utf-8 require "harmonious_dictionary/rseg" require "harmonious_dictionary/version" require "harmonious_dictionary/model_additions" require "harmonious_dictionary/railtie" if defined? Rails module HarmoniousDictionary def self.clean?(input) results = HarmoniousDictionary::Rseg.segment(input) results.size > 0 ? false : true end def self.clean_by_remote?(input) results = HarmoniousDictionary::Rseg.remote_segment(input) results.size > 0 ? false : true end def self.clean_by_remote(input) results = HarmoniousDictionary::Rseg.remote_segment(input) results.each do |result| encode_result = result.force_encoding('utf-8') input.gsub! /#{encode_result}/,self.clean_word_basic(encode_result) end input end def self.clean(input) results = HarmoniousDictionary::Rseg.segment(input) results.each{|result| input.gsub! /#{result}/,self.clean_word_basic(result) } input end def self.harmonious_words(input) return HarmoniousDictionary::Rseg.segment(input) end def self.clean_word_basic(word) clearn_words = "" word.size.times{ clearn_words << "*" } clearn_words end def self.chinese_harmonious Rseg.instance.send(:engines).first.dictionary end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
harmonious_dictionary-0.0.1 | lib/harmonious_dictionary.rb |