Class: String
Instance Method Summary collapse
Instance Method Details
#hash_vl ⇒ Object
9 |
# File 'ext/string_hashing/string_hashing.c', line 9 VALUE method_hash_vl(VALUE self, VALUE bitlength); |
#hash_vl_rb(length) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/string.rb', line 15 def hash_vl_rb(length) return 0 if self == "" x = self.bytes.first << 7 m = 1000003 mask = (1<<length) - 1 self.each_byte{ |char| x = ((x * m) ^ char.to_i) & mask } x ^= self.bytes.count x = -2 if x == -1 x end |
#segment ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/string.rb', line 28 def segment algor = RMMSeg::Algorithm.new(self) result = [] loop do tok = algor.next_token word = (Tyccl.get_similar(tok.text.force_encoding('utf-8')).first.first rescue nil) word = tok.text if word.nil? && !tok.nil? break if word.nil? result << word end result end |
#simhash(options = {}) ⇒ Object
11 12 13 |
# File 'lib/string.rb', line 11 def simhash(={}) Simhash.hash(self.segment, ) end |