Sha256: 05e59dd722b6bae15944754dbe40dd1993c85215504999b25cf7fd0ceebaf3ea
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
module Snuffle class Cohort include PoroPlus attr_accessor :element, :neighbors, :line_numbers def self.from(nodes) cohorts = Element::Hash.materialize(nodes.hashes.to_a).inject([]) do |cohorts, element| cohort = Cohort.new(element: element, line_numbers: element.node.line_numbers ) cohorts << cohort if cohort.values.count > 1 && cohort.near_neighbors.count > 0 cohorts end end def has_near_neighbors? near_neighbors.present? end def near_neighbors @near_neighbors ||= neighbors.select{ |n| (n.values & values).size == values.size } end def neighbors @neighbors ||= [element.node.siblings - [self.element.node]].flatten.map{|sibling| Element::Hash.materialize([sibling]).first} end def values @values ||= self.element.values end def neighbor Struct.new(:element, :distance) end def distance(primary_matrix, token_matrix) Snuffle::Util::Correlation.distance(primary_matrix, token_matrix) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
snuffle-0.11.1 | lib/snuffle/cohort.rb |
snuffle-0.10.1 | lib/snuffle/cohort.rb |
snuffle-0.9.1 | lib/snuffle/cohort.rb |