Class: SameSame::TermFrequencyBuilder
- Inherits:
-
Object
- Object
- SameSame::TermFrequencyBuilder
- Defined in:
- lib/same_same/term_frequency_builder.rb
Class Method Summary collapse
Class Method Details
.build_vectors(x, y) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/same_same/term_frequency_builder.rb', line 4 def self.build_vectors( x, y ) all_attributes = {} x.each {|s| all_attributes[s] = 0x01} y.each {|s| all_attributes[s] = (all_attributes[s] || 0x00) | 0x02 } # create term frequency vectors term_freq_for_x = [] term_freq_for_y = [] all_attributes.each {|_, flags| term_freq_for_x << (flags & 0x01) term_freq_for_y << (flags >> 1) } [term_freq_for_x, term_freq_for_y] end |