shookach 0.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6ed9e1d1ec991a677613601b7f94eb1cd6d8669208f4ef2621afa4c14990679f
4
+ data.tar.gz: 7b37a02e74e814c13ca46cf3a1184143399983ea018a240f0e0cfa70ef9e4947
5
+ SHA512:
6
+ metadata.gz: 1718ad244150a1f9ff82eaa3ef12257b4ab08ab508cf975b3e1c84af3d51a15e74cb5e080ab603a9f7ee6adbfc38cbbf5a04d10f49efa68e502a596544cfa581
7
+ data.tar.gz: b0d440cdc37aae0a3f75f9da6afaa6059cf35d2b669f4b2dd87d5da828e5231ed1505adcadbf7775b3370679c5dad11c49a064caa6e1227e2cf867bc672b1cbf
@@ -0,0 +1,44 @@
1
+ class Indexer
2
+ def initialize(library_path)
3
+ @path = library_path
4
+ @output_file = File.open('./public/output/indexes.yml', 'w')
5
+ end
6
+
7
+ def call
8
+ write_dir_indexes
9
+
10
+ @output_file.close
11
+ end
12
+
13
+ private
14
+
15
+ def write_dir_indexes
16
+ puts "indexing directory: #{@path}"
17
+
18
+ Dir.foreach(@path) do |filename|
19
+ next if filename == '.' || filename == '..'
20
+
21
+ write_file_indexes(filename)
22
+ end
23
+ end
24
+
25
+ def write_file_indexes(filename)
26
+ puts "indexing file: #{filename}"
27
+
28
+ @file = File.open("#{@path}/#{filename}", 'r')
29
+
30
+ sentences_arr.each_with_index do |sentence, s_index|
31
+ words = sentence.split(' ')
32
+
33
+ words.each_with_index do |word, w_index|
34
+ @output_file.write("#{word}:\r file: #{filename}\r sentence: #{s_index}\r word: #{w_index}\n")
35
+ end
36
+ end
37
+
38
+ @file.close
39
+ end
40
+
41
+ def sentences_arr
42
+ @file.read().gsub(/\n|\r/, ' ').split(/\.\s*/)
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ class Searcher
2
+ #TODO would be implemented later
3
+ end
data/lib/shookach.rb ADDED
@@ -0,0 +1,12 @@
1
+ require './lib/shookach/indexer'
2
+ require './lib/shookach/searcher'
3
+
4
+ class Shookach
5
+ def self.index(library_path = './public/input/')
6
+ Indexer.new(library_path).call
7
+ end
8
+
9
+ def self.search
10
+ # @searcher.call
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shookach
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bohdan Chaban
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple gem for full-text search
14
+ email: b.chaban.91@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/shookach.rb
20
+ - lib/shookach/indexer.rb
21
+ - lib/shookach/searcher.rb
22
+ homepage: http://rubygems.org/gems/shookach
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.7.5
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Full-text search
46
+ test_files: []