{"_id":"@agtabesh/lsh","_rev":"1-f56ceb0eb7d1dae04cd828425c13c27e","name":"@agtabesh/lsh","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@agtabesh/lsh","version":"0.1.0","description":"Locality-Sensitive Hashing implementation in node.js for fast and scalable approximate nearest neighbors search","main":"src/index.js","scripts":{"test":"jest"},"author":{"name":"Ahmad Ganjtabesh"},"license":"MIT","keywords":["locality sensitive hashing","lsh","similarity","minhash"],"dependencies":{"@adonisjs/fold":"^4.0.9","murmurhash-native":"^3.3.0","random-words":"^1.1.0"},"devDependencies":{"jest":"^24.5.0"},"gitHead":"0753b87fbec1b1e24e91528979d59e57b8792425","_id":"@agtabesh/lsh@0.1.0","_nodeVersion":"10.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-sgMrb2bTWljBdUGH9zbWnGABl5aliyY5UbcownN4cEA9Amzj6CRswI0v5a7E64L2XU7VsoKMPhsRpFaK8usKPQ==","shasum":"4a972ee0024578554c9e5d760ce4d9480efc3fe0","tarball":"https://registry.npmjs.org/@agtabesh/lsh/-/lsh-0.1.0.tgz","fileCount":15,"unpackedSize":14180,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcoTtXCRA9TVsSAnZWagAAfEAP/RoTDdaVH83GBpztoEOB\nQd38Myn0Hv1uUlFdjZvuvh/9qp1wE+TNGnJyW57yEjZX1FZ8F3qlXz9YnV6w\nz4ZKSA0e94tHwNynSCECZXNaPy+S999z1oRIk5BGQsJOcKTiPd3lhqzwfdjL\nt2Js430WIo0B5CSHb34Zr3tZgGe33Op3/3JLH1JUucpArd7TQR8WU86nUZ43\nklDMadpTtCqOworH0NIJHNdz+fcpPOyVtWv+/bQbt6IVaviFaC6BECxPMiHk\n7iAtWyqeECkIgajo9vkcaUluAPLOJHoGwVGZWsTEyQ+RGnbpjriHjyg1f4wj\nhLYBNLnpl7neK9J5GMEdwKY/zZRCPC0KAmDXyAgqYlo0r2zZ2EmWHh4zZJZv\nH9290PLp0ah21K9VKxuXLTxYPIJ6vJYIeSwR2uSpIDZ+pMy3kC8Tk7Tb+Ubn\nNZeUa+fRtrxiuFjV23KhlWyPLeDFw1bGQO7f/qpuWL8KlkcAQQbLBWuaNTqb\nddGafR/aX8FQgCFZKDynWscFAm1vF5qtXJDJruseE9NPDZHJCZ4S06j5HP4Q\nTK23gQPdowNnBp64dUWlBa+yTPAZ5UmJ7sxDcLLXeP2HUR6yQX3q6i91C8cb\nbN2OXj57cEfksYxsA4YCcCCdtaJH39VAjH02ThgIL2mBAHb7Yeh87nEmsTou\n71Xt\r\n=E3cp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBdfx+s4jDlQAEef7asOFGykJpHl1Z/uh/rKSE7O2ATSAiAxglexkBhQOimdDdDvBOiaVO+XiXPo0HG3CZKwLBYPZg=="}]},"maintainers":[{"name":"agtabesh","email":"ifireir@gmail.com"}],"_npmUser":{"name":"agtabesh","email":"ifireir@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lsh_0.1.0_1554070358583_0.5617543431396812"},"_hasShrinkwrap":false}},"time":{"created":"2019-03-31T22:12:38.327Z","0.1.0":"2019-03-31T22:12:38.719Z","modified":"2022-04-04T12:08:42.349Z"},"maintainers":[{"name":"agtabesh","email":"ifireir@gmail.com"}],"description":"Locality-Sensitive Hashing implementation in node.js for fast and scalable approximate nearest neighbors search","keywords":["locality sensitive hashing","lsh","similarity","minhash"],"author":{"name":"Ahmad Ganjtabesh"},"license":"MIT","readme":"# Locality-Sensitive Hashing\n\n[Locality-sensitive hashing](https://en.wikipedia.org/wiki/Locality-sensitive_hashing)\n(LSH) reduces the dimensionality of high-dimensional data and hashes input items so that similar items map to the same “buckets” with high probability (the number of buckets being much smaller than the universe of possible input items).\n\n\n[![npm (scoped)](https://img.shields.io/badge/npm-v0.1.0-brightgreen.svg)](https://www.npmjs.com/package/@agtabesh/lsh)\n[![npm (scoped)](https://img.shields.io/badge/license-MIT-red.svg)](https://www.npmjs.com/package/@agtabesh/lsh)\n[![npm (scoped)](https://img.shields.io/badge/repository-github-lightgrey.svg)](https://github.com/agtabesh/lsh)\n\n## Install\n\n```\n$ npm install lsh --save\n```\n\n## Usage\n\nTo figure out how to use this package please take a look at test files\n\n```js\nconst RandomWords = require('random-words')\nconst Lsh = require('@agtabesh/lsh')\n\nconst config = {\n  storage: 'memory',\n  shingleSize: 5,\n  numberOfHashFunctions: 120\n}\nconst lsh = Lsh.getInstance(config)\n\nconst numberOfDocuments = 100\nconst documents = []\n\n// generate random documents containing 100 words each\nfor (let i = 0; i < numberOfDocuments; i += 1) {\n  documents.push(RandomWords({ min: 100, max: 100 }).join(' '))\n}\n\n// add documents just created to LSH with their id\nfor (let i = 0; i < numberOfDocuments; i += 1) {\n  lsh.addDocument(i, documents[i])\n}\n\n// search for a specific document with its id and custom bicketSize\n// you can also perform a query using a string by passing text instead of id\n// bucket size are dynamic. feel free to change it to find proper one\nconst q = {\n  id: 1,\n  // text: 'this is a sample text to search for',\n  bucketSize: 6\n}\nconst result = lsh.query(q)\n\n// this will print out documents which are candidates to be similar to the one we are looking for\nconsole.log(result)\n```\n\nIt's incredibly fast. No matter how many documents you have, time complexity is always constant. Its Dependencies are injected by using [@adonisjs/fold](https://www.npmjs.com/package/@adonisjs/fold) which allows us to extend the package freely. There is only one storage and I'll be appreciated if you would implement the other storages such as [Redis](https://redis.io/) and submit a pull request.\n\nIn this package, [MurmurHash](https://en.wikipedia.org/wiki/MurmurHash), a non-cryptographic hash function which is faster than cryptographic hash function, is used.\n\n## Running tests\n\nYou can run the test suite using the following commands:\n```\nnpm test\n```\n\n**All contributions are welcome. Please ensure that the tests are passing when submitting a pull request. If you're adding new features to this package, please include tests.**\n\n\n## Release History\n0.1.0 - Initial release, basic functionality and supports memory storage.\n","readmeFilename":"README.md"}