Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: illdefined/recommendify
base: 4129292c99
...
head fork: illdefined/recommendify
compare: 00e87781c5
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 23 files changed
  • 0 commit comments
  • 2 contributors
View
2  .gitignore
@@ -1,2 +1,4 @@
bin/
+*.gem
Gemfile.lock
+ext/Makefile
View
10 README.md
@@ -152,13 +152,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-
-### todo
-
-+ implement CosineInputMatrix
-+ forbid ':' and '|' in item_ids
-+ recommendify::base no key part issue
-+ make max_row length configurable
-
View
2  Rakefile
@@ -14,6 +14,6 @@ task YARD::Rake::YardocTask.new
task :native => "bin/recommendify"
desc "Compile the native client"
-file "bin/recommendify" => FileList['src/*.c'] do |t|
+file "bin/recommendify" => FileList['ext/*.c'] do |t|
%x{gcc -pedantic-errors -Wall -std=c99 -lhiredis -o #{t.name} #{t.prerequisites.join(' ')}}
end
View
0  src/.gitignore → ext/.gitignore
File renamed without changes
View
0  src/Doxyfile → ext/Doxyfile
File renamed without changes
View
0  src/cc_item.h → ext/cc_item.h
File renamed without changes
View
0  src/cosine.c → ext/cosine.c
File renamed without changes
View
0  src/cosine.h → ext/cosine.h
File renamed without changes
View
0  src/iikey.c → ext/iikey.c
File renamed without changes
View
0  src/iikey.h → ext/iikey.h
File renamed without changes
View
0  src/jaccard.c → ext/jaccard.c
File renamed without changes
View
0  src/jaccard.h → ext/jaccard.h
File renamed without changes
View
0  src/output.c → ext/output.c
File renamed without changes
View
0  src/output.h → ext/output.h
File renamed without changes
View
9 src/recommendify.c → ext/recommendify.c
@@ -29,7 +29,11 @@ int main(int argc, char **argv){
size_t batch_size = 200; /* FIXPAUL: make option */
size_t maxItems = 50; /* FIXPAUL: make option */
-
+ struct {
+ char host[1024];
+ int port;
+ } redis_addr;
+
/* option parsing */
if(argc < 2) {
print_usage(stderr, argv[0]);
@@ -106,6 +110,8 @@ int main(int argc, char **argv){
redisPrefix = argv[argi + 1];
itemID = argv[argi + 2];
+ if(!redis_addr.port)
+ redis_addr.port = 6379;
/* connect to redis */
struct timeval timeout = { 1, 500000 };
@@ -115,7 +121,6 @@ int main(int argc, char **argv){
c ? c->errstr : "Broken by design");
return EXIT_FAILURE;
}
-
/* get item count */
reply = redisCommand(c,"HGET %s:items %s", redisPrefix, itemID);
View
0  src/sort.c → ext/sort.c
File renamed without changes
View
0  src/sort.h → ext/sort.h
File renamed without changes
View
0  src/version.h → ext/version.h
File renamed without changes
View
3  lib/recommendify/cc_matrix.rb
@@ -8,6 +8,7 @@ def ccmatrix
end
def add_set(set_id, item_ids)
+ # FIXPAUL: forbid | and : in item_ids
item_ids.each do |item_id|
item_count_incr(item_id)
end
@@ -48,4 +49,4 @@ def item_count(key)
Recommendify.redis.hget(redis_key(:items), key).to_i
end
-end
+end
View
6 lib/recommendify/jaccard_input_matrix.rb
@@ -34,7 +34,7 @@ def calculate_jaccard(set1, set2)
end
def run_native(item_id)
- res = %x{#{native_path} --jaccard "#{redis_key}" "#{item_id}"}
+ res = %x{#{native_path} --jaccard "#{redis_key}" "#{item_id}" "#{redis_url}"}
res.split("\n").map do |line|
sim = line.match(/OUT: \(([^\)]*)\) \(([^\)]*)\)/)
raise "error: #{res}" unless sim
@@ -51,4 +51,8 @@ def native_path
::File.expand_path('../../../bin/recommendify', __FILE__)
end
+ def redis_url
+ Recommendify.redis.client.location
+ end
+
end
View
9 recommendify.gemspec
@@ -3,22 +3,23 @@ $:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = "recommendify"
- s.version = "0.2.3"
+ s.version = "0.3.1"
s.date = Date.today.to_s
s.platform = Gem::Platform::RUBY
s.authors = ["Paul Asmuth"]
s.email = ["paul@paulasmuth.com"]
s.homepage = "http://github.com/paulasmuth/recommendify"
- s.summary = %q{Distributed item-based "Collaborative Filtering" with ruby and redis}
- s.description = %q{Distributed item-based "Collaborative Filtering" with ruby and redis}
+ s.summary = %q{ruby/redis based recommendation engine (collaborative filtering)}
+ s.description = %q{Recommendify is a distributed, incremental item-based recommendation engine for binary input ratings. It's based on ruby and redis and uses an approach called "Collaborative Filtering"}
s.licenses = ["MIT"]
+ s.extensions = ['ext/extconf.rb']
+
s.add_dependency "redis", ">= 2.2.2"
s.add_development_dependency "rspec", "~> 2.8.0"
s.files = `git ls-files`.split("\n") - [".gitignore", ".rspec", ".travis.yml"]
s.test_files = `git ls-files -- spec/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
end
View
6 spec/base_spec.rb
@@ -4,8 +4,8 @@
before(:each) do
flush_redis!
- Recommendify::Base.class_variable_set(:@@max_neighbors, nil)
- Recommendify::Base.class_variable_set(:@@input_matrices, {})
+ Recommendify::Base.send(:class_variable_set, :@@max_neighbors, nil)
+ Recommendify::Base.send(:class_variable_set, :@@input_matrices, {})
end
describe "configuration" do
@@ -24,7 +24,7 @@
it "should add an input_matrix by 'key'" do
Recommendify::Base.input_matrix(:myinput, :similarity_func => :jaccard)
- Recommendify::Base.class_variable_get(:@@input_matrices).keys.should == [:myinput]
+ Recommendify::Base.send(:class_variable_get, :@@input_matrices).keys.should == [:myinput]
end
it "should retrieve an input_matrix on a new instance" do
View
17 spec/jaccard_input_matrix_spec.rb
@@ -55,6 +55,23 @@
res.should include ["fnord", 0.4]
end
+ it "should call run_native when the native option was passed" do
+ Recommendify::JaccardInputMatrix.class_eval do
+ def check_native; true; end
+ end
+ matrix = Recommendify::JaccardInputMatrix.new(
+ :redis_prefix => "recommendify-test",
+ :native => true,
+ :key => "mymatrix"
+ )
+ matrix.should_receive(:run_native).with("fnord").and_return(true)
+ matrix.similarities_for("fnord")
+ end
+
+ it "should return the correct redis url" do
+ @matrix.send(:redis_url).should == "127.0.0.1:6379"
+ end
+
private
def add_two_item_test_data!(matrix)

No commit comments for this range

Something went wrong with that request. Please try again.