Socket
Socket
Sign inDemoInstall

wink-porter2-stemmer

Package Overview
Dependencies
0
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

17

package.json
{
"name": "wink-porter2-stemmer",
"version": "1.0.3",
"version": "1.0.4",
"description": "Implementation of Porter Stemmer Algorithm V2 by Dr Martin F Porter",

@@ -13,8 +13,9 @@ "keywords": [

"scripts": {
"pretest": "npm run lint && npm run hint",
"pretest": "npm run lint && npm run hint && npm run readmedocs",
"test": "istanbul cover _mocha ./test/",
"coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"docs": "docco -o ./docs/ ./src/*.js",
"hint": "jshint ./src/*.js ./test/*.js",
"lint": "eslint ./src/*.js ./test/*.js"
"docs": "docker -i src -o docs --sidebar no",
"readmedocs": "documentation readme src/*.js --section=API",
"hint": "jshint ./src/*.js ./test/*.js ./runkit/*.js",
"lint": "eslint ./src/*.js ./test/*.js ./runkit/*.js"
},

@@ -34,3 +35,4 @@ "repository": {

"coveralls": "^2.11.15",
"docco": "^0.7.0",
"docker": "^1.0.0",
"documentation": "^4.0.0-rc.1",
"eslint": "^3.13.1",

@@ -41,3 +43,4 @@ "istanbul": "^0.4.5",

"mocha-lcov-reporter": "^1.2.0"
}
},
"runkitExampleFilename": "./runkit/example.js"
}

@@ -1,2 +0,1 @@

# wink-porter2-stemmer

@@ -6,3 +5,3 @@

### [![Build Status](https://api.travis-ci.org/decisively/wink-porter2-stemmer.svg?branch=master)](https://travis-ci.org/decisively/wink-porter2-stemmer) [![Coverage Status](https://coveralls.io/repos/github/decisively/wink-porter2-stemmer/badge.svg?branch=master)](https://coveralls.io/github/decisively/wink-porter2-stemmer?branch=master)
### [![Build Status](https://api.travis-ci.org/decisively/wink-porter2-stemmer.svg?branch=master)](https://travis-ci.org/decisively/wink-porter2-stemmer) [![Coverage Status](https://coveralls.io/repos/github/decisively/wink-porter2-stemmer/badge.svg?branch=master)](https://coveralls.io/github/decisively/wink-porter2-stemmer?branch=master) [![Inline docs](http://inch-ci.org/github/decisively/wink-porter2-stemmer.svg?branch=master)](http://inch-ci.org/github/decisively/wink-porter2-stemmer) [![devDependencies Status](https://david-dm.org/decisively/wink-porter2-stemmer/dev-status.svg)](https://david-dm.org/decisively/wink-porter2-stemmer?type=dev)

@@ -13,14 +12,13 @@ <img align="right" src="https://decisively.github.io/wink-logos/logo-title.png" width="100px" >

[Stemming](https://en.wikipedia.org/wiki/Stemming) reduces an inflected word into its base form, for example *learning* to *learn*. It is used extensively in Natural Language Processing (NLP).
[Stems](https://en.wikipedia.org/wiki/Stemming) an inflected word into its base form, for example _learning_ to _learn_. It is also being used in [wink-nlp-utils](https://www.npmjs.com/package/wink-nlp-utils) that prepares raw text for Natural Language Processing (NLP).
## Installation
Use **[npm](https://www.npmjs.com/package/wink-porter2-stemmer)** to install:
```
npm install wink-porter2-stemmer --save
```
npm install wink-porter2-stemmer --save
## Usage
## Example [![Build Status](https://badge.runkitcdn.com/wink-porter2-stemmer.svg)](https://npm.runkit.com/wink-porter2-stemmer)
```javascript
// Load porter stemmer V2

@@ -39,7 +37,29 @@ var stem = require( 'wink-porter2-stemmer' );

## API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
### stem
Stems an inflected `word` using Porter2 stemming algorithm.
**Parameters**
- `word` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** — word to be stemmed.
**Examples**
```javascript
// returns 'consist'
stem( 'consisting' );
```
Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** — the stemmed word.
## Need Help?
If you spot a bug and the same has not yet been reported, raise a new [issue](https://github.com/decisively/wink-porter2-stemmer/issues) or consider fixing it and sending a pull request.
## Copyright & License
## Copyright & License
**wink-porter2-stemmer** is copyright 2017 GRAYPE Systems Private Limited.

@@ -46,0 +66,0 @@

@@ -26,3 +26,3 @@ // wink-porter2-stemmer

// #### Regex Definitions
// ## Regex Definitions

@@ -115,9 +115,16 @@ // Regex definition of `double`.

// #### Prelude
// ## Private functions
// Performs in initial pre-processing by transforming thhe input string `s` as
// per the replacements.
// ### prelude
/**
* Performs initial pre-processing by transforming the input string `s` as
* per the replacements.
*
* @param {String} s Input string
* @return {String} Processed string
* @private
*/
var prelude = function ( s ) {
return ( s
// Handle y's.
// Handle `y`'s.
.replace( /^y/, '3' )

@@ -132,6 +139,8 @@ .replace( /([aeiou])y/, '$13' )

// #### Is Short
// Returns `true` if the input string `s` is a short syllable; otherwise it
// returns `false`.
// ### isShort
/**
* @param {String} s Input string
* @return {Boolean} `true` if `s` is a short syllable, `false` otherwise
* @private
*/
var isShort = function ( s ) {

@@ -151,9 +160,12 @@ // (a) a vowel followed by a non-vowel other than w, x or 3 and

// #### Mark Regions
// Returns the R1 and R2 regions as an object from the input string `s`.
// ### markRegions
/**
* @param {String} s Input string
* @return {Object} the `R1` and `R2` regions as an object from the input string `s`.
* @private
*/
var markRegions = function ( s ) {
// Matches of R1 and R2.
// Matches of `R1` and `R2`.
var m1, m2;
// To detect regions i.e. R1 and R2.
// To detect regions i.e. `R1` and `R2`.
var rgxRegions = /[aeiouy]+([^aeiouy]{1}.+)/;

@@ -171,5 +183,8 @@ m1 = rgxRegions.exec( s );

// #### Step Ia
// Step Ia.
// ### step1a
/**
* @param {String} s Input string
* @return {String} Processed string
* @private
*/
var step1a = function ( s ) {

@@ -186,5 +201,8 @@ var wordPart;

// #### Step Ib
// Step Ib.
// ### step1b
/**
* @param {String} s Input string
* @return {String} Processed string
* @private
*/
var step1b = function ( s ) {

@@ -213,5 +231,8 @@ var rgn = markRegions( s ),

// #### Step Ic
// Step Ic.
// ### step1c
/**
* @param {String} s Input string
* @return {String} Processed string
* @private
*/
var step1c = function ( s ) {

@@ -221,5 +242,8 @@ return ( s.replace( rgxSFXyOR3, '$1i') );

// #### Step II
// Step II.
// ### step2
/**
* @param {String} s Input string
* @return {String} Processed string
* @private
*/
var step2 = function ( s ) {

@@ -240,5 +264,8 @@ var i, imax,

// #### Step III
// Step III.
// ### step3
/**
* @param {String} s Input string
* @return {String} Processed string
* @private
*/
var step3 = function ( s ) {

@@ -261,5 +288,8 @@ var i, imax,

// #### Step IV
// Step IV.
// ### step4
/**
* @param {String} s Input string
* @return {String} Processed string
* @private
*/
var step4 = function ( s ) {

@@ -280,5 +310,8 @@ var rgn = markRegions( s );

// #### Step V
// Step V.
// ### step5
/**
* @param {String} s Input string
* @return {String} Processed string
* @private
*/
var step5 = function ( s ) {

@@ -306,6 +339,15 @@ var preceding, rgn;

// #### Stem
// The main Porter 2 Stemmer: stems the input string `word` and returns the
// stemmed `word`.
// ## Public functions
// ### stem
/**
*
* Stems an inflected `word` using Porter2 stemming algorithm.
*
* @arg {string} word — word to be stemmed.
* @return {string} — the stemmed word.
*
* @example
* // returns 'consist'
* stem( 'consisting' );
*/
var stem = function ( word ) {

@@ -312,0 +354,0 @@ var str = word.toLowerCase();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc