rkneufeld-fuzzy-realty 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 4
3
+ :minor: 5
4
4
  :patch: 0
@@ -1,11 +1,11 @@
1
1
  module FuzzyRealty
2
+ # Stub for testing without Rails project
2
3
  class Listing
3
4
  attr_accessor :price, :sqft, :location, :style
4
5
  def initialize(values={})
5
6
  values.each_key {|k| instance_variable_set(:"@#{k}", values[k])}
6
7
  end
7
8
  end
8
-
9
9
  class Query
10
10
  attr_reader :params
11
11
  def initialize(params=[])
@@ -16,7 +16,7 @@ module FuzzyRealty
16
16
  raise "Attempting to add non-Parameter to Query"
17
17
  end
18
18
  @params << param
19
-
19
+
20
20
  end
21
21
  end
22
22
 
data/lib/fuzzy_realty.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'stubs.rb'
2
- require 'scores_table.rb'
3
1
  require 'weights.rb'
2
+ require 'classes.rb'
3
+ require 'scores_table.rb'
4
4
  require 'rulebase.rb'
5
5
 
6
6
  # If set this flag will turn on debugging printouts
@@ -41,14 +41,30 @@ if __FILE__ == $0
41
41
  })
42
42
  end
43
43
 
44
- parameters = []
45
- parameters << FuzzyRealty::Parameter.new(:price,250000)
46
- parameters << FuzzyRealty::Parameter.new(:location, 'A',true)
47
- parameters << FuzzyRealty::Parameter.new(:style,"Condominium",true)
48
- parameters << FuzzyRealty::Parameter.new(:sqft,1575,true)
49
- query = FuzzyRealty::Query.new(parameters)
44
+ query = FuzzyRealty::Query.new
45
+ query << FuzzyRealty::Parameter.new(:price,250000)
46
+ query << FuzzyRealty::Parameter.new(:location, 'A',true)
47
+ query << FuzzyRealty::Parameter.new(:style,"Condominium",true)
48
+ query << FuzzyRealty::Parameter.new(:sqft,1575,true)
49
+
50
+ scores = FuzzyRealty::ExpertSystem.scores(listings,query)
51
+ puts "Query 1, $250k Condominium in the prestiguous 'A' suburbs. 1575 sq. ft."
52
+ puts "Top 20 Listings:"
53
+ scores[(0..20)].each do |score|
54
+ puts "%.2f" % score[:score] + "\t\t#{score[:listing].inspect}"
55
+ end
56
+
57
+ puts "\n"
58
+ query = FuzzyRealty::Query.new
59
+ query << FuzzyRealty::Parameter.new(:price,99_000,true)
60
+ query << FuzzyRealty::Parameter.new(:location,'C')
61
+ query << FuzzyRealty::Parameter.new(:style, "Bungalow")
62
+ query << FuzzyRealty::Parameter.new(:sqft,1200)
63
+
50
64
  scores = FuzzyRealty::ExpertSystem.scores(listings,query)
51
- scores.each do |score|
65
+ puts "Query 2, $99k Bungalow in the ever so average 'C' block. 1200 sq. ft."
66
+ puts "Top 20 Listings:"
67
+ scores[(0..20)].each do |score|
52
68
  puts "%.2f" % score[:score] + "\t\t#{score[:listing].inspect}"
53
69
  end
54
70
  end
data/lib/rulebase.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'scores_table.rb'
1
2
  module FuzzyRealty
2
3
  RULES = {
3
4
  # Not yet implemented
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rkneufeld-fuzzy-realty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Neufeld
@@ -28,10 +28,10 @@ files:
28
28
  - Rakefile
29
29
  - VERSION.yml
30
30
  - lib/TODO
31
+ - lib/classes.rb
31
32
  - lib/fuzzy_realty.rb
32
33
  - lib/rulebase.rb
33
34
  - lib/scores_table.rb
34
- - lib/stubs.rb
35
35
  - lib/weights.rb
36
36
  - test/fuzzy_realty_test.rb
37
37
  - test/test_helper.rb