trie-substring-search 0.1.0.0 → 0.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.drone.yml +1 -1
- data/.gitignore +4 -1
- data/.rubocop.yml +16 -0
- data/Gemfile +17 -0
- data/README.md +9 -7
- data/Rakefile +2 -0
- data/bin/console +1 -2
- data/lib/tss/link.rb +6 -1
- data/lib/tss/trie-substring-search.code-workspace +10 -0
- data/lib/tss/trie.rb +11 -5
- data/lib/tss/tries/base.rb +9 -1
- data/lib/tss/tries/full.rb +22 -15
- data/lib/tss/tss.rb +2 -2
- data/lib/tss/version.rb +3 -1
- data/lib/tss/vertex.rb +7 -3
- data/tss.gemspec +17 -24
- metadata +13 -167
- data/.travis.yml +0 -7
- data/Gemfile.lock +0 -95
- data/lib/tss/tries/ac.rb +0 -26
- data/lib/tss/tries/flat.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc0392fcf9e1035033467b8fc1564f1abd4e675c81404fa5bd2991a2e656c73b
|
4
|
+
data.tar.gz: 6079b695eb1d2c439d06a7c01986654eadc2f30cef41558d6364366b755f75f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b0a93ba1d9ad0cc5a61ecb78b4e6f7dcddf07aa384a4a36eccdfd7656a895ce64096444d218fed4c9b3807adcd4e7f94b148399a9ca90facf694e7c97e242cc
|
7
|
+
data.tar.gz: bbd29010d634d023cafee5c4b4a273c0cc964d49d0d69e63767d10c375ab21d7f0db284e146336d82a3136bf42aa4115f0bfbf838b41d5b7ec487aa0000c32c0
|
data/.DS_Store
ADDED
Binary file
|
data/.drone.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in tss.gemspec
|
6
8
|
gemspec
|
9
|
+
|
10
|
+
gem 'bundler'
|
11
|
+
gem 'codecov'
|
12
|
+
gem 'pry'
|
13
|
+
gem 'rake'
|
14
|
+
gem 'rspec'
|
15
|
+
gem 'rspec-benchmark'
|
16
|
+
gem 'rspec-collection_matchers'
|
17
|
+
gem 'rubocop'
|
18
|
+
gem 'rubocop-md'
|
19
|
+
gem 'rubocop-performance'
|
20
|
+
gem 'rubocop-rake'
|
21
|
+
gem 'rubocop-rspec'
|
22
|
+
gem 'simplecov'
|
23
|
+
gem 'simplecov-console'
|
data/README.md
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
|
+
Implementation of text syntax analyzer, which represents text as non symetric trie of chars or substrings by dictionary or list of keywords. Similar to Aho-Corasick algorithm, but with modifications, there is removed suffixes and added recovering text from the trie.
|
11
|
+
|
10
12
|
Add this line to your application's Gemfile:
|
11
13
|
|
12
14
|
```ruby
|
@@ -25,12 +27,12 @@ Or install it yourself as:
|
|
25
27
|
|
26
28
|
```ruby
|
27
29
|
# Array of words in the dictionary
|
28
|
-
|
30
|
+
dictionary = %w[he she her his him he they their she]
|
29
31
|
# Initialize trie
|
30
32
|
# types of trie to build :full, :flat(WIP) and :aho_corasick(WIP)
|
31
|
-
|
33
|
+
tss = TSS::Trie.new(dictionary, :full)
|
32
34
|
# Parse text and receive array of all occurrences of words in texts with indexes of word in dictionary
|
33
|
-
|
35
|
+
tss.parse('he their them height have then their shelter')
|
34
36
|
# => [{:word=>"he", :indexes=>[0, 5]},
|
35
37
|
# {:word=>"their", :indexes=>[7]},
|
36
38
|
# {:word=>"he", :indexes=>[0, 5]},
|
@@ -42,9 +44,9 @@ Or install it yourself as:
|
|
42
44
|
# {:word=>"she", :indexes=>[1, 8]},
|
43
45
|
# {:word=>"he", :indexes=>[0, 5]}]
|
44
46
|
# Add additional words to the dictionary
|
45
|
-
|
47
|
+
tss.extend_dictionary(%w[our it them])
|
46
48
|
# Get end vertex of word 'they'
|
47
|
-
|
49
|
+
vertex = tss.root.get_child('s').get_child('h').get_child('e')
|
48
50
|
# => #<ACT::Vertex:0x000055cabb2399d0
|
49
51
|
# @char="e",
|
50
52
|
# @children=[],
|
@@ -59,10 +61,10 @@ Or install it yourself as:
|
|
59
61
|
# @char="s",
|
60
62
|
# @children=[#<ACT::Vertex:0x000055cabb239ac0 ...>],
|
61
63
|
# get array of indexes of word
|
62
|
-
|
64
|
+
vertex.end_indexes
|
63
65
|
# => [1, 8]
|
64
66
|
# Recover word from trie with indexes in dictionary
|
65
|
-
|
67
|
+
tss.backtrace_to_word(vertex)
|
66
68
|
# => {:word=>"she", :indexes=>[1, 8]}
|
67
69
|
```
|
68
70
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/tss/link.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# TSS module
|
1
5
|
module TSS
|
2
6
|
##
|
3
7
|
# Class representing links(suffixes) between vertexes
|
@@ -9,7 +13,8 @@ module TSS
|
|
9
13
|
# Character to simplify search
|
10
14
|
attr_reader :char
|
11
15
|
##
|
12
|
-
# Index of word in dictionary if vertex is ending, or nil if vertex
|
16
|
+
# Index of word in dictionary if vertex is ending, or nil if vertex
|
17
|
+
# is suffix
|
13
18
|
attr_accessor :end_index
|
14
19
|
|
15
20
|
##
|
data/lib/tss/trie.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# TSS module
|
2
4
|
module TSS
|
3
5
|
##
|
4
|
-
# Main class for creating Trie Substring Search from array of words of
|
6
|
+
# Main class for creating Trie Substring Search from array of words of
|
7
|
+
# dictionary
|
5
8
|
class Trie
|
6
9
|
##
|
7
10
|
# Root vertex
|
@@ -18,6 +21,7 @@ module TSS
|
|
18
21
|
##
|
19
22
|
# Trie class instance
|
20
23
|
attr_reader :trie_instance
|
24
|
+
|
21
25
|
##
|
22
26
|
# Initialize new trie and fill it with words from dictionary
|
23
27
|
def initialize(dictionary, type = :full)
|
@@ -28,15 +32,16 @@ module TSS
|
|
28
32
|
end
|
29
33
|
|
30
34
|
##
|
31
|
-
# Executes text analyzis and returns map occurring words with indexes from
|
35
|
+
# Executes text analyzis and returns map occurring words with indexes from
|
36
|
+
# dictionary
|
32
37
|
def parse(text)
|
33
38
|
@trie_instance.parse(text)
|
34
39
|
end
|
35
40
|
|
36
41
|
##
|
37
42
|
# Returns hash with word and indexes at dictionary
|
38
|
-
# * Ending vertex of chain should be used as argument, it means that it
|
39
|
-
# contain at least one value in the array of end_indexes attribute
|
43
|
+
# * Ending vertex of chain should be used as argument, it means that it
|
44
|
+
# should contain at least one value in the array of end_indexes attribute
|
40
45
|
def backtrace_to_word(vertex)
|
41
46
|
@trie_instance.backtrace_to_word(vertex)
|
42
47
|
end
|
@@ -65,7 +70,8 @@ module TSS
|
|
65
70
|
return :AC if type == :aho_corasick
|
66
71
|
return :Flat if type == :flat
|
67
72
|
|
68
|
-
raise ArgumentError, 'Wrong trie type. Possible is: :full, :flat or
|
73
|
+
raise ArgumentError, 'Wrong trie type. Possible is: :full, :flat or \
|
74
|
+
:aho_corasick'
|
69
75
|
end
|
70
76
|
end
|
71
77
|
end
|
data/lib/tss/tries/base.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
1
4
|
# TSS module
|
2
5
|
module TSS
|
6
|
+
##
|
7
|
+
# Tries module
|
3
8
|
module Tries
|
4
9
|
##
|
5
|
-
# Main class for creating Aho-Corasick Trie from array of words of
|
10
|
+
# Main class for creating Aho-Corasick Trie from array of words of
|
11
|
+
# dictionary
|
6
12
|
class Base
|
7
13
|
##
|
8
14
|
# Root vertex
|
@@ -37,6 +43,8 @@ module TSS
|
|
37
43
|
|
38
44
|
private
|
39
45
|
|
46
|
+
##
|
47
|
+
# Stub superclass method for build_trie
|
40
48
|
def build_trie
|
41
49
|
@root
|
42
50
|
end
|
data/lib/tss/tries/full.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
1
3
|
# TSS module
|
2
4
|
module TSS
|
5
|
+
##
|
6
|
+
# Tries module
|
3
7
|
module Tries
|
4
8
|
##
|
5
9
|
# Main class for creating Full Trie from array of words of dictionary
|
6
10
|
class Full < Base
|
7
11
|
##
|
8
|
-
# Executes text analyze and returns map occurring words with indexes
|
12
|
+
# Executes text analyze and returns map occurring words with indexes
|
13
|
+
# from dictionary
|
9
14
|
# Example:
|
10
15
|
# >> tss.parse('he their them height have then their shelter')
|
11
16
|
# => [ {:word=>"he", :indexes=>[0, 5]},
|
@@ -21,22 +26,23 @@ module TSS
|
|
21
26
|
# Arguments:
|
22
27
|
# text: (String)
|
23
28
|
def parse(text)
|
24
|
-
text = text.to_s.
|
29
|
+
text = text.to_s.chars
|
25
30
|
vm = vertex_map(text) { :vertex }
|
26
31
|
exec_branches(text, vm).flatten.compact
|
27
32
|
end
|
28
33
|
|
29
34
|
##
|
30
|
-
# Returns hash with vertexes that represents letters of word and indexes
|
31
|
-
#
|
32
|
-
#
|
35
|
+
# Returns hash with vertexes that represents letters of word and indexes
|
36
|
+
# of word in dictionary
|
37
|
+
# * Ending vertex of chain should be used as argument, it means that it
|
38
|
+
# should contain at least one value in the array of end_indexes attribute
|
33
39
|
# Example:
|
34
40
|
# backtrace_to_word(vertex)
|
35
41
|
# Arguments:
|
36
42
|
# vertex: (TSS::Vertex) - ending vertex of chain of letters
|
37
43
|
def backtrace_to_word(vertex)
|
38
44
|
if vertex.end_indexes.empty?
|
39
|
-
raise 'Argument should be ending vertex of chain, and contain at'\
|
45
|
+
raise 'Argument should be ending vertex of chain, and contain at' \
|
40
46
|
'least one value in the array of end_indexes attribute'
|
41
47
|
else
|
42
48
|
chain = backtrace(vertex)
|
@@ -61,7 +67,7 @@ module TSS
|
|
61
67
|
def exec_branches(text, vertex_map)
|
62
68
|
vertex_map.map do |b|
|
63
69
|
b[:indexes].map do |index|
|
64
|
-
search(b[:key], text[index + 1
|
70
|
+
search(b[:key], text[index + 1..])
|
65
71
|
end
|
66
72
|
end
|
67
73
|
end
|
@@ -74,19 +80,19 @@ module TSS
|
|
74
80
|
return result if vertex.children.empty?
|
75
81
|
|
76
82
|
ending = search_rest(vertex, text)
|
77
|
-
|
83
|
+
ending.empty? ? result : (result + ending)
|
78
84
|
end
|
79
85
|
|
80
86
|
def search_rest(vertex, text)
|
81
87
|
result = []
|
82
88
|
text.each do |char|
|
83
|
-
|
84
|
-
break if
|
89
|
+
c_vertex = vertex.get_child(char)
|
90
|
+
break if c_vertex.nil?
|
85
91
|
|
86
|
-
result << backtrace_to_word(
|
87
|
-
break if
|
92
|
+
result << backtrace_to_word(c_vertex) if end_vertex?(c_vertex)
|
93
|
+
break if c_vertex.children.empty?
|
88
94
|
|
89
|
-
vertex =
|
95
|
+
vertex = c_vertex
|
90
96
|
end
|
91
97
|
result
|
92
98
|
end
|
@@ -95,7 +101,8 @@ module TSS
|
|
95
101
|
@trie.children.map do |vertex|
|
96
102
|
{
|
97
103
|
key: vertex.send(yield),
|
98
|
-
indexes: text.collect.with_index { |c, i| i if c == vertex.char }
|
104
|
+
indexes: text.collect.with_index { |c, i| i if c == vertex.char }
|
105
|
+
.compact
|
99
106
|
}
|
100
107
|
end
|
101
108
|
end
|
@@ -105,7 +112,7 @@ module TSS
|
|
105
112
|
end
|
106
113
|
|
107
114
|
def backtrace(vertex)
|
108
|
-
result =
|
115
|
+
result = vertex.nil? ? [] : [vertex]
|
109
116
|
until vertex.parent.nil?
|
110
117
|
result << vertex.parent unless vertex.parent.char.nil?
|
111
118
|
vertex = vertex.parent
|
data/lib/tss/tss.rb
CHANGED
data/lib/tss/version.rb
CHANGED
data/lib/tss/vertex.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# TSS module
|
2
4
|
module TSS
|
3
5
|
##
|
@@ -10,11 +12,13 @@ module TSS
|
|
10
12
|
# Reference to the parent TSS::Vertex
|
11
13
|
attr_accessor :parent
|
12
14
|
##
|
13
|
-
# Array of children TSS::Vertex references for nested models
|
14
|
-
# or as list of nested vertexes of root
|
15
|
+
# Array of children TSS::Vertex references for nested models
|
16
|
+
# (full trie, Aho-Corasick trie) or as list of nested vertexes of root
|
17
|
+
# vertex of flat trie
|
15
18
|
attr_reader :children
|
16
19
|
##
|
17
|
-
# Array of TSS::Vertex links for flat trie model, also used as
|
20
|
+
# Array of TSS::Vertex links for flat trie model, also used as
|
21
|
+
# suffixes of Aho-Corasick trie
|
18
22
|
attr_reader :links
|
19
23
|
##
|
20
24
|
# Array of indexes of word in dictionary
|
data/tss.gemspec
CHANGED
@@ -1,13 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
|
5
|
+
|
4
6
|
require './lib/tss/tss'
|
5
|
-
|
6
|
-
require './lib/tss/tries/base'
|
7
|
-
require './lib/tss/tries/ac'
|
8
|
-
require './lib/tss/tries/full'
|
9
|
-
require './lib/tss/tries/flat'
|
10
|
-
require './lib/tss/vertex'
|
7
|
+
|
11
8
|
Gem::Specification.new do |spec|
|
12
9
|
spec.name = 'trie-substring-search'
|
13
10
|
spec.version = TSS::VERSION
|
@@ -16,12 +13,15 @@ Gem::Specification.new do |spec|
|
|
16
13
|
spec.homepage = 'https://codenv.top/projects/trie-substring-search'
|
17
14
|
spec.summary = 'Trie based substring search algorithm implementation'
|
18
15
|
spec.license = 'Apache-2.0'
|
19
|
-
spec.
|
16
|
+
spec.required_ruby_version = '~> 3.1'
|
17
|
+
spec.description = <<-DESCRIPTION
|
20
18
|
This gem provides ruby library with algorithms for trie based
|
21
19
|
substring search.
|
22
20
|
DESCRIPTION
|
23
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set
|
24
|
-
#
|
21
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set
|
22
|
+
# the 'allowed_push_host'
|
23
|
+
# to allow pushing to a single host or delete this section to allow
|
24
|
+
# pushing to any host.
|
25
25
|
if spec.respond_to?(:metadata)
|
26
26
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
27
27
|
|
@@ -30,27 +30,20 @@ Gem::Specification.new do |spec|
|
|
30
30
|
# spec.metadata['changelog_uri'] = 'https://github.com/sbezugliy/trie-substring-search/changelog.md'
|
31
31
|
else
|
32
32
|
raise 'RubyGems 2.0 or newer is required to protect against' \
|
33
|
-
|
33
|
+
'public gem pushes.'
|
34
34
|
end
|
35
35
|
|
36
36
|
# Specify which files should be added to the gem when it is released.
|
37
|
-
# The `git ls-files -z` loads the files in the RubyGem that have
|
37
|
+
# The `git ls-files -z` loads the files in the RubyGem that have
|
38
|
+
# been added into git.
|
38
39
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
39
|
-
`git ls-files -z`.split("\x0").reject
|
40
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
41
|
+
f.match(%r{^(test|spec|features)/})
|
42
|
+
end
|
40
43
|
end
|
41
44
|
spec.bindir = 'exe'
|
42
45
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
43
46
|
spec.require_paths = ['lib']
|
44
47
|
|
45
|
-
spec.
|
46
|
-
spec.add_development_dependency 'codecov', '~> 0.1'
|
47
|
-
spec.add_development_dependency 'pry', '~> 0.12'
|
48
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
49
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
50
|
-
spec.add_development_dependency 'rspec-benchmark', '~> 0.5.0'
|
51
|
-
spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1.0'
|
52
|
-
spec.add_development_dependency 'rubocop', '~> 0.67.0'
|
53
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.1.0'
|
54
|
-
spec.add_development_dependency 'simplecov', '~> 0.16.0'
|
55
|
-
spec.add_development_dependency 'simplecov-console', '~> 0.4.0'
|
48
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
56
49
|
end
|
metadata
CHANGED
@@ -1,169 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trie-substring-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Bezugliy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.1
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: codecov
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.1'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.1'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.12'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.12'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '10.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '10.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '3.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec-benchmark
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.5.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.5.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec-collection_matchers
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 1.1.0
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 1.1.0
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.67.0
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.67.0
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop-performance
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.1.0
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 1.1.0
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: simplecov
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 0.16.0
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 0.16.0
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: simplecov-console
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 0.4.0
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: 0.4.0
|
11
|
+
date: 2023-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
167
13
|
description: |2
|
168
14
|
This gem provides ruby library with algorithms for trie based
|
169
15
|
substring search.
|
@@ -173,22 +19,21 @@ executables: []
|
|
173
19
|
extensions: []
|
174
20
|
extra_rdoc_files: []
|
175
21
|
files:
|
22
|
+
- ".DS_Store"
|
176
23
|
- ".drone.yml"
|
177
24
|
- ".gitignore"
|
178
25
|
- ".rspec"
|
179
|
-
- ".
|
26
|
+
- ".rubocop.yml"
|
180
27
|
- Gemfile
|
181
|
-
- Gemfile.lock
|
182
28
|
- LICENSE
|
183
29
|
- README.md
|
184
30
|
- Rakefile
|
185
31
|
- bin/console
|
186
32
|
- bin/setup
|
187
33
|
- lib/tss/link.rb
|
34
|
+
- lib/tss/trie-substring-search.code-workspace
|
188
35
|
- lib/tss/trie.rb
|
189
|
-
- lib/tss/tries/ac.rb
|
190
36
|
- lib/tss/tries/base.rb
|
191
|
-
- lib/tss/tries/flat.rb
|
192
37
|
- lib/tss/tries/full.rb
|
193
38
|
- lib/tss/tss.rb
|
194
39
|
- lib/tss/version.rb
|
@@ -201,23 +46,24 @@ metadata:
|
|
201
46
|
allowed_push_host: https://rubygems.org
|
202
47
|
homepage_uri: https://codenv.top/projects/trie-substring-search
|
203
48
|
source_code_uri: https://github.com/sbezugliy/trie-substring-search
|
204
|
-
|
49
|
+
rubygems_mfa_required: 'true'
|
50
|
+
post_install_message:
|
205
51
|
rdoc_options: []
|
206
52
|
require_paths:
|
207
53
|
- lib
|
208
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
209
55
|
requirements:
|
210
|
-
- - "
|
56
|
+
- - "~>"
|
211
57
|
- !ruby/object:Gem::Version
|
212
|
-
version: '
|
58
|
+
version: '3.1'
|
213
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
60
|
requirements:
|
215
61
|
- - ">="
|
216
62
|
- !ruby/object:Gem::Version
|
217
63
|
version: '0'
|
218
64
|
requirements: []
|
219
|
-
rubygems_version: 3.
|
220
|
-
signing_key:
|
65
|
+
rubygems_version: 3.4.1
|
66
|
+
signing_key:
|
221
67
|
specification_version: 4
|
222
68
|
summary: Trie based substring search algorithm implementation
|
223
69
|
test_files: []
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
trie-substring-search (0.1.0.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ansi (1.5.0)
|
10
|
-
ast (2.4.0)
|
11
|
-
benchmark-malloc (0.1.0)
|
12
|
-
benchmark-perf (0.5.0)
|
13
|
-
benchmark-trend (0.3.0)
|
14
|
-
codecov (0.1.14)
|
15
|
-
json
|
16
|
-
simplecov
|
17
|
-
url
|
18
|
-
coderay (1.1.2)
|
19
|
-
diff-lcs (1.3)
|
20
|
-
docile (1.3.1)
|
21
|
-
hirb (0.7.3)
|
22
|
-
jaro_winkler (1.5.2)
|
23
|
-
json (2.2.0)
|
24
|
-
method_source (0.9.2)
|
25
|
-
parallel (1.17.0)
|
26
|
-
parser (2.6.3.0)
|
27
|
-
ast (~> 2.4.0)
|
28
|
-
pry (0.12.2)
|
29
|
-
coderay (~> 1.1.0)
|
30
|
-
method_source (~> 0.9.0)
|
31
|
-
psych (3.1.0)
|
32
|
-
rainbow (3.0.0)
|
33
|
-
rake (10.5.0)
|
34
|
-
rspec (3.8.0)
|
35
|
-
rspec-core (~> 3.8.0)
|
36
|
-
rspec-expectations (~> 3.8.0)
|
37
|
-
rspec-mocks (~> 3.8.0)
|
38
|
-
rspec-benchmark (0.5.0)
|
39
|
-
benchmark-malloc (~> 0.1.0)
|
40
|
-
benchmark-perf (~> 0.5.0)
|
41
|
-
benchmark-trend (~> 0.3.0)
|
42
|
-
rspec (>= 3.0.0, < 4.0.0)
|
43
|
-
rspec-collection_matchers (1.1.3)
|
44
|
-
rspec-expectations (>= 2.99.0.beta1)
|
45
|
-
rspec-core (3.8.0)
|
46
|
-
rspec-support (~> 3.8.0)
|
47
|
-
rspec-expectations (3.8.3)
|
48
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.8.0)
|
50
|
-
rspec-mocks (3.8.0)
|
51
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.8.0)
|
53
|
-
rspec-support (3.8.0)
|
54
|
-
rubocop (0.67.2)
|
55
|
-
jaro_winkler (~> 1.5.1)
|
56
|
-
parallel (~> 1.10)
|
57
|
-
parser (>= 2.5, != 2.5.1.1)
|
58
|
-
psych (>= 3.1.0)
|
59
|
-
rainbow (>= 2.2.2, < 4.0)
|
60
|
-
ruby-progressbar (~> 1.7)
|
61
|
-
unicode-display_width (>= 1.4.0, < 1.6)
|
62
|
-
rubocop-performance (1.1.0)
|
63
|
-
rubocop (>= 0.67.0)
|
64
|
-
ruby-progressbar (1.10.0)
|
65
|
-
simplecov (0.16.1)
|
66
|
-
docile (~> 1.1)
|
67
|
-
json (>= 1.8, < 3)
|
68
|
-
simplecov-html (~> 0.10.0)
|
69
|
-
simplecov-console (0.4.2)
|
70
|
-
ansi
|
71
|
-
hirb
|
72
|
-
simplecov
|
73
|
-
simplecov-html (0.10.2)
|
74
|
-
unicode-display_width (1.5.0)
|
75
|
-
url (0.3.2)
|
76
|
-
|
77
|
-
PLATFORMS
|
78
|
-
ruby
|
79
|
-
|
80
|
-
DEPENDENCIES
|
81
|
-
bundler (~> 2.0.1)
|
82
|
-
codecov (~> 0.1)
|
83
|
-
pry (~> 0.12)
|
84
|
-
rake (~> 10.0)
|
85
|
-
rspec (~> 3.0)
|
86
|
-
rspec-benchmark (~> 0.5.0)
|
87
|
-
rspec-collection_matchers (~> 1.1.0)
|
88
|
-
rubocop (~> 0.67.0)
|
89
|
-
rubocop-performance (~> 1.1.0)
|
90
|
-
simplecov (~> 0.16.0)
|
91
|
-
simplecov-console (~> 0.4.0)
|
92
|
-
trie-substring-search!
|
93
|
-
|
94
|
-
BUNDLED WITH
|
95
|
-
2.0.1
|
data/lib/tss/tries/ac.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module TSS
|
2
|
-
module Tries
|
3
|
-
##
|
4
|
-
# Aho-Corasick trie class
|
5
|
-
class AC < Base
|
6
|
-
##
|
7
|
-
# Executes text analyze and returns map occurring words with indexes from dictionary
|
8
|
-
|
9
|
-
def parse
|
10
|
-
raise 'WIP'
|
11
|
-
end
|
12
|
-
|
13
|
-
##
|
14
|
-
# Returns hash with word and indexes at dictionary
|
15
|
-
def backtrace_to_word
|
16
|
-
raise 'WIP'
|
17
|
-
end
|
18
|
-
|
19
|
-
##
|
20
|
-
# Adds additional words(chains of vertexes) to the trie object
|
21
|
-
def extend_dictionay
|
22
|
-
raise 'WIP'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/tss/tries/flat.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# TSS module
|
2
|
-
module TSS
|
3
|
-
module Tries
|
4
|
-
##
|
5
|
-
# Main class for creating Flat Trie from array of words of dictionary
|
6
|
-
class Flat < Base
|
7
|
-
##
|
8
|
-
# Executes text analyze and returns map occurring words with indexes from dictionary
|
9
|
-
|
10
|
-
def parse(_text)
|
11
|
-
raise 'WIP'
|
12
|
-
end
|
13
|
-
|
14
|
-
##
|
15
|
-
# Returns hash with word and indexes at dictionary
|
16
|
-
def backtrace_to_word(_vertex)
|
17
|
-
raise 'WIP'
|
18
|
-
end
|
19
|
-
|
20
|
-
##
|
21
|
-
# Adds additional words(chains of vertexes) to the trie object
|
22
|
-
def extend_dictionary(_dict)
|
23
|
-
raise 'WIP'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|