Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork92
natural language processor powered by plugins part of the@unifiedjs collective
License
retextjs/retext
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
retext is a tool that transforms natural language with plugins.These plugins can inspect and change the natural language.You can use retext on the server, the client, deno, etc.
retext is an ecosystem of plugins that work with natural language as structureddata, specifically CSTs (concrete syntax trees).Syntax trees make it easy for programs to deal with prose.We call those programs plugins.Plugins inspect and change trees.You can use the many existing plugins or you can make your own.Some example use cases are tocheck spelling,fix typography, ormake sure text is readable.
- for more about us, see
unifiedjs.com - for questions, seesupport
- to help, seecontribute orsponsor below
With this project and a plugin, you can turn simple punctuation:
He said, "A 'simple' english sentence. . .…into smart punctuation:
He said, “A ‘simple’ english sentence…”Show example code
importretextLatinfrom'retext-latin'importretextSmartyPantsfrom'retext-smartypants'importretextStringifyfrom'retext-stringify'import{unified}from'unified'constfile=awaitunified().use(retextLatin).use(retextSmartyPants).use(retextStringify).process("He said, \"A 'simple' english sentence. . .")console.log(String(file))
With another plugin, you can check natural language:
In:
Where can I find an ATM machine?Out:
1:21-1:32 warning Unexpected redundant `ATM machine`, expected `ATM` atm retext-redundant-acronyms⚠ 1 warningShow example code
importretextEnglishfrom'retext-english'importretextRedundantAcronymsfrom'retext-redundant-acronyms'importretextStringifyfrom'retext-stringify'import{unified}from'unified'import{reporter}from'vfile-reporter'constfile=awaitunified().use(retextEnglish).use(retextRedundantAcronyms).use(retextStringify).process('Where can I find an ATM machine?')console.log(reporter(file))
…and you can make your own plugins.
You can use retext for many different things.unified is the core project that transforms content with ASTs.retext adds support for natural language to unified.nlcst is the natural language AST that retext uses.
This GitHub repository is a monorepo that contains the following packages:
retext-dutch— parse Dutch prose to a syntax treeretext-english— parse English prose to a syntax treeretext-latin— parse any Latin-script prose to a syntax treeretext-stringify— serialize a syntax treeretext— programmatic interface with bothretext-latinandretext-stringify
It is recommended to useunified withretext-english (orretext-dutch)andretext-stringify if your content is in English (or Dutch).Otherwise, if your content is in another Latin-script language, useretext.
retext plugins deal with natural language.You can choose from the many plugins that already exist.Here are three good ways to find plugins:
awesome-retext— selection of the most awesome projects- List of plugins— list of all plugins
retext-plugintopic— any tagged repo on GitHub
Some plugins are maintained by us here in the@retextjs organization whileothers are maintained by folks elsewhere.Anyone can make retext plugins, so as always when choosing whether to includedependencies in your project, make sure to carefully assess the quality ofretext plugins too.
The retext organization and the unified collective as a whole is fully typedwithTypeScript.Types for nlcst are available in@types/nlcst.
For TypeScript to work, it is important to type your plugins.For example:
/** *@import {Root} from 'nlcst' *//** *@typedef Options * Configuration (optional). *@property {boolean | null | undefined} [someField] * Some option. *//** * My plugin. * *@param {Options | null | undefined} [options] * Configuration (optional). *@returns * Transform. */exportfunctionmyRetextPluginAcceptingOptions(options){/** *@param {Root} tree * Tree. *@param {VFile} file * File. *@returns {undefined} * Nothing. */returnfunction(tree,file){// Do things.}}
Projects maintained by the unified collective are compatible with maintainedversions of Node.js.
When we cut a new major release, we drop support for unmaintained versions ofNode.This means we try to keep the current release line compatible with Node.js 16.
Seecontributing.md inretextjs/.github for waysto get started.Seesupport.md for ways to get help.
This project has acode of conduct.By interacting with this repository, organization, or community you agree toabide by its terms.
For info on how to submit a security report, see oursecurity policy.
Support this effort and give back by sponsoring onOpenCollective!
| Vercel | Motif | HashiCorp | GitBook | Gatsby | |||||
Netlify![]() | Coinbase | ThemeIsle | Expo | Boost Note![]() | Markdown Space![]() | Holloway | |||
You? | |||||||||
About
natural language processor powered by plugins part of the@unifiedjs collective
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.


