• Stars
    star
    2,334
  • Rank 19,705 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

natural language processor powered by plugins part of the @unifiedjs collective

retext

Build Coverage Downloads Size Sponsors Backers Chat

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.

Intro

retext is an ecosystem of plugins that work with natural language as structured data, specifically ASTs (abstract syntax trees). ASTs 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 to check spelling, fix typography, or make sure text is readable.

Contents

What is this?

You can use plugins to fix typography. In:

He said, "A 'simple' english sentence. . .

Out:

He said, “A ‘simple’ english sentence…”

You can use plugins to check natural language. In:

He’s pretty set on beating your butt for sheriff.

Out:

example.txt
  1:1-1:5    warning  `He’s` may be insensitive, use `They`, `It` instead  he-she  retext-equality
  1:33-1:37  warning  Be careful with “butt”, it’s profane in some cases  butt  retext-profanities

⚠ 1 warning

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:

When should I use this?

It is recommended to use unified with retext-english (or retext-dutch) and retext-stringify if your content is in English (or Dutch). Otherwise, if your content is in another Latin-script language, use retext.

Plugins

retext plugins deal with natural language. You can choose from the many plugins that already exist. Here are three good ways to find plugins:

Some plugins are maintained by us here in the @retextjs organization while others are maintained by folks elsewhere. Anyone can make retext plugins, so as always when choosing whether to include dependencies in your project, make sure to carefully assess the quality of retext plugins too.

Types

The retext organization and the unified collective as a whole is fully typed with TypeScript. Types for nlcst are available in @types/nlcst.

For TypeScript to work, it is particularly important to type your plugins correctly. We strongly recommend using the Plugin type from unified with its generics and to use the node types for the syntax trees provided by @types/nlcst.

/**
 * @typedef {import('nlcst').Root} Root
 *
 * @typedef Options
 *   Configuration (optional).
 * @property {boolean} [someField]
 *   Some option.
 */

// To type options and that the it works with `nlcst`:
/** @type {import('unified').Plugin<[Options?], Root>} */
export function myRetextPluginAcceptingOptions(options) {
  // `options` is `Options?`.
  return function (tree, file) {
    // `tree` is `Root`.
  }
}

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+. Our projects sometimes work with older versions, but this is not guaranteed.

Contribute

See contributing.md in retextjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

For info on how to submit a security report, see our security policy.

Sponsor

Support this effort and give back by sponsoring on OpenCollective!

Vercel

Motif

HashiCorp

GitBook

Gatsby

Netlify

Coinbase

ThemeIsle

Expo

Boost Note

Markdown Space

Holloway


You?

License

MIT © Titus Wormer

More Repositories

1

retext-keywords

plugin to extract keywords and key-phrases
JavaScript
322
star
2

retext-equality

plugin to check for possible insensitive, inconsiderate language
JavaScript
156
star
3

awesome-retext

Curated list of awesome retext resources
108
star
4

retext-sentiment

plugin to detect sentiment
JavaScript
97
star
5

retext-simplify

plugin to check phrases for simpler alternatives
JavaScript
91
star
6

retext-readability

plugin to check readability
JavaScript
89
star
7

retext-spell

plugin to check spelling
JavaScript
68
star
8

retext-smartypants

plugin to implement SmartyPants
JavaScript
55
star
9

retext-profanities

plugin to check for profane and vulgar wording
JavaScript
44
star
10

retext-emoji

plugin to support emoji, gemoji, and emoticons
JavaScript
34
star
11

retext-pos

plugin to add part-of-speech (POS) tags
JavaScript
21
star
12

retext-indefinite-article

plugin to check if indefinite articles (a and an) are used correctly
JavaScript
20
star
13

retext-intensify

plugin to check for weak and mitigating wording
JavaScript
17
star
14

retext-passive

plugin to check for passive voice
JavaScript
15
star
15

retext-repeated-words

plugin to check for for repeated words
JavaScript
13
star
16

retext-syntax-mentions

plugin to classify @mentions as syntax, not natural language
JavaScript
10
star
17

retext-sentence-spacing

plugin to check spacing between sentences
JavaScript
10
star
18

retext-quotes

plugin to check quotes and apostrophes
JavaScript
10
star
19

retext-syntax-urls

plugin to classify url-like values as syntax, not natural language
JavaScript
9
star
20

retext-contractions

plugin to check apostrophes in elided contractions
JavaScript
8
star
21

retext-diacritics

plugin to check for proper use of diacritics
JavaScript
6
star
22

retext-redundant-acronyms

plugin to check for redundant acronyms (such as ATM machine to ATM)
JavaScript
5
star
23

ideas

Share ideas for new utilities and tools built with @retextjs
3
star
24

.github

Community health files for retext
2
star