class Marisa::Trie

Included Modules

Direct Known Subclasses

Defined in:

marisa/trie.cr

Constructors

Instance Method Summary

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

def self.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. @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

def <<(value) : self #

def 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


def add_many(keys : Array(String), weights : Array(Float32) = [] of Array(Float32)) #

def agent : Wrapper::Agent #

def build #

def build_if_necessary #

def built? : Bool #

def each(&block : String -> ) #
Description copied from module Enumerable(String)

Must yield this collection's elements to the block.


def get_id(key : String) : UInt64 | Nil #

def get_key(id : UInt64) : String | Nil #

def get_weight(key : String) : Float32 | Nil #

def has_keys? : Bool #

def include?(key : String) : Bool #

def keys : Array(String) #

def load(path : String) #

def save(path : String) #

def search(prefix : String = "") : Search #

def size : UInt64 #
Description copied from module Enumerable(String)

Returns the number of elements in the collection.

[1, 2, 3, 4].size # => 4

def trie : Wrapper::Trie #

Attribute reader for the trie