{"id":13749478,"url":"https://github.com/retextjs/retext-keywords","last_synced_at":"2025-05-15T04:04:28.542Z","repository":{"id":18694313,"uuid":"21904210","full_name":"retextjs/retext-keywords","owner":"retextjs","description":"plugin to extract keywords and key-phrases","archived":false,"fork":false,"pushed_at":"2024-10-23T15:15:36.000Z","size":2270,"stargazers_count":333,"open_issues_count":0,"forks_count":32,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-05-07T14:02:19.746Z","etag":null,"topics":["keyword","keyword-extraction","natural-language","retext","retext-plugin","tensorflow","term"],"latest_commit_sha":null,"homepage":"https://retextjs.github.io/retext-keywords/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/retextjs.png","metadata":{"funding":{"github":"unifiedjs","open_collective":"unified"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-16T14:31:13.000Z","updated_at":"2025-04-21T19:39:42.000Z","dependencies_parsed_at":"2024-11-17T23:10:52.214Z","dependency_job_id":null,"html_url":"https://github.com/retextjs/retext-keywords","commit_stats":{"total_commits":192,"total_committers":4,"mean_commits":48.0,"dds":0.015625,"last_synced_commit":"a06bc229b56e99ccfa1b0df8529bf426782ddaff"},"previous_names":["wooorm/retext-keywords"],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retextjs%2Fretext-keywords","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retextjs%2Fretext-keywords/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retextjs%2Fretext-keywords/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retextjs%2Fretext-keywords/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/retextjs","download_url":"https://codeload.github.com/retextjs/retext-keywords/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043298,"owners_count":22004917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["keyword","keyword-extraction","natural-language","retext","retext-plugin","tensorflow","term"],"created_at":"2024-08-03T07:01:02.852Z","updated_at":"2025-05-15T04:04:28.491Z","avatar_url":"https://github.com/retextjs.png","language":"JavaScript","readme":"# retext-keywords\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n**[retext][]** plugin to extract keywords and key phrases.\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`unified().use(retextKeywords[, options])`](#unifieduseretextkeywords-options)\n  * [`Keyphrase`](#keyphrase)\n  * [`Keyword`](#keyword)\n  * [`Options`](#options)\n  * [`PhraseMatch`](#phrasematch)\n  * [`WordMatch`](#wordmatch)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a [unified][] ([retext][]) plugin to extract keywords and key\nphrases from a document, and exposes that metadata on the [file][vfile].\n\n## When should I use this?\n\nYou can use this plugin any time you’re dealing with unified or retext already,\nand are interested in keywords and key phrases.\nImportantly, keywords extraction in NLP is a rather heavy and sometimes fragile\nprocess, so you might be better off manually providing a list of keywords.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install retext-keywords\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport retextKeywords from 'https://esm.sh/retext-keywords@8'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import retextKeywords from 'https://esm.sh/retext-keywords@8?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay our document `example.txt` contains (from [Wikipedia][term-extraction]):\n\n```txt\nTerminology mining, term extraction, term recognition, or glossary extraction, is a subtask of information extraction. The goal of terminology extraction is to automatically extract relevant terms from a given corpus.\n\nIn the semantic web era, a growing number of communities and networked enterprises started to access and interoperate through the internet. Modeling these communities and their information needs is important for several web applications, like topic-driven web crawlers, web services, recommender systems, etc. The development of terminology extraction is essential to the language industry.\n\nOne of the first steps to model the knowledge domain of a virtual community is to collect a vocabulary of domain-relevant terms, constituting the linguistic surface manifestation of domain concepts. Several methods to automatically extract technical terms from domain-specific document warehouses have been described in the literature.\n\nTypically, approaches to automatic term extraction make use of linguistic processors (part of speech tagging, phrase chunking) to extract terminological candidates, i.e. syntactically plausible terminological noun phrases, NPs (e.g. compounds \"credit card\", adjective-NPs \"local tourist information office\", and prepositional-NPs \"board of directors\" - in English, the first two constructs are the most frequent). Terminological entries are then filtered from the candidate list using statistical and machine learning methods. Once filtered, because of their low ambiguity and high specificity, these terms are particularly useful for conceptualizing a knowledge domain or for supporting the creation of a domain ontology. Furthermore, terminology extraction is a very useful starting point for semantic similarity, knowledge management, human translation and machine translation, etc.\n```\n\n…and our module `example.js` contains:\n\n```js\nimport {toString} from 'nlcst-to-string'\nimport {retext} from 'retext'\nimport retextKeywords from 'retext-keywords'\nimport retextPos from 'retext-pos'\nimport {read} from 'to-vfile'\n\nconst file = await retext()\n  .use(retextPos) // Make sure to use `retext-pos` before `retext-keywords`.\n  .use(retextKeywords)\n  .process(await read('example.txt'))\n\nconsole.log('Keywords:')\n\nif (file.data.keywords) {\n  for (const keyword of file.data.keywords) {\n    console.log(toString(keyword.matches[0].node))\n  }\n}\n\nconsole.log()\nconsole.log('Key-phrases:')\n\nif (file.data.keyphrases) {\n  for (const phrase of file.data.keyphrases) {\n    console.log(toString(phrase.matches[0].nodes))\n  }\n}\n```\n\n…then running `node example.js` yields:\n\n```txt\nKeywords:\nterm\nextraction\nTerminology\nweb\ndomain\n\nKey-phrases:\nterminology extraction\nterms\nterm extraction\nknowledge domain\ncommunities\n```\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`retextKeywords`][api-retext-keywords].\n\n### `unified().use(retextKeywords[, options])`\n\nExtract keywords and key phrases.\n\nThe results are stored on `file.data.keyphrases`\n([`Array\u003cKeyphrase\u003e`][api-keyphrase]) and `file.data.keywords`\n([`Array\u003cKeyword\u003e`][api-keyword]).\n\n###### Parameters\n\n* `options` ([`Options`][api-options], optional)\n  — configuration\n\n###### Returns\n\nTransform ([`Transformer`][unified-transformer]).\n\n### `Keyphrase`\n\nInfo on a key phrase (TypeScript type).\n\n###### Fields\n\n* `matches` ([`Array\u003cPhraseMatch\u003e`][api-phrase-match])\n  — all matches\n* `score` (`number`)\n  — score of phrase, for one match\n* `stems` (`Array\u003cstring\u003e`)\n  — stems of phrase\n* `weight` (`number`)\n  — score of phrase, for all matches\n\n### `Keyword`\n\nInfo on a keyword (TypeScript type).\n\n###### Fields\n\n* `matches` ([`Array\u003cWordMatch\u003e`][api-word-match])\n  — all matches\n* `score` (`number`)\n  — score of word, for all matches\n* `stem` (`string`)\n  — stems of word\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n* `maximum` (`number`, default: `5`)\n  — try to detect at most `maximum` words and phrases; actual counts may\n  differ, for example, when two words have the same score, both will be\n  returned; when too few words exist, less will be returned\n\n### `PhraseMatch`\n\nMatch (TypeScript type).\n\n###### Fields\n\n* `nodes` ([`Array\u003cNode\u003e`][nlcst-node])\n  — matched nodes\n* `parent` ([`Node`][nlcst-node])\n  — parent\n\n### `WordMatch`\n\nMatch (TypeScript type).\n\n###### Fields\n\n* `node` ([`Node`][nlcst-node])\n  — matched node\n* `index` (`number`)\n  — index of `node` in `parent`\n* `parent` ([`Node`][nlcst-node])\n  — parent\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types\n[`Keyphrase`][api-keyphrase],\n[`Keyword`][api-keyword],\n[`Options`][api-options],\n[`PhraseMatch`][api-phrase-match], and\n[`WordMatch`][api-word-match].\n\nIt also registers the `file.data` fields with `vfile`.\nIf you’re working with the file, make sure to import this plugin somewhere in\nyour types, as that registers the new fields on the file.\n\n```js\n/**\n * @import {} from 'retext-keywords'\n */\n\nimport {VFile} from 'vfile'\n\nconst file = new VFile()\n\nconsole.log(file.data.keywords) //=\u003e TS now knows this is `Array\u003cKeyword\u003e | undefined`.\n```\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `retext-keywords@^8`,\ncompatible with Node.js 16.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`retextjs/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/retextjs/retext-keywords/workflows/main/badge.svg\n\n[build]: https://github.com/retextjs/retext-keywords/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/retextjs/retext-keywords.svg\n\n[coverage]: https://codecov.io/github/retextjs/retext-keywords\n\n[downloads-badge]: https://img.shields.io/npm/dm/retext-keywords.svg\n\n[downloads]: https://www.npmjs.com/package/retext-keywords\n\n[size-badge]: https://img.shields.io/bundlejs/size/retext-keywords\n\n[size]: https://bundlejs.com/?q=retext-keywords\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/retextjs/retext/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[health]: https://github.com/retextjs/.github\n\n[contributing]: https://github.com/retextjs/.github/blob/main/contributing.md\n\n[support]: https://github.com/retextjs/.github/blob/main/support.md\n\n[coc]: https://github.com/retextjs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[term-extraction]: https://en.wikipedia.org/wiki/Terminology_extraction\n\n[nlcst-node]: https://github.com/syntax-tree/nlcst?tab=readme-ov-file#nodes\n\n[retext]: https://github.com/retextjs/retext\n\n[unified]: https://github.com/unifiedjs/unified\n\n[unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[vfile]: https://github.com/vfile/vfile\n\n[api-keyphrase]: #keyphrase\n\n[api-keyword]: #keyword\n\n[api-options]: #options\n\n[api-phrase-match]: #phrasematch\n\n[api-retext-keywords]: #unifieduseretextkeywords-options\n\n[api-word-match]: #wordmatch\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["JavaScript","📦 Legacy \u0026 Inactive Projects","Plugins"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretextjs%2Fretext-keywords","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretextjs%2Fretext-keywords","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretextjs%2Fretext-keywords/lists"}