dejunk 0.6.0 → 0.6.1
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 +4 -4
- data/.github/workflows/build.yml +15 -0
- data/.tool-versions +1 -0
- data/lib/dejunk/version.rb +1 -1
- data/lib/dejunk.rb +8 -10
- metadata +4 -3
- data/.circleci/config.yml +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 06c7eece281db7bb6218b0f3a56da9541a5830f8b7d0e739daf08b6d9f6b004d
|
|
4
|
+
data.tar.gz: b2dc0dd0f457164085eb19e418f75db4bca6d7cb0a315fa1e5bc0f9fad2ac3aa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 367bf74302776bf03dbef89b2f5aad58c5f446511b30ae2cfc765372b86a9600ef9e2faf7d4b639629938ebfc59dd9c7d2a1720564dcfd94aeedd05235b023cb
|
|
7
|
+
data.tar.gz: a47f13d1b05d25641329ac4ed963288096e84a30186a16789facef75ecb5709137987d65b7cf727b935c71a16f01481b39b50e46bae8154cdd5ea28843ac1b3c
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 4.0.5
|
data/lib/dejunk/version.rb
CHANGED
data/lib/dejunk.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require "active_support/core_ext/object/blank"
|
|
2
2
|
require "active_support/core_ext/string"
|
|
3
|
-
require "bigdecimal"
|
|
4
3
|
require "yaml"
|
|
5
4
|
|
|
6
5
|
require "dejunk/version"
|
|
@@ -133,17 +132,16 @@ module Dejunk
|
|
|
133
132
|
|
|
134
133
|
return 0 unless bigrams.present?
|
|
135
134
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
# Work in log space because the raw products of per-bigram probabilities
|
|
136
|
+
# underflow Float.
|
|
137
|
+
log_prob_given_mashing = bigrams.sum { |bigram| Math.log(mashing_probability(bigram)) }
|
|
138
|
+
log_prob_given_corpus = bigrams.sum { |bigram| Math.log(corpus_probability(bigram)) }
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
# Equivalent to mashing / (mashing + corpus), with the priors applied.
|
|
141
|
+
log_odds_ratio = log_prob_given_corpus + Math.log(1 - apriori_probability_of_mashing) -
|
|
142
|
+
log_prob_given_mashing - Math.log(apriori_probability_of_mashing)
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
numerator / (numerator + prob_bigrams_given_corpus * (1 - apriori_probability_of_mashing))
|
|
144
|
+
1.0 / (1.0 + Math.exp(log_odds_ratio))
|
|
147
145
|
end
|
|
148
146
|
|
|
149
147
|
def normalize_for_comparison(string)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dejunk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Judd
|
|
@@ -57,9 +57,10 @@ executables: []
|
|
|
57
57
|
extensions: []
|
|
58
58
|
extra_rdoc_files: []
|
|
59
59
|
files:
|
|
60
|
-
- ".
|
|
60
|
+
- ".github/workflows/build.yml"
|
|
61
61
|
- ".gitignore"
|
|
62
62
|
- ".rspec"
|
|
63
|
+
- ".tool-versions"
|
|
63
64
|
- ".travis.yml"
|
|
64
65
|
- Gemfile
|
|
65
66
|
- LICENSE
|
|
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
88
89
|
- !ruby/object:Gem::Version
|
|
89
90
|
version: '0'
|
|
90
91
|
requirements: []
|
|
91
|
-
rubygems_version:
|
|
92
|
+
rubygems_version: 4.0.10
|
|
92
93
|
specification_version: 4
|
|
93
94
|
summary: Detect keyboard mashing and other junk in your data.
|
|
94
95
|
test_files: []
|