{"_id":"@apto-space/moving-ngrams","name":"@apto-space/moving-ngrams","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@apto-space/moving-ngrams","module":"index.ts","type":"module","version":"0.0.1","devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5.0.0"},"dependencies":{"@mobily/ts-belt":"^3.13.1"},"_id":"@apto-space/moving-ngrams@0.0.1","gitHead":"5c1300010b2a14cdfc36ce710a03faf6dac7edc1","description":"A utility package for generating all possible n-gram combinations from a sequence of words, useful for search engine query analysis and natural language processing tasks.","_nodeVersion":"22.2.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-sb3I1I/RfC8hEmC7HAIJl65l5VvivEY9IPP3gXoloVAiDypP28AQnAF/hRxj6GWWhl0uOs/AgK+etfMKwZ0etg==","shasum":"e1d63f84f972471cbabfaaef8723e4142a5ee21a","tarball":"https://registry.npmjs.org/@apto-space/moving-ngrams/-/moving-ngrams-0.0.1.tgz","fileCount":7,"unpackedSize":11176,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHX/8FimoutG4SUJ2JX4Oy5MNoHTpchv+cONrJ2zPBsuAiEAn70/bjv+TWUKOX0FxevlSLHGpwvD7Wm/zMPuSkjwfBQ="}]},"_npmUser":{"name":"janwirth","email":"contact@jan-wirth.de"},"directories":{},"maintainers":[{"name":"janwirth","email":"contact@jan-wirth.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/moving-ngrams_0.0.1_1741540771212_0.7537448865482836"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-09T17:19:31.144Z","0.0.1":"2025-03-09T17:19:31.427Z","modified":"2025-03-09T17:19:31.698Z"},"maintainers":[{"name":"janwirth","email":"contact@jan-wirth.de"}],"description":"A utility package for generating all possible n-gram combinations from a sequence of words, useful for search engine query analysis and natural language processing tasks.","readme":"# moving-ngrams\n\nA utility package for generating all possible n-gram combinations from a sequence of words, useful for search engine query analysis and natural language processing tasks.\n\n## Description\n\n`moving-ngrams` helps you analyze text by generating all possible meaningful combinations of consecutive words. This is particularly useful for:\n\n- Search engine query analysis\n- Automatic keyphrase extraction\n- Faceted search implementation\n- Natural language understanding\n\n## Installation\n\n```bash\n# Using bun\nbun add moving-ngrams\n\n# Using npm\nnpm install moving-ngrams\n\n# Using yarn\nyarn add moving-ngrams\n```\n\n## Usage\n\n```typescript\nimport { movingNgrams } from 'moving-ngrams';\n\n// Example 1: Simple phrase analysis\nconst result = movingNgrams(['hello', 'world']);\nconsole.log(result);\n/* Output:\n[\n  [['hello'], ['world']],      // Individual words\n  [['hello', 'world']]         // Combined phrase\n]\n*/\n\n// Example 2: Search query analysis\nconst searchQuery = movingNgrams(['elon', 'musk', 'san', 'francisco']);\nconsole.log(searchQuery);\n/* Output will include all possible combinations like:\n- [['elon'], ['musk'], ['san'], ['francisco']]\n- [['elon', 'musk'], ['san'], ['francisco']]\n- [['elon'], ['musk', 'san'], ['francisco']]\n- [['elon'], ['musk'], ['san', 'francisco']]\n... and more combinations\n*/\n```\n\n## Use Cases\n\n### 1. Search Query Analysis\nWhen users enter a search query like \"Elon Musk San Francisco\", the package helps you analyze all possible meaningful combinations:\n- Individual terms: \"Elon\", \"Musk\", \"San\", \"Francisco\"\n- Compound terms: \"Elon Musk\", \"San Francisco\"\n- Mixed combinations: [\"Elon Musk\", \"San Francisco\"], [\"Elon\", \"Musk San Francisco\"], etc.\n\nThis is particularly useful for:\n- Improving search relevance\n- Understanding user intent\n- Supporting multi-term matching\n\n### 2. Keyphrase Extraction\nWhen analyzing text content, you can use this to:\n- Extract potential keyphrases\n- Identify compound terms\n- Generate search indices\n\n## API\n\n```typescript\nfunction movingNgrams(words: string[]): string[][][]\n```\n\n- **Input**: Array of words\n- **Output**: Array of all possible combinations where each combination is an array of word groups\n\n## License\n\nMIT\n\n---\n\nThis project was created using [Bun](https://bun.sh) v1.1.41.\n","readmeFilename":"README.md","_rev":"1-dc22fdd6a9683fd0ee432550bdf94f97"}