predictor 2.3.0 → 2.3.1

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: c267ff0bf82d11ccefe19ae4314a62b09e9300fa
4
- data.tar.gz: 7eed86238af5297d8c32250c6ebf28f992b9e331
3
+ metadata.gz: f4df4be1a5695f1d3166382a5cf25efd1925bcb1
4
+ data.tar.gz: 4468cd0189e18ec27d0651501e37ff07cb826446
5
5
  SHA512:
6
- metadata.gz: eaa28d8a14437dd11742499a10211827ebc212feeb99d421185676d4a06ed1253f67a5252e7e4a748c6f87c69b6d0ed136b461f1df7b557ef4c92514b399e2c3
7
- data.tar.gz: c60c5a6572cb6c42ef4e9633e29a73e8baee84384b6dbc3371b9979e7b0a5fc2c6bc2b67dd64e0a2733a38fbadb1e8df73b4e024bdb22b501aaf88b1732d438d
6
+ metadata.gz: 8a45d82c57f57f219b86a19ca759d04dacdcce44ece6a4ae92d80a115229fca6b7d23ae9c1ab78012049c9337b576777a8fcee517b1371b4daecf57db42dd595
7
+ data.tar.gz: 046bc87e3faf2ecbc1bbf1a6bd04f1e92c09fbdb17053aa9bbac597bc98b79f11d4d09af02ba230bafa44c546dd7bdfb150d5620048cce4320c1d169968c3038
data/README.md CHANGED
@@ -219,6 +219,26 @@ You can also configure the namespace used by each class you create:
219
219
  end
220
220
  ```
221
221
 
222
+ You can also configure the namespace used by each instance you create in addition to class and global namespace:
223
+
224
+ ```ruby
225
+ class CourseRecommender
226
+ include Predictor::Base
227
+
228
+ def initialize(prefix)
229
+ @prefix = prefix
230
+ end
231
+
232
+ # Simply override this instance method with the prefix you want
233
+ def get_redis_prefix
234
+ @prefix
235
+ end
236
+ end
237
+
238
+ recommender = CourseRecommender.new("super")
239
+ recommender.redis_prefix # "predictor:CourseRecommender:super"
240
+ ```
241
+
222
242
  Processing Items
223
243
  ---------------------
224
244
  As of 2.3.0, there are now multiple techniques available for processing item similarities. You can choose between them by setting a global default like `Predictor.processing_technique(:lua)` or setting a technique for certain classes like `CourseRecommender.processing_technique(:union)`. There are three values.
@@ -266,6 +286,12 @@ predictor.delete_from_matrix!(:topics, "course-1")
266
286
  ```
267
287
  * Regenerate your recommendations, as redis keys have changed for Predictor 2. You can use the recommender.clean! to clear out old similarities, then run your rake task (or whatever you've setup) to create new similarities.
268
288
 
289
+ About Pathgather
290
+ ---------------------
291
+ Pathgather is an NYC-based startup building a platform that dramatically accelerates learning for enterprises by bringing employees, training content, and existing enterprise systems into one engaging platform.
292
+
293
+ Every Friday, we work on open-source software (our own or other projects). Want to join our always growing team? Peruse our [current opportunities](http://www.pathgather.com/jobs/) or reach out to us at <tech@pathgather.com>!
294
+
269
295
  Problems? Issues? Want to help out?
270
296
  ---------------------
271
297
  Just submit a Gihub issue or pull request! We'd love to have you help out, as the most common library to use for this need, Recommendify, was last updated 2 years ago. We'll be sure to keep this maintained, but we could certainly use your help!
@@ -63,8 +63,12 @@ module Predictor::Base
63
63
  }]
64
64
  end
65
65
 
66
+ def get_redis_prefix
67
+ nil # Override in subclass.
68
+ end
69
+
66
70
  def redis_prefix
67
- [Predictor.get_redis_prefix, self.class.get_redis_prefix]
71
+ [Predictor.get_redis_prefix, self.class.get_redis_prefix, self.get_redis_prefix].compact
68
72
  end
69
73
 
70
74
  def similarity_limit
@@ -263,6 +267,10 @@ module Predictor::Base
263
267
  return self
264
268
  end
265
269
 
270
+ def add_item(item)
271
+ Predictor.redis.sadd(redis_key(:all_items), item)
272
+ end
273
+
266
274
  def delete_item!(item)
267
275
  Predictor.redis.srem(redis_key(:all_items), item)
268
276
  Predictor.redis.watch(redis_key(:similarities, item)) do
@@ -1,3 +1,3 @@
1
1
  module Predictor
2
- VERSION = "2.3.0"
3
- end
2
+ VERSION = "2.3.1"
3
+ end
@@ -142,6 +142,21 @@ describe Predictor::Base do
142
142
  expect(br.redis_key(:another, :key)).to eq("predictor-test:BaseRecommender:another:key")
143
143
  expect(br.redis_key(:another, [:set, :of, :keys])).to eq("predictor-test:BaseRecommender:another:set:of:keys")
144
144
  end
145
+
146
+ it "should respect the instance prefix configuration setting" do
147
+ br = PrefixRecommender.new("foo")
148
+
149
+ expect(br.redis_key).to eq("predictor-test:PrefixRecommender:foo")
150
+ expect(br.redis_key(:another)).to eq("predictor-test:PrefixRecommender:foo:another")
151
+ expect(br.redis_key(:another, :key)).to eq("predictor-test:PrefixRecommender:foo:another:key")
152
+ expect(br.redis_key(:another, [:set, :of, :keys])).to eq("predictor-test:PrefixRecommender:foo:another:set:of:keys")
153
+
154
+
155
+ br.prefix = nil
156
+ expect(br.redis_key).to eq("predictor-test:PrefixRecommender")
157
+ expect(br.redis_key(:another)).to eq("predictor-test:PrefixRecommender:another")
158
+
159
+ end
145
160
  end
146
161
 
147
162
  describe "all_items" do
@@ -24,6 +24,22 @@ class TestRecommender
24
24
  input_matrix :jaccard_one
25
25
  end
26
26
 
27
+ class PrefixRecommender
28
+ include Predictor::Base
29
+
30
+ def initialize(prefix)
31
+ @prefix = prefix
32
+ end
33
+
34
+ def prefix=(new_prefix)
35
+ @prefix = new_prefix
36
+ end
37
+
38
+ def get_redis_prefix
39
+ @prefix
40
+ end
41
+ end
42
+
27
43
  class Predictor::TestInputMatrix
28
44
  def initialize(opts)
29
45
  @opts = opts
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: predictor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pathgather
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-05 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.14.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.14.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Fast and efficient recommendations and predictions using Redis
@@ -115,17 +115,17 @@ require_paths:
115
115
  - lib
116
116
  required_ruby_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - '>='
118
+ - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.1.11
128
+ rubygems_version: 2.4.5
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Fast and efficient recommendations and predictions using Redis