Coder Social home page Coder Social logo

lancaster-stemmer's Introduction

lancaster-stemmer

Build Coverage Downloads Size

Lancaster stemming algorithm.

Contents

What is this?

This package exposes a stemming algorithm. That means it gets a certain string (typically an English word), and turns it into a shorter version (a stem), which can then be compared to other stems (of other words), to check if they are both (likely) the same term.

When should I use this?

You’re probably dealing with natural language and know you need this if you’re here!

Install

This package is ESM only. In Node.js (version 16+), install with npm:

npm install lancaster-stemmer

In Deno with esm.sh:

import {lancasterStemmer} from 'https://esm.sh/lancaster-stemmer@2'

In browsers with esm.sh:

<script type="module">
  import {lancasterStemmer} from 'https://esm.sh/lancaster-stemmer@2?bundle'
</script>

Use

import {lancasterStemmer} from 'lancaster-stemmer'

console.log(lancasterStemmer('considerations')) // => 'consid'
console.log(lancasterStemmer('detestable')) // => 'detest'
console.log(lancasterStemmer('vileness')) // => 'vil'
console.log(lancasterStemmer('giggling')) // => 'giggl'
console.log(lancasterStemmer('anxious')) // => 'anxy'

// Case insensitive
console.log(lancasterStemmer('analytic') === lancasterStemmer('AnAlYtIc')) // => true

API

This package exports the identifier lancasterStemmer. There is no default export.

lancasterStemmer(value, options?)

Get the stem from a given value.

Parameters
  • value(string, required) — value to stem
  • options(Options, default: {}) — configuration
Returns

Stem for value (string).

Options

Configuration (TypeScript type).

Fields
  • style (Style, default: 'c') — style of algorithm

Style

Style of algorithm (TypeScript type).

There are small algorithmic differences between how the algorithm was implemented over the years. Looking at Algorithm Implementations on the archived website, there are four styles available, in addition to the original paper.

The only difference currently implemented in this package is whether a final s is kept before stopping (paper) or dropped before stopping (c).

Values
  • 'c' — rules from the ANSI C (Stark, 1994) and Perl (Taffet, 2001) implementations (compensation -> compen)
  • 'paper' — rules from the original paper (1990), and Pascal (Paice/Husk) and Java (O’Neill, 2000) implementations (compensation -> compens)

CLI

Usage: lancaster-stemmer [options] <words...>

Lancaster stemming algorithm

Options:

  -h, --help           output usage information
  -v, --version        output version number

Usage:

# output stems
$ lancaster-stemmer considerations
consid

# output stems from stdin
$ echo "detestable vileness" | lancaster-stemmer
detest vil

Types

This package is fully typed with TypeScript. It exports the additional types Options and Style.

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, lancaster-stemmer@^2, compatible with Node.js 12.

Related

Contribute

Yes please! See How to Contribute to Open Source.

Security

This package is safe.

License

MIT © Titus Wormer

lancaster-stemmer's People

Contributors

greenkeeperio-bot avatar wooorm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.