Class: Bmg::Operator::Autosummarize::Trust

Inherits:
Object
  • Object
show all
Defined in:
lib/bmg/operator/autosummarize.rb

Overview

class Check

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sums) ⇒ Trust

Returns a new instance of Trust.



149
150
151
# File 'lib/bmg/operator/autosummarize.rb', line 149

def initialize(sums)
  @sums = sums
end

Instance Attribute Details

#sumsObject (readonly)

Returns the value of attribute sums.



152
153
154
# File 'lib/bmg/operator/autosummarize.rb', line 152

def sums
  @sums
end

Instance Method Details

#init(tuple) ⇒ Object

Returns the initial tuple to use for a given determinant.



155
156
157
158
159
# File 'lib/bmg/operator/autosummarize.rb', line 155

def init(tuple)
  sums.each_with_object(tuple.dup){|(attribute,summarizer),new_tuple|
    new_tuple[attribute] = summarizer.init(tuple[attribute])
  }
end

#sum(memo, tuple) ⇒ Object

Sums ‘tuple` on `memo`, returning the new tuple to use as memo.



162
163
164
165
166
# File 'lib/bmg/operator/autosummarize.rb', line 162

def sum(memo, tuple)
  sums.each_with_object(memo.dup){|(attribute,summarizer),new_tuple|
    new_tuple[attribute] = summarizer.sum(memo[attribute], tuple[attribute])
  }
end

#term(tuple) ⇒ Object

Terminates the summarization of a given tuple.



169
170
171
172
173
# File 'lib/bmg/operator/autosummarize.rb', line 169

def term(tuple)
  sums.each_with_object(tuple.dup){|(attribute,summarizer),new_tuple|
    new_tuple[attribute] = summarizer.term(tuple[attribute])
  }
end