bayesic_matching 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5cea0e170af73887df8e76272b3cd884b83ddf06
4
- data.tar.gz: a3448c71f0ea4614fea06983678f988bcde33c27
3
+ metadata.gz: df98c7d569ac9e2e548452b9a3b40656b3626a91
4
+ data.tar.gz: 8da8d971e361eb88303054ca11ab83deeab10a6c
5
5
  SHA512:
6
- metadata.gz: 159b74bf8b9224c7cba78e483b88f2f69c6ac943d5bcabee6bebc2a65077755d2402512139e94adde5b3b0e3be4c074d37d8fcd32262c3d6ee8b822dc6925294
7
- data.tar.gz: 3e451a929ab45a35cd7462f72fd23ad962b844d7a3b854cf77479cb4347e34d647fab4d4f801c94d29e2f67015461bb5e87d2e44b6500a1fd723db0815dcdd1c
6
+ metadata.gz: 3b0bffa3d5381e085f7376e76053ed47b3593b9cc51a64590ea15f889a763b8fd71a40a8a5f0820444221d31990fed2936ee17d06e23fdab8cd752e2ed55e3f7
7
+ data.tar.gz: 64d046aff06b505337e8f3593f9cd4a89e365fdcad65cd482d2d4c3782ed6f5e33b696f0a372c93ec7257eff3f39d5681410d7ba0787cee5ebaf0f2ab72c4687
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bayesic_matching (0.1.0)
4
+ bayesic_matching (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  class BayesicMatching
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,15 +1,15 @@
1
1
  require "bayesic_matching/version"
2
+ require "set"
2
3
 
3
4
  class BayesicMatching
4
5
  def initialize
5
- @classifications = []
6
+ @classifications = ::Set.new
6
7
  @classifications_by_token = {}
7
8
  @tokens_by_classification = {}
8
- @total_token_entries = 0.0
9
9
  end
10
10
 
11
11
  def classify(tokens)
12
- tokens = tokens.reject{|t| @classifications_by_token[t].nil? }
12
+ tokens = tokens.reject{|t| @classifications_by_token[t].nil? }.uniq
13
13
  tokens.each_with_object({}) do |token, hash|
14
14
  @classifications_by_token[token].each do |c|
15
15
  p_klass = hash[c] || (1.0 / @classifications.size)
@@ -23,12 +23,11 @@ class BayesicMatching
23
23
 
24
24
  def train(tokens, classification)
25
25
  @classifications << classification
26
- @tokens_by_classification[classification] ||= []
27
- @tokens_by_classification[classification].concat(tokens)
26
+ @tokens_by_classification[classification] ||= ::Set.new
28
27
  tokens.each do |token|
29
- @classifications_by_token[token] ||= []
28
+ @tokens_by_classification[classification] << token
29
+ @classifications_by_token[token] ||= ::Set.new
30
30
  @classifications_by_token[token] << classification
31
- @total_token_entries += 1.0
32
31
  end
33
32
  end
34
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bayesic_matching
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Ries