la 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +57 -0
- data/app.rb +36 -0
- data/bin/la +7 -0
- data/cli/import.rb +41 -0
- data/la.gemspec +11 -0
- data/web/config.ru +3 -0
- data/web/html/layouts/default.slim +7 -0
- data/web/html/pages/index.slim +1 -0
- data/web/html/pages/search.slim +1 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b7695064f4c2301b69618534b5541d40161a81ca
|
4
|
+
data.tar.gz: fb7af2e0c63ad399840bd51121655e35d576a6dd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d70625ef483ac28f02cf8ad7b3e81d82c9dfce2c08d7b0e3c0633aeb338cd52aa479b55b34e8fcbf0f9a0ba65112f14a06f776f4e55b40711f7aed3a9b620a11
|
7
|
+
data.tar.gz: d24be49881202295966b1fe0a412fa217ea8dac68ccfbdf81e294f872bf8f721c19976109c282af6dfd04c830b49d90be8e54b7d418bd125c56ada0638df39e2
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
la (0.0.0)
|
5
|
+
hobby-pages
|
6
|
+
sequel
|
7
|
+
sqlite3
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
awesome_print (1.8.0)
|
13
|
+
coderay (1.1.1)
|
14
|
+
coffee-script (2.4.1)
|
15
|
+
coffee-script-source
|
16
|
+
execjs
|
17
|
+
coffee-script-source (1.12.2)
|
18
|
+
concurrent-ruby (1.0.5)
|
19
|
+
execjs (2.7.0)
|
20
|
+
hobby (0.0.8)
|
21
|
+
rack
|
22
|
+
hobby-pages (0.0.2)
|
23
|
+
coffee-script
|
24
|
+
hobby (>= 0.0.8)
|
25
|
+
sass
|
26
|
+
slim
|
27
|
+
sprockets
|
28
|
+
tilt
|
29
|
+
method_source (0.8.2)
|
30
|
+
pry (0.10.4)
|
31
|
+
coderay (~> 1.1.0)
|
32
|
+
method_source (~> 0.8.1)
|
33
|
+
slop (~> 3.4)
|
34
|
+
rack (2.0.3)
|
35
|
+
sass (3.4.24)
|
36
|
+
sequel (4.47.0)
|
37
|
+
slim (3.0.8)
|
38
|
+
temple (>= 0.7.6, < 0.9)
|
39
|
+
tilt (>= 1.3.3, < 2.1)
|
40
|
+
slop (3.6.0)
|
41
|
+
sprockets (3.7.1)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
rack (> 1, < 3)
|
44
|
+
sqlite3 (1.3.13)
|
45
|
+
temple (0.8.0)
|
46
|
+
tilt (2.0.7)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
awesome_print
|
53
|
+
la!
|
54
|
+
pry
|
55
|
+
|
56
|
+
BUNDLED WITH
|
57
|
+
1.15.1
|
data/app.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module App
|
2
|
+
module Screen
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def clear
|
6
|
+
print "\e[H\e[2J"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module InsertApp
|
11
|
+
module_function
|
12
|
+
|
13
|
+
def run
|
14
|
+
Screen.clear
|
15
|
+
|
16
|
+
while gets
|
17
|
+
if $_.start_with? ':'
|
18
|
+
command = $_.strip
|
19
|
+
else
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module CLI
|
26
|
+
module_function
|
27
|
+
def run
|
28
|
+
case ARGV[0]
|
29
|
+
when 'insert'
|
30
|
+
InsertApp.run
|
31
|
+
when 'search'
|
32
|
+
SearchApp.run
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/bin/la
ADDED
data/cli/import.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'sequel'
|
3
|
+
|
4
|
+
module La
|
5
|
+
ROOT_DIRECTORY = "#{ENV['HOME']}/.la"
|
6
|
+
|
7
|
+
module Import
|
8
|
+
def self.[] origin, file
|
9
|
+
origin = const_get origin.capitalize
|
10
|
+
origin.import_sentences_from file
|
11
|
+
end
|
12
|
+
|
13
|
+
module Tatoeba
|
14
|
+
def self.import_sentences_from file
|
15
|
+
FileUtils.mkdir_p ROOT_DIRECTORY
|
16
|
+
db = Sequel.sqlite "#{ROOT_DIRECTORY}/db.sqlite"
|
17
|
+
db.run "CREATE VIRTUAL TABLE sentences USING fts5(sentence, language, tatoeba_id);"
|
18
|
+
|
19
|
+
e = File.open(file).each_line.lazy
|
20
|
+
batch = e.first 100000
|
21
|
+
sentences = []
|
22
|
+
|
23
|
+
until batch.empty?
|
24
|
+
batch.each do |line|
|
25
|
+
tatoeba_id, language, sentence = line.split "\t"
|
26
|
+
sentences << [sentence, language, tatoeba_id] if language == 'eng'
|
27
|
+
end
|
28
|
+
|
29
|
+
p batch.first
|
30
|
+
db[:sentences].import [:sentence, :language, :tatoeba_id], sentences
|
31
|
+
p batch.last
|
32
|
+
|
33
|
+
batch = e.first 100000
|
34
|
+
sentences.clear
|
35
|
+
end
|
36
|
+
|
37
|
+
"#{file} was imported."
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/la.gemspec
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Gem::Specification.new do |g|
|
2
|
+
g.name = 'la'
|
3
|
+
g.files = `git ls-files`.split($/)
|
4
|
+
g.version = '0.0.0'
|
5
|
+
g.summary = 'A local Tatoeba.'
|
6
|
+
g.authors = ['Anatoly Chernow']
|
7
|
+
|
8
|
+
g.add_dependency 'hobby-pages'
|
9
|
+
g.add_dependency 'sqlite3'
|
10
|
+
g.add_dependency 'sequel'
|
11
|
+
end
|
data/web/config.ru
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
web/html/pages/search.slim
|
@@ -0,0 +1 @@
|
|
1
|
+
input
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: la
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anatoly Chernow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: hobby-pages
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sequel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- Gemfile
|
62
|
+
- Gemfile.lock
|
63
|
+
- app.rb
|
64
|
+
- bin/la
|
65
|
+
- cli/import.rb
|
66
|
+
- la.gemspec
|
67
|
+
- web/config.ru
|
68
|
+
- web/html/layouts/default.slim
|
69
|
+
- web/html/pages/index.slim
|
70
|
+
- web/html/pages/search.slim
|
71
|
+
homepage:
|
72
|
+
licenses: []
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.6.11
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: A local Tatoeba.
|
94
|
+
test_files: []
|