{"_id":"@basementuniverse/bm25","_rev":"1-92f915865222ada80c02db951eeefc70","name":"@basementuniverse/bm25","description":"Search for terms in an array of documents","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"@basementuniverse/bm25","version":"0.0.1","keywords":["okapi","bm25","search","find","rank"],"author":{"url":"https://gordonlarrigan.com","name":"Gordon Larrigan","email":"gordonlarrigan@gmail.com"},"license":"MIT","_id":"@basementuniverse/bm25@0.0.1","maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"homepage":"https://github.com/basementuniverse/bm25#readme","bugs":{"url":"https://github.com/basementuniverse/bm25/issues"},"dist":{"shasum":"18017b49239322a1d0535f23d4ff212d89f04be6","tarball":"https://registry.npmjs.org/@basementuniverse/bm25/-/bm25-0.0.1.tgz","fileCount":6,"integrity":"sha512-YlO9gfTju6bK85q8f99KTnq6RuQddZ3lXeMSJQacAqTViy8KAHS4Tk3/dZTw/UY3mZPfjM8OEjGSJa8YqEuz/g==","signatures":[{"sig":"MEUCIE8u8iK/tZekdOPynQz3J3jQThkcgrEwaHa9Bt1zpEF9AiEAn+mKSzD6UzXMFeRKXMmB/pVS2CRqZMjvx8Lzf8WDdys=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6798},"main":"build/index.js","types":"./build/index.d.ts","gitHead":"d9b6aad193cc7252946047784f86facf85b47194","scripts":{"test":"jest","build":"tsc"},"_npmUser":{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"},"repository":{"url":"git+https://github.com/basementuniverse/bm25.git","type":"git"},"_npmVersion":"9.5.1","description":"Search for terms in an array of documents","directories":{},"_nodeVersion":"18.16.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.1","typescript":"^5.3.2","@types/jest":"^29.5.10"},"_npmOperationalInternal":{"tmp":"tmp/bm25_0.0.1_1708645241110_0.1463946405229808","host":"s3://npm-registry-packages"}},"0.1.0":{"name":"@basementuniverse/bm25","version":"0.1.0","description":"Search for terms in an array of documents","main":"build/index.js","scripts":{"build":"tsc","test":"jest"},"keywords":["okapi","bm25","search","find","rank"],"author":{"name":"Gordon Larrigan","email":"gordonlarrigan@gmail.com","url":"https://gordonlarrigan.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/basementuniverse/bm25.git"},"devDependencies":{"@types/jest":"^29.5.10","jest":"^29.7.0","ts-jest":"^29.1.1","typescript":"^5.3.2"},"types":"./build/index.d.ts","gitHead":"f352efea1cc714d15a08afca067db5ef24f5e169","bugs":{"url":"https://github.com/basementuniverse/bm25/issues"},"homepage":"https://github.com/basementuniverse/bm25#readme","_id":"@basementuniverse/bm25@0.1.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-8NJtip+Iguw7jmA9MdSi9JoxshvmQJzX3RaKAKrGERFDpO161Tj1ULVjqQlynvl4lce1z8UMnLEDD0ULPsOYBA==","shasum":"32767e407b90713df68f91872ef0e967ea5b7e36","tarball":"https://registry.npmjs.org/@basementuniverse/bm25/-/bm25-0.1.0.tgz","fileCount":6,"unpackedSize":6860,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCoOWgQm+lH6HTAW3nLOwiwX+UxU3SSovF8hgsq5+nd8QIhAJBDhfJTztCgdJJqFl+cd5Xb1yko+RuF/D455R86mGmm"}]},"_npmUser":{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"},"directories":{},"maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bm25_0.1.0_1717061369405_0.25024082393007463"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-22T23:40:41.014Z","modified":"2024-05-30T09:29:29.713Z","0.0.1":"2024-02-22T23:40:41.261Z","0.1.0":"2024-05-30T09:29:29.539Z"},"maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"author":{"name":"Gordon Larrigan","email":"gordonlarrigan@gmail.com","url":"https://gordonlarrigan.com"},"repository":{"type":"git","url":"git+https://github.com/basementuniverse/bm25.git"},"keywords":["okapi","bm25","search","find","rank"],"license":"MIT","homepage":"https://github.com/basementuniverse/bm25#readme","bugs":{"url":"https://github.com/basementuniverse/bm25/issues"},"readme":"# Okapi BM25\n\nSearch for terms in an array of documents using [Okapi BM25](https://en.wikipedia.org/wiki/Okapi_BM25).\n\n## Installation\n\n```\nnpm install -g @basementuniverse/bm25\n```\n\n## Usage\n\n```typescript\nimport { Corpus } from '@basementuniverse/bm25';\n\nconst corpus = new Corpus([\n  'This is a document',\n  'Here is another document',\n]);\n\nconst results = corpus.search('document');\n```\n\n`results` will look something like:\n\n```json\n[\n  {\n    \"document\": \"This is a document\",\n    \"score\": 0.5\n  },\n  {\n    \"document\": \"Here is another document\",\n    \"score\": 0.5\n  }\n]\n```\n\nThe documents passed into the `Corpus` constructor will be treated as strings by default, and will be converted to lowercase and split by non-word characters.\n\nHowever, it is possible to pass in values of any type here, as long as you provide a function to convert each value to an array of strings. For example:\n\n```typescript\nconst corpus = new Corpus(\n  [\n    {\n      id: '1234',\n      name: 'John Doe',\n    },\n    {\n      id: '2345',\n      name: 'Jane Doe',\n    },\n  ],\n  {\n    processor: document => [document.id, ...document.name.toLowerCase().split(' ')],\n  },\n);\n```\n\nPartial term matching can be enabled by passing `true` as the second argument to `search()`:\n\n```typescript\nconst results = corpus.search('doe', true);\n```\n\n## Options\n\nThe 2nd argument to the `Corpus` constructor is an options object, which can contain the following properties:\n\n- `processor` (function) - A function to convert each document to an array of strings.\n- `k1` (number between 1.2 and 2, default: 1.5) - Controls the impact of term frequency saturation.\n- `b` (number between 0 and 1, default: 0.75) - Controls how much the document length affects the term frequency score.\n- `gamma` (number, default: 1) - Addresses a deficiency of BM25 in which term frequency normalization by document length is not properly lower-bounded.\n","readmeFilename":"README.md"}