Sha256: 62a1308c0421821324af01b441a5a5299fb5b65da488e61d3aa8f4cc62056a42
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
module RMMSeg module Dictionary @dictionaries = [ [:chars, File.join(File.dirname(__FILE__), "..", "..", "data", "chars.dic")], [:words, File.join(File.dirname(__FILE__), "..", "..", "data", "words.dic")] ] class << self # # An array of dictionaries used by RMMSeg. Each entry is of the # following form: # # [type, path] # # where +type+ can either <tt>:chars</tt> or <tt>:words</tt>. +path+ is the path # to the dictionary file. # # The format of <tt>:chars</tt> dictionary is a collection of lines of the # following form: # # freq char # # Where +frequency+ is a number <b>less than 65535</b>. +char+ is the # character. They are spearated by <b>exactly one space</b>. # # The format of <tt>:words</tt> dictionary is similar: # # length word # # except the first number is not the frequency, but the number of # characters (not number of bytes) in the word. # attr_accessor :dictionaries # Add a user defined dictionary, +type+ can be # +:chars+ or <tt>:words</tt>. See doc of dictionaries. def add_dictionary(path, type) @dictionaries << [type, path] end def load_dictionaries @dictionaries.each do |type, path| if type == :chars load_chars(path) elsif type == :words load_words(path) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pluskid-rmmseg-cpp-0.2.0 | lib/rmmseg/dictionary.rb |
pluskid-rmmseg-cpp-0.2.1 | lib/rmmseg/dictionary.rb |
pluskid-rmmseg-cpp-0.2.2 | lib/rmmseg/dictionary.rb |