Class: FpGrowth::Miner::Pattern
- Inherits:
-
Object
- Object
- FpGrowth::Miner::Pattern
- Defined in:
- lib/fpgrowth/miner/pattern.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#support ⇒ Object
Returns the value of attribute support.
Instance Method Summary collapse
- #+(y) ⇒ Object
- #<<(y) ⇒ Object
- #clone ⇒ Object
-
#initialize(content = [], support = 0) ⇒ Pattern
constructor
A new instance of Pattern.
- #size ⇒ Object
Constructor Details
#initialize(content = [], support = 0) ⇒ Pattern
Returns a new instance of Pattern.
9 10 11 12 |
# File 'lib/fpgrowth/miner/pattern.rb', line 9 def initialize(content=[], support = 0) @content = content @support = support end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/fpgrowth/miner/pattern.rb', line 6 def content @content end |
#support ⇒ Object
Returns the value of attribute support.
7 8 9 |
# File 'lib/fpgrowth/miner/pattern.rb', line 7 def support @support end |
Instance Method Details
#+(y) ⇒ Object
14 15 16 17 |
# File 'lib/fpgrowth/miner/pattern.rb', line 14 def +(y) return self unless y return Pattern.new(@content + y.content, [@support, y.support].min) end |
#<<(y) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fpgrowth/miner/pattern.rb', line 19 def <<(y) if y.is_a?(Array) min_support = @support for node in y unless @content.include?(node.item) @content << node.item if min_support > node.support then min_support = node.support end end end @support = min_support elsif y.is_a?(FpTree::Node) self << [y] end end |
#clone ⇒ Object
41 42 43 |
# File 'lib/fpgrowth/miner/pattern.rb', line 41 def clone return Pattern.new(@content.clone, @support) end |
#size ⇒ Object
37 38 39 |
# File 'lib/fpgrowth/miner/pattern.rb', line 37 def size @content.size end |