0.1.1 • Published 2 years ago

@biu/simhash v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

simhash

Javascript implementation for simhash algorithm which is widely used by Google for massive web pages

Installation

npm i @biu/simhash

Usage

const { simhash, similarity } = require( '@biu/simhash' )

const hash1 = simhash( [
  {
    text: '你',
    weight: 1,
  },
  {
    text: '好',
    weight: 1,
  },
  {
    text: '世界',
    weight: 2,
  }
] )

const hash2 = simhash( [
  {
    text: '你',
    weight: 1,
  },
  {
    text: '呀',
    weight: 1,
  },
  {
    text: '世界',
    weight: 1,
  }
] )

console.log( similarity( hash1, hash2 ) ) // -> 0.78125

License

MIT