module Evoc::Util
Public Class Methods
lattice(nodes,filter: nil)
click to toggle source
helper function to generate a lattice so we can easily come up with tests for the closed rules mining examples nodes: [['a’,],['b’,],['c’,]] first elem is item name second elem is the txes where this item changes
# File lib/evoc/util.rb, line 8 def self.lattice(nodes,filter: nil) (1..nodes.size).each do |n| nodes.combination(n).each do |comb| # [['a',[1,2]],['b',[2,3]]] union = comb.map(&:first).join(',') frequency = comb.map(&:second).inject(&:&).size if filter =~ union if frequency > 0 printf("%#{nodes.size*2}s",[union,frequency].join(':')) end end end puts end end
nodes2txstore(nodes)
click to toggle source
helper function for generating a txstore from the following format
# File lib/evoc/util.rb, line 27 def self.nodes2txstore(nodes) txes = nodes.map(&:second).inject(&:|) store = Evoc::TxStore.new txes.each do |id| items = nodes.select {|n| n.second.include?(id)}.map(&:first) store << Evoc::Tx.new(id: id, items: items) end return(store) end