class TSS::Tries::Base
Main class for creating Aho-Corasick Trie
from array of words of dictionary
Attributes
dictionary[R]
Dictionary attribute
root[R]
Root vertex
trie[R]
Trie
attribute
Public Class Methods
new(dictionary, root_vertex)
click to toggle source
Initialize new trie and fill it with words from dictionary
Remarks:
-
dictioanry is array of characters
-
if indexing is important array should not be sorted
-
word from sentence may contain spaces and special characters, so one “word” can be the whole sentence
-
word can be an integer, but result will be converted to the string
Example:
>> TSS.new(["abc", "cde", 8, "ad f", "wer\nm"])
Arguments:
dictionary: (Array)
# File lib/tss/tries/base.rb, line 32 def initialize(dictionary, root_vertex) @root = root_vertex @dictionary = dictionary @trie = build_trie end
Private Instance Methods
build_trie()
click to toggle source
# File lib/tss/tries/base.rb, line 40 def build_trie @root end