ProductPromotion
Logo

Node.JS

made by https://0x3d.site

GitHub - retextjs/retext: natural language processor powered by plugins part of the @unifiedjs collective
natural language processor powered by plugins part of the @unifiedjs collective - retextjs/retext
Visit Site

GitHub - retextjs/retext: natural language processor powered by plugins part of the @unifiedjs collective

GitHub - retextjs/retext: 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 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 to check spelling, fix typography, or make sure text is readable.

Contents

What is this?

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…”
import retextLatin from 'retext-latin'
import retextSmartyPants from 'retext-smartypants'
import retextStringify from 'retext-stringify'
import {unified} from 'unified'

const file = await unified()
  .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 warning
import retextEnglish from 'retext-english'
import retextRedundantAcronyms from 'retext-redundant-acronyms'
import retextStringify from 'retext-stringify'
import {unified} from 'unified'
import {reporter} from 'vfile-reporter'

const file = await unified()
  .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:

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 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.
 */
export function myRetextPluginAcceptingOptions(options) {
  /**
   * @param {Root} tree
   *   Tree.
   * @param {VFile} file
   *   File.
   * @returns {undefined}
   *   Nothing.
   */
  return function (tree, file) {
    // Do things.
  }
}

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line compatible with Node.js 16.

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!

License

MIT © Titus Wormer

Articles
to learn more about the nodejs concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about NodeJS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory