Need private packages and team management tools?Check out npm Teams »

retext-porter-stemmer

1.0.0 • Public • Published

retext-porter-stemmer Build Status Coverage Status

retext implementation of the Porter stemming algorithm.

Installation

npm:

npm install retext-porter-stemmer

retext-porter-stemmer is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.

Usage

var retext = require('retext');
var inspect = require('unist-util-inspect');
var stemmer = require('retext-porter-stemmer');
 
retext().use(stemmer).use(function () {
    return function (cst) {
        console.log(inspect(cst));
    };
}).process('A simple English sentence.');

Yields:

RootNode[1]
└─ ParagraphNode[1]
   └─ SentenceNode[8]
      ├─ WordNode[1] [data={"stem":"a"}]
      │  └─ TextNode: 'A'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1] [data={"stem":"simpl"}]
      │  └─ TextNode: 'simple'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1] [data={"stem":"english"}]
      │  └─ TextNode: 'English'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1] [data={"stem":"sentenc"}]
      │  └─ TextNode: 'sentence'
      └─ PunctuationNode: '.'

API

None, retext-porter-stemmer automatically detects the stem of each WordNode (using wooorm/stemmer), and stores the stem in node.data.stem.

Related

License

MIT © Titus Wormer

Install

npm i retext-porter-stemmer

DownloadsWeekly Downloads

4

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar