Skip to content

Commit

Permalink
Merge branch 'master' of github.com:paulasmuth/recommendify
Browse files Browse the repository at this point in the history
  • Loading branch information
asmuth committed Mar 12, 2012
2 parents 84bcfb0 + 5858793 commit 0f5fd79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions lib/recommendify/jaccard_input_matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ class Recommendify::JaccardInputMatrix < Recommendify::InputMatrix

include Recommendify::CCMatrix

def initialize(opts={})
def initialize(opts={})
check_native if opts[:native]
super(opts)
super(opts)
end

def similarity(item1, item2)
calculate_jaccard_cached(item1, item2)
end

def similarities_for(item1)
return run_native(item1) if @opts[:native]
return run_native(item1) if @opts[:native]
calculate_similarities(item1)
end

Expand All @@ -35,6 +35,7 @@ def calculate_jaccard(set1, set2)

def run_native(item_id)
res = %x{#{native_path} --jaccard "#{redis_key}" "#{item_id}" "#{redis_url}"}
raise "error: dirty exit (#{$?})" if $? != 0
res.split("\n").map do |line|
sim = line.match(/OUT: \(([^\)]*)\) \(([^\)]*)\)/)
raise "error: #{res}" unless sim
Expand All @@ -55,4 +56,4 @@ def redis_url
Recommendify.redis.client.location
end

end
end
6 changes: 3 additions & 3 deletions recommendify.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)

Gem::Specification.new do |s|
s.name = "recommendify"
s.version = "0.3.1"
s.version = "0.3.2"
s.date = Date.today.to_s
s.platform = Gem::Platform::RUBY
s.authors = ["Paul Asmuth"]
Expand All @@ -12,11 +12,11 @@ Gem::Specification.new do |s|
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"]
Expand Down

0 comments on commit 0f5fd79

Please sign in to comment.