Apply weighted MinHash for one trigram: hash w times per seed. */
| 220 | |
| 221 | /* Apply weighted MinHash for one trigram: hash w times per seed. */ |
| 222 | static void weighted_minhash_update(cbm_minhash_t *out, const char *trigram, int len, int w) { |
| 223 | for (int k = 0; k < CBM_MINHASH_K; k++) { |
| 224 | for (int rep = 0; rep < w; rep++) { |
| 225 | uint64_t seed = ((uint64_t)k * MAX_STRUCTURAL_WEIGHT) + (uint64_t)rep; |
| 226 | uint64_t h = XXH3_64bits_withSeed(trigram, (size_t)len, seed); |
| 227 | uint32_t h32 = (uint32_t)(h & U32_MASK); |
| 228 | if (h32 < out->values[k]) { |
| 229 | out->values[k] = h32; |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | static int hash_trigrams(const char **tokens, int token_count, cbm_minhash_t *out) { |
| 236 | for (int k = 0; k < CBM_MINHASH_K; k++) { |