Permalink
Browse files

Refactoring dependencies.

  • Loading branch information...
1 parent 6645b20 commit a0f21c283610361f4626e0c06f10cfb33f94403d @vasinov committed Dec 10, 2012
View
@@ -3,4 +3,5 @@
.DS_Store
log/*.log
pkg/
-.rbenv-version
+.rbenv-version
+*.gem
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- jruby_mahout (0.2.0)
+ jruby_mahout (0.2.1)
GEM
remote: http://rubygems.org/
View
@@ -1,4 +1,4 @@
-$LOAD_PATH << File.expand_path("../lib", __FILE__)
+$:.push File.expand_path("../lib", __FILE__)
require "jruby_mahout/version"
Gem::Specification.new do |gem|
@@ -11,11 +11,9 @@ Gem::Specification.new do |gem|
gem.description = "Jruby Mahout is a gem that unleashes the power of Apache Mahout in the world of Jruby. Mahout is a superior machine learning library written in Java. It deals with recommendations, clustering and classification machine learning problems at scale. Until now it was difficult to use it in Ruby projects. You'd have to implement Java interfaces in Jruby yourself, which is not quick especially if you just started exploring the world of machine learning."
gem.license = "MIT"
- gem.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "README.md"]
+ gem.files = Dir["lib/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
gem.test_files = Dir["spec/**/*"]
- gem.files = `git ls-files`.split($/)
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
- gem.require_paths = ["lib"]
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.add_development_dependency "rake"
gem.add_development_dependency "rspec"
View
@@ -4,5 +4,11 @@ module JrubyMahout
require File.join(ENV["MAHOUT_DIR"], 'mahout-integration-0.7.jar')
require File.join(ENV["MAHOUT_DIR"], 'mahout-math-0.7.jar')
Dir.glob(File.join(ENV["MAHOUT_DIR"], 'lib/*.jar')).each { |d| require d }
- Dir['./lib/jruby_mahout/*.rb'].each{ |f| require f }
+
+ require 'jruby_mahout/recommender'
+ require 'jruby_mahout/recommender_builder'
+ require 'jruby_mahout/data_model'
+ require 'jruby_mahout/evaluator'
+ require 'jruby_mahout/postgres_manager'
+ require 'jruby_mahout/mysql_manager'
end
@@ -1,5 +1,7 @@
module JrubyMahout
class DataModel
+ java_import org.apache.mahout.cf.taste.impl.model.file.FileDataModel
+
attr_accessor :data_model
def initialize(data_model_type, params)
@@ -1,5 +1,7 @@
module JrubyMahout
class Evaluator
+ java_import org.apache.mahout.cf.taste.impl.eval.AverageAbsoluteDifferenceRecommenderEvaluator
+
def initialize(data_model, recommender_builder)
@data_model = data_model
@recommender_builder = recommender_builder
@@ -1,34 +1,21 @@
# Recommenders
-java_import org.apache.mahout.cf.taste.eval.RecommenderBuilder
-java_import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity
-java_import org.apache.mahout.cf.taste.impl.similarity.EuclideanDistanceSimilarity
-java_import org.apache.mahout.cf.taste.impl.similarity.SpearmanCorrelationSimilarity
-java_import org.apache.mahout.cf.taste.impl.similarity.LogLikelihoodSimilarity
-java_import org.apache.mahout.cf.taste.impl.similarity.TanimotoCoefficientSimilarity
-java_import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity
+
# Neighborhoods
-java_import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood
+
# Recommenders
-java_import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender
-java_import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender
-java_import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender
+
# Weighting
-java_import org.apache.mahout.cf.taste.common.Weighting
+
# Evaluators
-java_import org.apache.mahout.cf.taste.impl.eval.AverageAbsoluteDifferenceRecommenderEvaluator
+
# Data Models
-java_import org.apache.mahout.cf.taste.impl.model.jdbc.PostgreSQLJDBCDataModel
-java_import org.apache.mahout.cf.taste.impl.model.file.FileDataModel
+
# Postgres
-begin
- java_import org.postgresql.ds.PGPoolingDataSource
-rescue Exception => e
- puts e
-end
+
@@ -1,5 +1,13 @@
module JrubyMahout
class PostgresManager
+ java_import org.apache.mahout.cf.taste.impl.model.jdbc.PostgreSQLJDBCDataModel
+
+ begin
+ java_import org.postgresql.ds.PGPoolingDataSource
+ rescue Exception => e
+ puts e
+ end
+
attr_accessor :data_model, :data_source, :statement
def initialize(params)
@@ -1,5 +1,21 @@
module JrubyMahout
class RecommenderBuilder
+ java_import org.apache.mahout.cf.taste.eval.RecommenderBuilder
+ java_import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity
+ java_import org.apache.mahout.cf.taste.impl.similarity.EuclideanDistanceSimilarity
+ java_import org.apache.mahout.cf.taste.impl.similarity.SpearmanCorrelationSimilarity
+ java_import org.apache.mahout.cf.taste.impl.similarity.LogLikelihoodSimilarity
+ java_import org.apache.mahout.cf.taste.impl.similarity.TanimotoCoefficientSimilarity
+ java_import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity
+
+ java_import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood
+
+ java_import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender
+ java_import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender
+ java_import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender
+
+ java_import org.apache.mahout.cf.taste.common.Weighting
+
attr_accessor :recommender_name, :item_based_allowed
# public interface RecommenderBuilder
# Implementations of this inner interface are simple helper classes which create a Recommender to be evaluated based on the given DataModel.
@@ -1,3 +1,3 @@
module JrubyMahout
- VERSION = '0.2.0'
+ VERSION = '0.2.1'
end

0 comments on commit a0f21c2

Please sign in to comment.