spellr 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +4 -4
- data/lib/spellr/backports.rb +43 -41
- data/lib/spellr/config_loader.rb +4 -0
- data/lib/spellr/key_tuner/naive_bayes.rb +4 -0
- data/lib/spellr/key_tuner/possible_key.rb +3 -0
- data/lib/spellr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e045b4e7f76fa43573c0e28564a4f532dbcc9b35f05ca682e7302274ce0bdbc
|
4
|
+
data.tar.gz: 2918d1f1c2a41c681dc7370180ead18a63a86f991032140f0dea1ac92faad3b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d44c69a61badacc0a792f2ec60794847ea722101fc46e5fdce717562e2f3923ce6d95624af75d6c31e4cdcf2e6b017aaa7aa87c28a3f3b3761591658fcea6770
|
7
|
+
data.tar.gz: a607bcdf971179b58c7a1fc4fbf433ef4312724910c74f3731dd5df1127ccc2c9059d836564f00456656d19dfad39b62707663baffd1349bb93352a20f83f9b8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -257,14 +257,14 @@ To have this automatically run on travis, add `:spellr` to the default task.
|
|
257
257
|
require 'spellr/rake_task'
|
258
258
|
Spellr::RakeTask.generate_task
|
259
259
|
|
260
|
-
task :
|
260
|
+
task default: :spellr
|
261
261
|
```
|
262
262
|
or if you already have :default task, add :spellr to the array.
|
263
263
|
```ruby
|
264
264
|
require 'spellr/rake_task'
|
265
265
|
Spellr::RakeTask.generate_task
|
266
266
|
|
267
|
-
task :
|
267
|
+
task default: [:spec, :spellr]
|
268
268
|
```
|
269
269
|
or etc.
|
270
270
|
|
@@ -285,7 +285,7 @@ To provide default cli arguments, the first argument is the name, and subsequent
|
|
285
285
|
require 'spellr/rake_task'
|
286
286
|
Spellr::RakeTask.generate_task(:spellr_quiet, '--quiet')
|
287
287
|
|
288
|
-
task :
|
288
|
+
task default: :spellr_quiet
|
289
289
|
```
|
290
290
|
or `rake spellr` will be in interactive mode unless the CI env variable is set.
|
291
291
|
```ruby
|
@@ -294,7 +294,7 @@ require 'spellr/rake_task'
|
|
294
294
|
spellr_arguments = ENV['CI'] ? [] : ['--interactive']
|
295
295
|
Spellr::RakeTask.generate_task(:spellr, **spellr_arguments)
|
296
296
|
|
297
|
-
task :
|
297
|
+
task default: :spellr
|
298
298
|
```
|
299
299
|
|
300
300
|
## Development
|
data/lib/spellr/backports.rb
CHANGED
@@ -1,58 +1,60 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
unless ruby_version >= Gem::Version.new('2.5')
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
module Spellr
|
4
|
+
ruby_version = Gem::Version.new(RUBY_VERSION)
|
5
|
+
unless ruby_version >= Gem::Version.new('2.5')
|
6
|
+
module HashSlice
|
7
|
+
refine Hash do
|
8
|
+
def slice!(*keys)
|
9
|
+
delete_if { |k| !keys.include?(k) }
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
def slice(*keys)
|
13
|
+
dup.slice!(*keys)
|
14
|
+
end
|
15
|
+
end
|
13
16
|
end
|
14
|
-
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
require 'yaml'
|
19
|
+
module YAMLSymbolizeNames
|
20
|
+
refine YAML.singleton_class do
|
21
|
+
alias_method :safe_load_without_symbolize_names, :safe_load
|
22
|
+
def safe_load(path, *args, symbolize_names: false, **kwargs)
|
23
|
+
if symbolize_names
|
24
|
+
symbolize_names!(safe_load_without_symbolize_names(path, *args, **kwargs))
|
25
|
+
else
|
26
|
+
safe_load_without_symbolize_names(path, *args, **kwargs)
|
27
|
+
end
|
25
28
|
end
|
26
|
-
end
|
27
29
|
|
28
|
-
|
30
|
+
private
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def symbolize_names!(obj) # rubocop:disable Metrics/MethodLength
|
33
|
+
case obj
|
34
|
+
when Hash
|
35
|
+
obj.keys.each do |key| # rubocop:disable Style/HashEachMethods # each_key never finishes.
|
36
|
+
obj[key.to_sym] = symbolize_names!(obj.delete(key))
|
37
|
+
end
|
38
|
+
when Array
|
39
|
+
obj.map! { |ea| symbolize_names!(ea) }
|
35
40
|
end
|
36
|
-
|
37
|
-
obj.map! { |ea| symbolize_names!(ea) }
|
41
|
+
obj
|
38
42
|
end
|
39
|
-
obj
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
43
|
-
end
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
unless ruby_version >= Gem::Version.new('2.6')
|
48
|
+
require 'yaml'
|
49
|
+
module YAMLPermittedClasses
|
50
|
+
refine YAML.singleton_class do
|
51
|
+
alias_method :safe_load_without_permitted_classes, :safe_load
|
52
|
+
def safe_load(path, *args, permitted_classes: nil, **kwargs)
|
53
|
+
if permitted_classes
|
54
|
+
safe_load_without_permitted_classes(path, permitted_classes, *args, **kwargs)
|
55
|
+
else
|
56
|
+
safe_load_without_permitted_classes(path, *args, **kwargs)
|
57
|
+
end
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
data/lib/spellr/config_loader.rb
CHANGED
@@ -5,6 +5,10 @@ require_relative 'backports'
|
|
5
5
|
|
6
6
|
module Spellr
|
7
7
|
class ConfigLoader
|
8
|
+
# :nocov:
|
9
|
+
using ::Spellr::YAMLSymbolizeNames if defined?(::Spellr::YAMLSymbolizeNames)
|
10
|
+
# :nocov:
|
11
|
+
|
8
12
|
attr_reader :config_file
|
9
13
|
|
10
14
|
def initialize(config_file = ::File.join(Dir.pwd, '.spellr.yml'))
|
@@ -7,6 +7,10 @@ require 'yaml'
|
|
7
7
|
# https://www.sitepoint.com/machine-learning-ruby-naive-bayes-theorem/
|
8
8
|
|
9
9
|
class NaiveBayes
|
10
|
+
# :nocov:
|
11
|
+
using ::Spellr::YAMLPermittedClasses if defined?(::Spellr::YAMLPermittedClasses)
|
12
|
+
# :nocov:
|
13
|
+
|
10
14
|
YAML_PATH = File.join(__dir__, 'data.yml')
|
11
15
|
|
12
16
|
attr_reader :feature_set
|
data/lib/spellr/version.rb
CHANGED