class Marisa::Trie
- Marisa::Trie
- Reference
- Object
Included Modules
- Enumerable(String)
- Marisa::BaseConfigFlags
Direct Known Subclasses
Defined in:
marisa/trie.crConstructors
-
.new(keys = [] of String, weights = [] of Float32, binary : Bool = false, num_tries : Symbol | Int32 = :default, cache_size : Symbol = :normal, order : Symbol = :label)
Initialize a BaseTrie.
Instance Method Summary
- #<<(value) : self
-
#add(key : String, weight : Int32 | Nil = nil)
Note: weight is not the same thing as a value! Use a BytesTrie or IntTrie subclass if you want a key/value dictionary
- #add_many(keys : Array(String), weights : Array(Float32) = [] of Array(Float32))
- #agent : Wrapper::Agent
- #build
- #build_if_necessary
- #built? : Bool
-
#each(&block : String -> )
Must yield this collection's elements to the block.
- #get_id(key : String) : UInt64 | Nil
- #get_key(id : UInt64) : String | Nil
- #get_weight(key : String) : Float32 | Nil
- #has_keys? : Bool
- #include?(key : String) : Bool
- #keys : Array(String)
- #load(path : String)
- #save(path : String)
- #search(prefix : String = "") : Search
-
#size : UInt64
Returns the number of elements in the collection.
-
#trie : Wrapper::Trie
Attribute reader for the trie
Instance methods inherited from module Marisa::BaseConfigFlags
binary_flag(bool : Bool) : Int32
binary_flag,
config_flags(binary = false, num_tries = :default, cache_size = :default, order = :default)
config_flags,
lookup_cache_size(cache_size : Symbol) : Int32
lookup_cache_size,
valid_node_order(order : Symbol) : Int32
valid_node_order,
valid_num_tries(num_tries : Int32 | Symbol) : Int32
valid_num_tries
Constructor Detail
Initialize a BaseTrie. @keys An array of UTF-8 strings @weights An array of corresponding weights @opts :binary Boolean, true for a binary Trie, false for text :num_tries An integer from 1 to 127 representing the depth of recursive Tries :cache_size One of [:tiny, :small, :normal, :large, :huge] :order One of [:label, :weight]
Instance Method Detail
Note: weight is not the same thing as a value! Use a BytesTrie or IntTrie subclass if you want a key/value dictionary
Must yield this collection's elements to the block.
Returns the number of elements in the collection.
[1, 2, 3, 4].size # => 4