lib/doc_sim/shingling.rb in doc_sim-0.1.0 vs lib/doc_sim/shingling.rb in doc_sim-0.1.1
- old
+ new
@@ -1,10 +1,9 @@
# frozen_string_literal: true
+# Shingle a document
module Shingling
def self.shingle(document, k)
max_index = document.length - k + 1
- max_index.times.map do |i|
- document[i...(i + k)]
- end
+ max_index.times.to_set { |i| document[i...(i + k)] }
end
end