commendo 0.0.8 → 0.0.9

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: 62cfaa4fff44e045a7adf83a7bc3ccb29db84812
4
- data.tar.gz: 8473e5cb764e1474f2aa541b195afd22ca123a84
3
+ metadata.gz: 80baa49ab8364f70fd8dd4f2127f95d4f5ad0da2
4
+ data.tar.gz: 355812df077e1df1cb4d0425fb36fac8334d19f6
5
5
  SHA512:
6
- metadata.gz: 2e2911b2ab856cc6ce7514f289a02cf1fe3e29e9e4a546aca1a11a97da8c4f4b9a2518074ed8b1b4148ffde164c62a970d36f42cd1c6e56b9c49021f513b818f
7
- data.tar.gz: f8664d3e2e048c9026865929c1c39375242b3f05d669b6b14212442f3ffaeb0aeca03a8a80091c42e1b59d6e305d7622b5ffb8eca516f083a4af991aaeaf8ef7
6
+ metadata.gz: a1c2164296cfe3c47d0ef943594aeb6b4f20a007f421729ddd5b4328c3ffd2e90033f7315fac9451f98f39a088b504f0252cc3540a75560f6df9b4052bc4c9b6
7
+ data.tar.gz: 5d31d9f878a2eb7ab19e97b13887adb95b3df416866993b5c9ff8008a21f24b97c7acaf685a1baeb17d9003fa6716a5b1d5041efe057de1f2dc70327c8eba4df
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.0.9 / 2014-04-09
2
+ * [BUGFIX] Fix similarity calculation for resources in many sets
3
+
1
4
  # 0.0.8 / 2014-04-09
2
5
  * [FEATURE] Allow degree of set membership to be included when adding data and incrementally increase scores when adding new data
3
6
 
@@ -4,8 +4,8 @@ local left_similarity_key = KEYS[3]
4
4
  local right_similarity_key = KEYS[4]
5
5
 
6
6
  local tmp_key_base = ARGV[1]
7
- local left = tonumber(ARGV[2])
8
- local right = tonumber(ARGV[3])
7
+ local left = ARGV[2]
8
+ local right = ARGV[3]
9
9
  local threshold = tonumber(ARGV[4])
10
10
 
11
11
  local function round(num, idp)
@@ -40,9 +40,14 @@ if table.getn(intersect) > 0 then
40
40
  end
41
41
 
42
42
  local similarity = round(intersect_score / union_score, 3)
43
+ redis.log(redis.LOG_NOTICE, 'Similarity from pair comparison for ' .. left_key .. ' ' .. right_key .. ', ' .. similarity .. ', ' .. threshold)
43
44
  if similarity > threshold then
45
+ redis.log(redis.LOG_NOTICE, 'Saving ' .. left_similarity_key .. ', ' .. similarity .. ', ' .. right)
44
46
  redis.call('ZADD', left_similarity_key, similarity, right)
47
+ redis.log(redis.LOG_NOTICE, 'Saving ' .. right_similarity_key .. ', ' .. similarity .. ', ' .. left)
45
48
  redis.call('ZADD', right_similarity_key, similarity, left)
49
+ else
50
+ redis.log(redis.LOG_NOTICE, 'NOT saving ' .. right_similarity_key .. ', ' .. similarity .. ', ' .. left)
46
51
  end
47
52
  end
48
53
 
@@ -1,3 +1,3 @@
1
1
  module Commendo
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
@@ -52,6 +52,22 @@ module Commendo
52
52
  assert_equal expected, cs.similar_to('resource-1')
53
53
  end
54
54
 
55
+ def test_recommends_with_large_number_of_groups
56
+ redis = Redis.new(db: 15)
57
+ redis.flushdb
58
+ key_base = 'CommendoTests'
59
+ cs = ContentSet.new(redis, key_base)
60
+ (0..3000).each do |i|
61
+ cs.add('resource-1', ["group-#{i}", i/100.0], ["group-#{i+1}", i/20.0])
62
+ cs.add('resource-9', ["group-#{i}", i/100.0], ["group-#{i+1}", i/20.0])
63
+ end
64
+ cs.calculate_similarity
65
+ expected = [
66
+ {resource: 'resource-9', similarity: 1.0}
67
+ ]
68
+ assert_equal expected, cs.similar_to('resource-1')
69
+ end
70
+
55
71
  def test_recommends_when_extra_scores_added
56
72
  test_recommends_when_added_with_scores
57
73
  redis = Redis.new(db: 15)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commendo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Styles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis