rambling-trie 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +28 -0
- data/Gemfile +18 -9
- data/Guardfile +16 -5
- data/README.md +23 -23
- 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 -21
- data/lib/rambling/trie/configuration/properties.rb +5 -4
- data/lib/rambling/trie/configuration/provider_collection.rb +12 -7
- data/lib/rambling/trie/configuration.rb +2 -3
- data/lib/rambling/trie/container.rb +20 -23
- data/lib/rambling/trie/enumerable.rb +4 -5
- data/lib/rambling/trie/nodes/compressed.rb +26 -16
- data/lib/rambling/trie/nodes/node.rb +31 -8
- data/lib/rambling/trie/nodes/raw.rb +16 -19
- data/lib/rambling/trie/nodes.rb +2 -3
- data/lib/rambling/trie/readers/plain_text.rb +2 -2
- data/lib/rambling/trie/readers.rb +2 -3
- data/lib/rambling/trie/serializers/marshal.rb +1 -1
- data/lib/rambling/trie/serializers/yaml.rb +1 -1
- data/lib/rambling/trie/serializers/zip.rb +12 -6
- 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 +11 -14
- data/rambling-trie.gemspec +1 -1
- 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 +29 -3
@@ -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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rambling-trie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgar Gonzalez
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: 'The Rambling Trie is a Ruby implementation of the trie data structure,
|
15
15
|
which includes compression abilities and is designed to be very fast to traverse. '
|
@@ -20,11 +20,13 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
|
+
- Dockerfile
|
23
24
|
- Gemfile
|
24
25
|
- Guardfile
|
25
26
|
- LICENSE
|
26
27
|
- README.md
|
27
28
|
- Rakefile
|
29
|
+
- Steepfile
|
28
30
|
- lib/rambling-trie.rb
|
29
31
|
- lib/rambling/trie.rb
|
30
32
|
- lib/rambling/trie/comparable.rb
|
@@ -54,6 +56,30 @@ files:
|
|
54
56
|
- lib/rambling/trie/stringifyable.rb
|
55
57
|
- lib/rambling/trie/version.rb
|
56
58
|
- rambling-trie.gemspec
|
59
|
+
- sig/lib/rambling/trie.rbs
|
60
|
+
- sig/lib/rambling/trie/comparable.rbs
|
61
|
+
- sig/lib/rambling/trie/compressible.rbs
|
62
|
+
- sig/lib/rambling/trie/compressor.rbs
|
63
|
+
- sig/lib/rambling/trie/configuration/properties.rbs
|
64
|
+
- sig/lib/rambling/trie/configuration/provider_collection.rbs
|
65
|
+
- sig/lib/rambling/trie/container.rbs
|
66
|
+
- sig/lib/rambling/trie/enumerable.rbs
|
67
|
+
- sig/lib/rambling/trie/inspectable.rbs
|
68
|
+
- sig/lib/rambling/trie/invalid_operation.rbs
|
69
|
+
- sig/lib/rambling/trie/nodes/compressed.rbs
|
70
|
+
- sig/lib/rambling/trie/nodes/missing.rbs
|
71
|
+
- sig/lib/rambling/trie/nodes/node.rbs
|
72
|
+
- sig/lib/rambling/trie/nodes/raw.rbs
|
73
|
+
- sig/lib/rambling/trie/readers/plain_text.rbs
|
74
|
+
- sig/lib/rambling/trie/readers/reader.rbs
|
75
|
+
- sig/lib/rambling/trie/serializers/file.rbs
|
76
|
+
- sig/lib/rambling/trie/serializers/marshal.rbs
|
77
|
+
- sig/lib/rambling/trie/serializers/serializer.rbs
|
78
|
+
- sig/lib/rambling/trie/serializers/yaml.rbs
|
79
|
+
- sig/lib/rambling/trie/serializers/zip.rbs
|
80
|
+
- sig/lib/rambling/trie/stringifyable.rbs
|
81
|
+
- sig/lib/zip/entry.rbs
|
82
|
+
- sig/lib/zip/file.rbs
|
57
83
|
homepage: https://github.com/gonzedge/rambling-trie
|
58
84
|
licenses:
|
59
85
|
- MIT
|
@@ -79,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
105
|
- !ruby/object:Gem::Version
|
80
106
|
version: '0'
|
81
107
|
requirements: []
|
82
|
-
rubygems_version: 3.5.
|
108
|
+
rubygems_version: 3.5.22
|
83
109
|
signing_key:
|
84
110
|
specification_version: 4
|
85
111
|
summary: A Ruby implementation of the trie data structure.
|