rambling-trie 2.4.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +28 -0
- data/Gemfile +20 -8
- data/Guardfile +16 -5
- data/README.md +38 -32
- data/Rakefile +6 -0
- data/Steepfile +35 -0
- data/lib/rambling/trie/comparable.rb +2 -2
- data/lib/rambling/trie/compressible.rb +1 -1
- data/lib/rambling/trie/compressor.rb +22 -19
- data/lib/rambling/trie/configuration/properties.rb +10 -6
- data/lib/rambling/trie/configuration/provider_collection.rb +14 -9
- data/lib/rambling/trie/configuration.rb +2 -3
- data/lib/rambling/trie/container.rb +32 -24
- data/lib/rambling/trie/enumerable.rb +5 -6
- data/lib/rambling/trie/nodes/compressed.rb +26 -16
- data/lib/rambling/trie/nodes/node.rb +35 -12
- data/lib/rambling/trie/nodes/raw.rb +18 -20
- data/lib/rambling/trie/nodes.rb +2 -3
- data/lib/rambling/trie/readers/plain_text.rb +3 -3
- data/lib/rambling/trie/readers.rb +2 -3
- data/lib/rambling/trie/serializers/file.rb +1 -3
- data/lib/rambling/trie/serializers/marshal.rb +4 -4
- data/lib/rambling/trie/serializers/yaml.rb +3 -3
- data/lib/rambling/trie/serializers/zip.rb +13 -5
- data/lib/rambling/trie/serializers.rb +2 -3
- data/lib/rambling/trie/stringifyable.rb +1 -1
- data/lib/rambling/trie/version.rb +1 -1
- data/lib/rambling/trie.rb +12 -15
- data/rambling-trie.gemspec +4 -10
- data/sig/lib/rambling/trie/comparable.rbs +17 -0
- data/sig/lib/rambling/trie/compressible.rbs +17 -0
- data/sig/lib/rambling/trie/compressor.rbs +17 -0
- data/sig/lib/rambling/trie/configuration/properties.rbs +28 -0
- data/sig/lib/rambling/trie/configuration/provider_collection.rbs +47 -0
- data/sig/lib/rambling/trie/container.rbs +69 -0
- data/sig/lib/rambling/trie/enumerable.rbs +23 -0
- data/sig/lib/rambling/trie/inspectable.rbs +27 -0
- data/sig/lib/rambling/trie/invalid_operation.rbs +7 -0
- data/sig/lib/rambling/trie/nodes/compressed.rbs +25 -0
- data/sig/lib/rambling/trie/nodes/missing.rbs +9 -0
- data/sig/lib/rambling/trie/nodes/node.rbs +69 -0
- data/sig/lib/rambling/trie/nodes/raw.rbs +27 -0
- data/sig/lib/rambling/trie/readers/plain_text.rbs +9 -0
- data/sig/lib/rambling/trie/readers/reader.rbs +9 -0
- data/sig/lib/rambling/trie/serializers/file.rbs +8 -0
- data/sig/lib/rambling/trie/serializers/marshal.rbs +13 -0
- data/sig/lib/rambling/trie/serializers/serializer.rbs +10 -0
- data/sig/lib/rambling/trie/serializers/yaml.rbs +13 -0
- data/sig/lib/rambling/trie/serializers/zip.rbs +21 -0
- data/sig/lib/rambling/trie/stringifyable.rbs +21 -0
- data/sig/lib/rambling/trie.rbs +27 -0
- data/sig/lib/zip/entry.rbs +11 -0
- data/sig/lib/zip/file.rbs +11 -0
- metadata +34 -123
- data/spec/assets/test_words.en_US.txt +0 -23
- data/spec/assets/test_words.es_DO.txt +0 -24
- data/spec/integration/rambling/trie_spec.rb +0 -116
- data/spec/lib/rambling/trie/comparable_spec.rb +0 -87
- data/spec/lib/rambling/trie/compressor_spec.rb +0 -111
- data/spec/lib/rambling/trie/configuration/properties_spec.rb +0 -75
- data/spec/lib/rambling/trie/configuration/provider_collection_spec.rb +0 -177
- data/spec/lib/rambling/trie/container_spec.rb +0 -466
- data/spec/lib/rambling/trie/enumerable_spec.rb +0 -50
- data/spec/lib/rambling/trie/inspectable_spec.rb +0 -62
- data/spec/lib/rambling/trie/nodes/compressed_spec.rb +0 -43
- data/spec/lib/rambling/trie/nodes/node_spec.rb +0 -9
- data/spec/lib/rambling/trie/nodes/raw_spec.rb +0 -184
- data/spec/lib/rambling/trie/readers/plain_text_spec.rb +0 -26
- data/spec/lib/rambling/trie/readers/reader_spec.rb +0 -14
- data/spec/lib/rambling/trie/serializers/file_spec.rb +0 -11
- data/spec/lib/rambling/trie/serializers/marshal_spec.rb +0 -10
- data/spec/lib/rambling/trie/serializers/serializer_spec.rb +0 -21
- data/spec/lib/rambling/trie/serializers/yaml_spec.rb +0 -10
- data/spec/lib/rambling/trie/serializers/zip_spec.rb +0 -36
- data/spec/lib/rambling/trie/stringifyable_spec.rb +0 -89
- data/spec/lib/rambling/trie_spec.rb +0 -244
- data/spec/spec_helper.rb +0 -42
- data/spec/support/config.rb +0 -15
- data/spec/support/helpers/add_word.rb +0 -20
- data/spec/support/helpers/one_line_heredoc.rb +0 -11
- data/spec/support/shared_examples/a_compressible_trie.rb +0 -46
- data/spec/support/shared_examples/a_container_partial_word.rb +0 -17
- data/spec/support/shared_examples/a_container_scan.rb +0 -14
- data/spec/support/shared_examples/a_container_word.rb +0 -43
- data/spec/support/shared_examples/a_container_words_within.rb +0 -44
- data/spec/support/shared_examples/a_serializable_trie.rb +0 -26
- data/spec/support/shared_examples/a_serializer.rb +0 -60
- data/spec/support/shared_examples/a_trie_data_structure.rb +0 -45
- data/spec/support/shared_examples/a_trie_node.rb +0 -135
- data/spec/support/shared_examples/a_trie_node_implementation.rb +0 -149
- data/spec/tmp/.gitkeep +0 -0
data/lib/rambling/trie.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
path = File.join 'rambling', 'trie'
|
3
4
|
%w(
|
4
5
|
comparable compressible compressor configuration container enumerable inspectable invalid_operation
|
5
6
|
readers serializers stringifyable nodes version
|
6
|
-
).each
|
7
|
-
require File.join('rambling', 'trie', file)
|
8
|
-
end
|
7
|
+
).each { |file| require File.join(path, file) }
|
9
8
|
|
10
9
|
# General namespace for all Rambling gems.
|
11
10
|
module Rambling
|
12
|
-
# Entry point for
|
11
|
+
# Entry point for `rambling-trie` API.
|
13
12
|
module Trie
|
14
13
|
class << self
|
15
|
-
# Creates a new
|
14
|
+
# Creates a new `Rambling::Trie`. Entry point for the `rambling-trie` API.
|
16
15
|
# @param [String, nil] filepath the file to load the words from.
|
17
16
|
# @param [Readers::Reader, nil] reader the file parser to get each word.
|
18
17
|
# @return [Container] the trie just created.
|
@@ -26,9 +25,7 @@ module Rambling
|
|
26
25
|
if filepath
|
27
26
|
reader ||= readers.resolve filepath
|
28
27
|
# noinspection RubyMismatchedArgumentType,RubyNilAnalysis
|
29
|
-
reader.each_word
|
30
|
-
container << word
|
31
|
-
end
|
28
|
+
(reader || raise).each_word(filepath) { |word| container << word }
|
32
29
|
end
|
33
30
|
|
34
31
|
yield container if block_given?
|
@@ -37,18 +34,18 @@ module Rambling
|
|
37
34
|
|
38
35
|
# Loads an existing trie from disk into memory. By default, it will
|
39
36
|
# deduce the correct way to deserialize based on the file extension.
|
40
|
-
# Available formats are
|
37
|
+
# Available formats are `yml`, `marshal`, and `zip` versions of all the
|
41
38
|
# previous formats. You can also define your own.
|
42
39
|
# @param [String] filepath the file to load the words from.
|
43
40
|
# @param [Serializer, nil] serializer the object responsible of loading the trie from disk.
|
44
41
|
# @return [Container] the trie just loaded.
|
45
42
|
# @yield [Container] the trie just loaded.
|
46
43
|
# @see Rambling::Trie::Serializers Serializers.
|
47
|
-
# @note Use of # {https://ruby-doc.org/
|
48
|
-
# discouraged. Only use the
|
44
|
+
# @note Use of # {https://ruby-doc.org/3.3.0/Marshal.html#method-c-load Marshal.load} is generally
|
45
|
+
# discouraged. Only use the `.marshal` format with trusted input.
|
49
46
|
def load filepath, serializer = nil
|
50
47
|
serializer ||= serializers.resolve filepath
|
51
|
-
root = serializer.load filepath
|
48
|
+
root = (serializer || raise).load filepath
|
52
49
|
Rambling::Trie::Container.new root, compressor do |container|
|
53
50
|
yield container if block_given?
|
54
51
|
end
|
@@ -56,7 +53,7 @@ module Rambling
|
|
56
53
|
|
57
54
|
# Dumps an existing trie from memory into disk. By default, it will
|
58
55
|
# deduce the correct way to serialize based on the file extension.
|
59
|
-
# Available formats are
|
56
|
+
# Available formats are `yml`, `marshal`, and `zip` versions of all the
|
60
57
|
# previous formats. You can also define your own.
|
61
58
|
# @param [Container] trie the trie to dump into disk.
|
62
59
|
# @param [String] filepath the file to dump to serialized trie into.
|
@@ -66,10 +63,10 @@ module Rambling
|
|
66
63
|
def dump trie, filepath, serializer = nil
|
67
64
|
serializer ||= serializers.resolve filepath
|
68
65
|
# noinspection RubyNilAnalysis
|
69
|
-
serializer.dump trie.root, filepath
|
66
|
+
(serializer || raise).dump trie.root, filepath
|
70
67
|
end
|
71
68
|
|
72
|
-
# Provides configuration properties for the
|
69
|
+
# Provides configuration properties for the `Rambling::Trie` gem.
|
73
70
|
# @return [Configuration::Properties] the configured properties of the gem.
|
74
71
|
# @yield [Configuration::Properties] the configured properties of the gem.
|
75
72
|
def config
|
data/rambling-trie.gemspec
CHANGED
@@ -14,28 +14,22 @@ Gem::Specification.new do |gem|
|
|
14
14
|
|
15
15
|
gem.summary = 'A Ruby implementation of the trie data structure.'
|
16
16
|
gem.homepage = 'https://github.com/gonzedge/rambling-trie'
|
17
|
-
gem.date = Time.now.strftime '%Y-%m-%d'
|
18
17
|
gem.metadata = {
|
19
|
-
'changelog_uri' => 'https://github.com/gonzedge/rambling-trie/blob/
|
18
|
+
'changelog_uri' => 'https://github.com/gonzedge/rambling-trie/blob/main/CHANGELOG.md',
|
20
19
|
'documentation_uri' => 'https://www.rubydoc.info/gems/rambling-trie',
|
20
|
+
'rubygems_mfa_required' => 'true',
|
21
21
|
}
|
22
22
|
|
23
23
|
executables = `git ls-files -- bin/*`.split "\n"
|
24
|
-
files = `git ls-files -- {lib,*file,*.gemspec,LICENSE*,README*}`.split "\n"
|
25
|
-
test_files = `git ls-files -- {test,spec,features}/*`.split "\n"
|
24
|
+
files = `git ls-files -- {lib,sig,*file,*.gemspec,LICENSE*,README*}`.split "\n"
|
26
25
|
|
27
26
|
gem.executables = executables.map { |f| File.basename f }
|
28
27
|
gem.files = files
|
29
|
-
gem.test_files = test_files
|
30
28
|
gem.require_paths = %w(lib)
|
31
29
|
|
32
30
|
gem.name = 'rambling-trie'
|
33
31
|
gem.license = 'MIT'
|
34
32
|
gem.version = Rambling::Trie::VERSION
|
35
33
|
gem.platform = Gem::Platform::RUBY
|
36
|
-
gem.required_ruby_version = '>=
|
37
|
-
|
38
|
-
gem.add_development_dependency 'rake', '~> 13.1'
|
39
|
-
gem.add_development_dependency 'rspec', '~> 3.12'
|
40
|
-
gem.add_development_dependency 'yard', '~> 0.9.34'
|
34
|
+
gem.required_ruby_version = '>= 3.1', '< 4'
|
41
35
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Comparable
|
4
|
+
def ==: (Nodes::Node) -> bool
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
# abstract methods
|
9
|
+
|
10
|
+
def letter: -> Symbol
|
11
|
+
|
12
|
+
def terminal?: -> bool
|
13
|
+
|
14
|
+
def children_tree: -> Hash[Symbol, Nodes::Node]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
class Compressor
|
4
|
+
def compress: (Nodes::Node?) -> Nodes::Compressed?
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def compress_only_child_and_merge: (Nodes::Node) -> Nodes::Compressed
|
9
|
+
|
10
|
+
def merge: (Nodes::Node, Nodes::Node) -> Nodes::Compressed
|
11
|
+
|
12
|
+
def compress_children_and_copy: (Nodes::Node) -> Nodes::Compressed
|
13
|
+
|
14
|
+
def compress_children: (Hash[Symbol, Nodes::Node]) -> Hash[Symbol, Nodes::Node]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Configuration
|
4
|
+
class Properties
|
5
|
+
attr_reader readers: ProviderCollection[Readers::Reader]
|
6
|
+
attr_reader serializers: ProviderCollection[Serializers::Serializer[Nodes::Node]]
|
7
|
+
attr_accessor compressor: Compressor
|
8
|
+
attr_accessor root_builder: ^() -> Nodes::Node
|
9
|
+
attr_accessor tmp_path: String
|
10
|
+
|
11
|
+
def initialize: -> void
|
12
|
+
|
13
|
+
def reset: -> void
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_writer readers: ProviderCollection[Readers::Reader]
|
18
|
+
attr_writer serializers: ProviderCollection[Serializers::Serializer[Nodes::Node]]
|
19
|
+
|
20
|
+
def reset_readers: -> void
|
21
|
+
|
22
|
+
def default_reader_providers: -> Hash[Symbol, Readers::Reader]
|
23
|
+
|
24
|
+
def reset_serializers: -> void
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Configuration
|
4
|
+
class ProviderCollection[TProvider < _Nilable]
|
5
|
+
interface _Nilable
|
6
|
+
def nil?: -> bool
|
7
|
+
end
|
8
|
+
|
9
|
+
@providers: Hash[Symbol, TProvider]
|
10
|
+
|
11
|
+
attr_reader name: Symbol
|
12
|
+
attr_reader default: TProvider?
|
13
|
+
|
14
|
+
def initialize: (Symbol, Hash[Symbol, TProvider], ?TProvider?) -> void
|
15
|
+
|
16
|
+
def []: (Symbol) -> TProvider
|
17
|
+
|
18
|
+
def add: (Symbol, TProvider) -> TProvider
|
19
|
+
|
20
|
+
def default=: (TProvider?) -> TProvider?
|
21
|
+
|
22
|
+
def formats: -> Array[Symbol]
|
23
|
+
|
24
|
+
def providers: -> Hash[Symbol, TProvider]
|
25
|
+
|
26
|
+
def reset: -> void
|
27
|
+
|
28
|
+
def resolve: (String) -> TProvider?
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader configured_default: TProvider?
|
33
|
+
attr_reader configured_providers: Hash[Symbol, TProvider]
|
34
|
+
|
35
|
+
def []=: (Symbol, TProvider) -> TProvider
|
36
|
+
|
37
|
+
def values: -> Array[TProvider]
|
38
|
+
|
39
|
+
def file_format: (String) -> Symbol
|
40
|
+
|
41
|
+
def contains?: (TProvider?) -> bool
|
42
|
+
|
43
|
+
alias provider_instances values
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
class Container
|
4
|
+
include ::Enumerable[String]
|
5
|
+
|
6
|
+
@compressor: Compressor
|
7
|
+
|
8
|
+
attr_reader root: Nodes::Node
|
9
|
+
|
10
|
+
def initialize: (Nodes::Node, Compressor) ?{ (Container) -> void } -> void
|
11
|
+
|
12
|
+
def add: (String) -> Nodes::Node
|
13
|
+
|
14
|
+
def concat: (Array[String]) -> Array[Nodes::Node]
|
15
|
+
|
16
|
+
def compress!: -> Container
|
17
|
+
|
18
|
+
def compress: -> Container
|
19
|
+
|
20
|
+
def each: { (String) -> void } -> (Enumerator[String, void] | Enumerable)
|
21
|
+
|
22
|
+
def partial_word?: (String) -> bool
|
23
|
+
|
24
|
+
def push: (*String) -> Array[Nodes::Node]
|
25
|
+
|
26
|
+
def word?: (String) -> bool
|
27
|
+
|
28
|
+
def scan: (String) -> Array[String]
|
29
|
+
|
30
|
+
def words_within: (String) -> Array[String]
|
31
|
+
|
32
|
+
def words_within?: (String) -> bool
|
33
|
+
|
34
|
+
def ==: (Container) -> bool
|
35
|
+
|
36
|
+
def []: (Symbol) -> Nodes::Node
|
37
|
+
|
38
|
+
def children: -> Array[Nodes::Node]
|
39
|
+
|
40
|
+
def children_tree: -> Hash[Symbol, Nodes::Node]
|
41
|
+
|
42
|
+
def compressed?: -> bool
|
43
|
+
|
44
|
+
def to_a: -> Array[String]
|
45
|
+
|
46
|
+
def key?: (Symbol) -> bool
|
47
|
+
|
48
|
+
def size: -> Numeric
|
49
|
+
|
50
|
+
alias include? word?
|
51
|
+
alias match? partial_word?
|
52
|
+
alias words? scan
|
53
|
+
alias << add
|
54
|
+
alias has_key? key?
|
55
|
+
alias has_letter? key?
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
attr_reader compressor: Compressor
|
60
|
+
attr_writer root: Nodes::Node
|
61
|
+
|
62
|
+
def words_within_root: (String) ?{ (String) -> void } -> Enumerator[String, void]
|
63
|
+
|
64
|
+
def compress_root: -> Nodes::Compressed
|
65
|
+
|
66
|
+
def reversed_char_symbols: (String) -> Array[Symbol]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Enumerable
|
4
|
+
include ::Enumerable[String]
|
5
|
+
|
6
|
+
EMPTY_ENUMERATOR: Enumerator[String, void]
|
7
|
+
|
8
|
+
alias size count
|
9
|
+
|
10
|
+
def each: { (String) -> void } -> (Enumerator[String, void] | Enumerable)
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
# abstract methods
|
15
|
+
|
16
|
+
def as_word: -> String
|
17
|
+
|
18
|
+
def terminal?: -> bool
|
19
|
+
|
20
|
+
def children_tree: -> Hash[Symbol, Nodes::Node]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Inspectable
|
4
|
+
def inspect: -> String
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def class_name: -> String?
|
9
|
+
|
10
|
+
def attributes: -> String
|
11
|
+
|
12
|
+
def letter_inspect: -> String
|
13
|
+
|
14
|
+
def terminal_inspect: -> String
|
15
|
+
|
16
|
+
def children_inspect: -> String
|
17
|
+
|
18
|
+
# abstract methods
|
19
|
+
|
20
|
+
def letter: -> Symbol
|
21
|
+
|
22
|
+
def terminal: -> bool?
|
23
|
+
|
24
|
+
def children_tree: -> Hash[Symbol, Nodes::Node]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Nodes
|
4
|
+
class Compressed < Node
|
5
|
+
def initialize: (?Symbol?, ?Node?, ?Hash[Symbol, Node]) -> void
|
6
|
+
|
7
|
+
def add: (Array[Symbol]) -> Node
|
8
|
+
|
9
|
+
def compressed?: -> bool
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# overrides
|
14
|
+
|
15
|
+
def children_match_prefix: (Array[String]) { (String) -> void } -> Enumerator[String, void]
|
16
|
+
|
17
|
+
def partial_word_chars?: (Array[String]) -> bool
|
18
|
+
|
19
|
+
def word_chars?: (Array[String]) -> bool
|
20
|
+
|
21
|
+
def closest_node: (Array[String]) -> Node
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Nodes
|
4
|
+
class Node
|
5
|
+
include Compressible
|
6
|
+
include Enumerable
|
7
|
+
include Comparable
|
8
|
+
include Stringifyable
|
9
|
+
include Inspectable
|
10
|
+
|
11
|
+
attr_reader letter: Symbol?
|
12
|
+
attr_accessor children_tree: Hash[Symbol, Node]
|
13
|
+
attr_accessor parent: Node?
|
14
|
+
|
15
|
+
def initialize: (?Symbol?, ?Node?, ?Hash[Symbol, Node]) -> void
|
16
|
+
|
17
|
+
def add: (Array[Symbol]) -> Node
|
18
|
+
|
19
|
+
def children: -> Array[Node]
|
20
|
+
|
21
|
+
def first_child: -> Node?
|
22
|
+
|
23
|
+
def match_prefix: (Array[String]) { (String) -> void } -> Enumerator[String, void]
|
24
|
+
|
25
|
+
def root?: -> bool
|
26
|
+
|
27
|
+
def scan: (Array[String]) -> Node
|
28
|
+
|
29
|
+
def terminal?: -> bool
|
30
|
+
|
31
|
+
def terminal!: -> Node
|
32
|
+
|
33
|
+
def letter=: (String | Symbol?) -> Symbol?
|
34
|
+
|
35
|
+
def compressed?: -> bool
|
36
|
+
|
37
|
+
def partial_word?: (Array[String]) -> bool
|
38
|
+
|
39
|
+
def word?: (Array[String]) -> bool
|
40
|
+
|
41
|
+
def []: (Symbol) -> Node
|
42
|
+
|
43
|
+
def []=: (Symbol, Node) -> Node
|
44
|
+
|
45
|
+
def key?: (Symbol) -> bool
|
46
|
+
|
47
|
+
def delete: (Symbol) -> Node?
|
48
|
+
|
49
|
+
alias has_key? key?
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
attr_accessor terminal: bool?
|
54
|
+
|
55
|
+
def missing: -> Node
|
56
|
+
|
57
|
+
# abstract methods
|
58
|
+
|
59
|
+
def children_match_prefix: (Array[String]) { (String) -> void } -> Enumerator[String, void]
|
60
|
+
|
61
|
+
def partial_word_chars?: (Array[String]) -> bool
|
62
|
+
|
63
|
+
def word_chars?: (Array[String]) -> bool
|
64
|
+
|
65
|
+
def closest_node: (Array[String]) -> Node
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Nodes
|
4
|
+
class Raw < Node
|
5
|
+
def add: (Array[Symbol]) -> Node
|
6
|
+
|
7
|
+
def compressed?: -> bool
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def add_to_children_tree: (Array[Symbol]) -> Node
|
12
|
+
|
13
|
+
def new_node: (Symbol) -> Node
|
14
|
+
|
15
|
+
# overrides
|
16
|
+
|
17
|
+
def children_match_prefix: (Array[String]) { (String) -> void } -> Enumerator[String, void]
|
18
|
+
|
19
|
+
def partial_word_chars?: (Array[String]) -> bool
|
20
|
+
|
21
|
+
def word_chars?: (Array[String]) -> bool
|
22
|
+
|
23
|
+
def closest_node: (Array[String]) -> Node
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Serializers
|
4
|
+
class Zip < Serializer[Nodes::Node]
|
5
|
+
@properties: Configuration::Properties
|
6
|
+
|
7
|
+
def initialize: (Configuration::Properties) -> void
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
attr_reader properties: Configuration::Properties
|
12
|
+
|
13
|
+
def serializers: -> Configuration::ProviderCollection[Serializer[Nodes::Node]]
|
14
|
+
|
15
|
+
def tmp_path: -> String
|
16
|
+
|
17
|
+
def path: (String) -> String
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
module Stringifyable
|
4
|
+
def as_word: -> String
|
5
|
+
|
6
|
+
def to_s: -> String
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
# abstract methods
|
11
|
+
|
12
|
+
def letter: -> Symbol
|
13
|
+
|
14
|
+
def terminal?: -> bool
|
15
|
+
|
16
|
+
def parent: -> Nodes::Node?
|
17
|
+
|
18
|
+
def children_tree: -> Hash[Symbol, Nodes::Node]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rambling
|
2
|
+
module Trie
|
3
|
+
VERSION: String
|
4
|
+
|
5
|
+
@properties: Configuration::Properties
|
6
|
+
|
7
|
+
def self.create: (?String?, ?Readers::Reader?) ?{ (Container) -> void } -> Container
|
8
|
+
|
9
|
+
def self.load: (String, ?Serializers::Serializer[Nodes::Node]?) ?{ (Container) -> void } -> Container
|
10
|
+
|
11
|
+
def self.dump: (Container, String, ?Serializers::Serializer[Nodes::Node]?) -> void
|
12
|
+
|
13
|
+
def self.config: ?{ (Configuration::Properties) -> void } -> Configuration::Properties
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def self.properties: -> Configuration::Properties
|
18
|
+
|
19
|
+
def self.readers: -> Configuration::ProviderCollection[Readers::Reader]
|
20
|
+
|
21
|
+
def self.serializers: -> Configuration::ProviderCollection[Serializers::Serializer[Nodes::Node]]
|
22
|
+
|
23
|
+
def self.compressor: -> Compressor
|
24
|
+
|
25
|
+
def self.root_builder: -> ^() -> Nodes::Node
|
26
|
+
end
|
27
|
+
end
|