Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

retext

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retext - npm Package Compare versions

Comparing version 0.2.0-rc.5 to 0.2.0

2

package.json
{
"name": "retext",
"version": "0.2.0-rc.5",
"version": "0.2.0",
"description": "Extensible system for analysing and manipulating natural language",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -40,42 +40,40 @@ # ![Retext logo](http://i58.tinypic.com/5xpx5z.png)

emoji = require('retext-emoji'),
smartypants = require('retext-smartypants'),
input,
retext;
smartypants = require('retext-smartypants');
/* Create an instance using retext-emoji and -smartypants. */
retext = new Retext()
.use(emoji({
'convert' : 'encode'
}))
.use(smartypants());
var retext = new Retext()
.use(emoji({
'convert' : 'encode'
}))
.use(smartypants());
/* Read a document. */
retext.parse(
'The three wise monkeys [. . .] sometimes called the ' +
'three mystic apes--are a pictorial maxim. Together ' +
'they embody the proverbial principle to ("see no evil, ' +
'hear no evil, speak no evil"). The three monkeys are ' +
'Mizaru (:see_no_evil:), covering his eyes, who sees no ' +
'evil; Kikazaru (:hear_no_evil:), covering his ears, ' +
'who hears no evil; and Iwazaru (:speak_no_evil:), ' +
'covering his mouth, who speaks no evil.',
function (err, tree) {
/* Handle errors. */
if (err) {
throw err;
'The three wise monkeys [. . .] sometimes called the ' +
'three mystic apes--are a pictorial maxim. Together ' +
'they embody the proverbial principle to ("see no evil, ' +
'hear no evil, speak no evil"). The three monkeys are ' +
'Mizaru (:see_no_evil:), covering his eyes, who sees no ' +
'evil; Kikazaru (:hear_no_evil:), covering his ears, ' +
'who hears no evil; and Iwazaru (:speak_no_evil:), ' +
'covering his mouth, who speaks no evil.',
function (err, tree) {
/* Handle errors. */
if (err) {
throw err;
}
/* Log the text content of the tree (the transformed input). */
console.log(tree.toString());
/**
* This logs the following:
* The three wise monkeys […] sometimes called the three
* mystic apes—are a pictorial maxim. Together they
* embody the proverbial principle to (“see no evil,
* hear no evil, speak no evil”). The three monkeys are
* Mizaru (🙈), covering his eyes, who sees no evil;
* Kikazaru (🙉), covering his ears, who hears no evil;
* and Iwazaru (🙊), covering his mouth, who speaks no evil.
*/
}
/* Log the text content of the tree (the transformed input). */
console.log(tree.toString());
/**
* This logs the following:
* The three wise monkeys […] sometimes called the three
* mystic apes—are a pictorial maxim. Together they
* embody the proverbial principle to (“see no evil,
* hear no evil, speak no evil”). The three monkeys are
* Mizaru (🙈), covering his eyes, who sees no evil;
* Kikazaru (🙉), covering his ears, who hears no evil;
* and Iwazaru (🙊), covering his mouth, who speaks no evil.
*/
}
);

@@ -89,12 +87,8 @@ ```

```js
var Retext = require('./'),
ParseEnglish = require('parse-english'),
retext;
var Retext = require('retext'),
ParseEnglish = require('parse-english');
retext = new Retext(new ParseEnglish());
var retext = new Retext(new ParseEnglish());
/**
* There, ol' chap.
*/
/* There, ol’ chap. */
retext.parse(/* ...some English... */, function (err, tree) {/* ... */});

@@ -105,7 +99,7 @@ ```

### Retext.prototype.use(plugin)
### Retext#use(plugin)
Takes a plugin—a humble function. When `Retext#parse` is invoked, the plugin will be invoked with the parsed tree, and the **Retext** instance as arguments. Returns self.
Takes a plugin—a humble function. When `Retext#parse()` is invoked, the plugin will be invoked with the parsed tree, and the **Retext** instance as arguments. Returns self.
### Retext.prototype.parse(value, callback)
### Retext#parse(value, function(Error, Node))

@@ -116,25 +110,25 @@ Parses the given source and when done passes either an error (the first argument), or the (by `use`d plugins, modified) tree (the second argument) to the callback.

* [retext-ast](https://github.com/wooorm/retext-ast) — Encoding and decoding between AST (JSON) and TextOM object model;
* [retext-content](https://github.com/wooorm/retext-content) — Append, prepend, remove, and replace content into/from Retext nodes;
* [retext-directionality](https://github.com/wooorm/retext-directionality) — (**[demo](http://wooorm.github.io/retext-directionality/)**) — Detect the direction text is written in;
* [retext-dom](https://github.com/wooorm/retext-dom) — (**[demo](http://wooorm.github.io/retext-dom/)**) — Create a (living) DOM tree from a TextOM tree;
* [retext-double-metaphone](https://github.com/wooorm/retext-double-metaphone) — (**[demo](http://wooorm.github.io/retext-double-metaphone/)**) — Implementation of the Double Metaphone algorithm;
* [retext-emoji](https://github.com/wooorm/retext-emoji) — (**[demo](http://wooorm.github.io/retext-emoji/)**) — Encode or decode [Gemojis](https://github.com/github/gemoji);
* [retext-find](https://github.com/wooorm/retext-find) — Easily find nodes;
* [retext-inspect](https://github.com/wooorm/retext-inspect) — Nicely display nodes in `console.log` calls;
* [retext-keywords](https://github.com/wooorm/retext-keywords) — Extract keywords and keyphrases;
* [retext-lancaster-stemmer](https://github.com/wooorm/retext-lancaster-stemmer) — (**[demo](http://wooorm.github.io/retext-lancaster-stemmer/)**) — Implementation of [the Lancaster (Paice/Husk) algorithm](http://www.comp.lancs.ac.uk/computing/research/stemming/index.htm);
* [retext-language](https://github.com/wooorm/retext-language) — (**[demo](http://wooorm.github.io/retext-language/)**) — Detect the language of text;
* [retext-link](https://github.com/wooorm/retext-link) — (**[demo](http://wooorm.github.io/retext-link/)**) — Detect links in text;
* [retext-metaphone](https://github.com/wooorm/retext-metaphone) — (**[demo](http://wooorm.github.io/retext-metaphone/)**) — Implementation of the Metaphone algorithm;
* [retext-porter-stemmer](https://github.com/wooorm/retext-porter-stemmer) — (**[demo](http://wooorm.github.io/retext-porter-stemmer/)**) — Implementation of [the Porter stemming algorithm](http://tartarus.org/martin/PorterStemmer/);
* [retext-pos](https://github.com/wooorm/retext-pos) — Part-of-speech tagger;
* [retext-range](https://github.com/wooorm/retext-range) — Sequences of content within a TextOM tree between two points;
* [retext-search](https://github.com/wooorm/retext-search) — (**[demo](http://wooorm.github.io/retext-search/)**) — Search in a TextOM tree;
* [retext-sentiment](https://github.com/wooorm/retext-sentiment) — (**[demo](http://wooorm.github.io/retext-sentiment/)**) — Detect sentiment in text;
* [retext-smartypants](https://github.com/wooorm/retext-smartypants) — (**[demo](http://wooorm.github.io/retext-smartypants/)**) — Implementation of [SmartyPants](http://daringfireball.net/projects/smartypants/);
* [retext-soundex](https://github.com/wooorm/retext-soundex) — (**[demo](http://wooorm.github.io/retext-soundex/)**) — Implementation of the Soundex algorithm;
* [retext-syllable](https://github.com/wooorm/retext-syllable) — Syllable count;
* [retext-visit](https://github.com/wooorm/retext-visit) — (**[demo](http://wooorm.github.io/retext-visit/)**) — Visit nodes, optionally by type;
* [retext-walk](https://github.com/wooorm/retext-walk) — Walk trees, optionally by type.
- [retext-ast](https://github.com/wooorm/retext-ast) — Encoding and decoding between AST (JSON) and TextOM object model;
- [retext-content](https://github.com/wooorm/retext-content) — Append, prepend, remove, and replace content into/from Retext nodes;
- [retext-directionality](https://github.com/wooorm/retext-directionality) — (**[demo](http://wooorm.github.io/retext-directionality/)**) — Detect the direction text is written in;
- [retext-dom](https://github.com/wooorm/retext-dom) — (**[demo](http://wooorm.github.io/retext-dom/)**) — Create a (living) DOM tree from a TextOM tree;
- [retext-double-metaphone](https://github.com/wooorm/retext-double-metaphone) — (**[demo](http://wooorm.github.io/retext-double-metaphone/)**) — Implementation of the Double Metaphone algorithm;
- [retext-emoji](https://github.com/wooorm/retext-emoji) — (**[demo](http://wooorm.github.io/retext-emoji/)**) — Encode or decode [Gemojis](https://github.com/github/gemoji);
- [retext-find](https://github.com/wooorm/retext-find) — Easily find nodes;
- [retext-inspect](https://github.com/wooorm/retext-inspect) — Nicely display nodes in `console.log` calls;
- [retext-keywords](https://github.com/wooorm/retext-keywords) — Extract keywords and keyphrases;
- [retext-lancaster-stemmer](https://github.com/wooorm/retext-lancaster-stemmer) — (**[demo](http://wooorm.github.io/retext-lancaster-stemmer/)**) — Implementation of [the Lancaster (Paice/Husk) algorithm](http://www.comp.lancs.ac.uk/computing/research/stemming/index.htm);
- [retext-language](https://github.com/wooorm/retext-language) — (**[demo](http://wooorm.github.io/retext-language/)**) — Detect the language of text;
- [retext-link](https://github.com/wooorm/retext-link) — (**[demo](http://wooorm.github.io/retext-link/)**) — Detect links in text;
- [retext-metaphone](https://github.com/wooorm/retext-metaphone) — (**[demo](http://wooorm.github.io/retext-metaphone/)**) — Implementation of the Metaphone algorithm;
- [retext-porter-stemmer](https://github.com/wooorm/retext-porter-stemmer) — (**[demo](http://wooorm.github.io/retext-porter-stemmer/)**) — Implementation of [the Porter stemming algorithm](http://tartarus.org/martin/PorterStemmer/);
- [retext-pos](https://github.com/wooorm/retext-pos) — Part-of-speech tagger;
- [retext-range](https://github.com/wooorm/retext-range) — Sequences of content within a TextOM tree between two points;
- [retext-search](https://github.com/wooorm/retext-search) — (**[demo](http://wooorm.github.io/retext-search/)**) — Search in a TextOM tree;
- [retext-sentiment](https://github.com/wooorm/retext-sentiment) — (**[demo](http://wooorm.github.io/retext-sentiment/)**) — Detect sentiment in text;
- [retext-smartypants](https://github.com/wooorm/retext-smartypants) — (**[demo](http://wooorm.github.io/retext-smartypants/)**) — Implementation of [SmartyPants](http://daringfireball.net/projects/smartypants/);
- [retext-soundex](https://github.com/wooorm/retext-soundex) — (**[demo](http://wooorm.github.io/retext-soundex/)**) — Implementation of the Soundex algorithm;
- [retext-syllable](https://github.com/wooorm/retext-syllable) — Syllable count;
- [retext-visit](https://github.com/wooorm/retext-visit) — (**[demo](http://wooorm.github.io/retext-visit/)**) — Visit nodes, optionally by type;
- [retext-walk](https://github.com/wooorm/retext-walk) — Walk trees, optionally by type.

@@ -146,26 +140,23 @@ ## Desired Plugins

* retext-date — detect time and date in text;
* retext-live — Detect changes in a textarea (contenteditable?), sync the diffs over to a **retext** tree, let plugins modify the content, and sync the diffs back to the textarea;
* retext-profanity — Censor profane words;
* retext-punctuation-pair — detect which opening or initial punctuation, belongs to which closing or final punctuation mark (and vice versa);
* retext-summary — Summarise text;
* retraverse — like Estraverse;
- retext-date — Detect time and date in text;
- retext-emoticon — Like **retext-emoji**, but for general emoticons;
- retext-frequent-words — Like **retext-keywords**, but based on frequency and stop-words instead of a POS-tagger;
- retext-live — Detect changes in a textarea (contenteditable?), sync the diffs over to a **retext** tree, let plugins modify the content, and sync the diffs back to the textarea;
- retext-no-pants — Opposite of **retext-smartypants**;
- retext-profanity — Censor profane words;
- retext-punctuation-pair — Detect which opening or initial punctuation, belongs to which closing or final punctuation mark (and vice versa);
- retext-summary — Summarise text;
- retraverse — Like Estraverse;
## Parsers
* [parse-latin](https://github.com/wooorm/parse-latin "Parse Latin") (**[demo](http://wooorm.github.io/parse-latin/)**) — default;
* [parse-english](https://github.com/wooorm/parse-english "Parse English") (**[demo](http://wooorm.github.io/parse-english/)**) — Specifically for English;
* [parse-dutch](https://github.com/wooorm/parse-dutch "Parse Dutch") (**[demo](http://wooorm.github.io/parse-dutch/)**) — Specifically for Dutch;
- [parse-latin](https://github.com/wooorm/parse-latin) (**[demo](http://wooorm.github.io/parse-latin/)**) — default;
- [parse-english](https://github.com/wooorm/parse-english) (**[demo](http://wooorm.github.io/parse-english/)**) — Specifically for English;
- [parse-dutch](https://github.com/wooorm/parse-dutch) (**[demo](http://wooorm.github.io/parse-dutch/)**) — Specifically for Dutch;
## Benchmark
Run the benchmark yourself:
On a MacBook Air, it parses about 2 big articles, 22 sections, or 202 paragraphs per second.
```sh
$ npm run benchmark
```
On a MacBook Air, it parses about 2 big articles, 22 sections, or 206 paragraphs per second.
```
retext.parse(source);

@@ -179,3 +170,4 @@ 202 op/s » A paragraph (5 sentences, 100 words)

* [textom](https://github.com/wooorm/textom "TextOM")
- [textom](https://github.com/wooorm/textom)
- [nlcst](https://github.com/wooorm/nlcst)

@@ -182,0 +174,0 @@ ## License

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc