npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

snowball-stem

v1.1.1

Published

⛄ Snowball stemmers for NPM.

Downloads

158

Readme

snowball

Snowball stemmers for deno. These stemmers are based on the compiled JavaScript stemmers from the snowball project version 2.2.0.

Usage

EnglishStemmer

Provides the stem of the given word. Assumes that the input is lowercase.

import { assertStrictEquals } from "./test_deps.ts";
import { EnglishStemmer } from "https://deno.land/x/snowball/english_stemmer.ts";

const englishStemmer = new EnglishStemmer();

const stem = englishStemmer.stem("enthusiastically");

assertStrictEquals(stem, "enthusiast");

Here is an example with multiple words.

import { assertStrictEquals } from "./test_deps.ts";
import { EnglishStemmer } from "https://deno.land/x/snowball/english_stemmer.ts";

const sentence = "the quick brown fox jumped over the lazy dog";

const englishStemmer = new EnglishStemmer();

const stemmedSentence = sentence
  .match(/\b\w\w+\b/gu) // matches two or more word characters
  .map((token) => englishStemmer.stem(token))
  .join(" ");

assertStrictEquals(
  stemmedSentence,
  "the quick brown fox jump over the lazi dog",
);

RussianStemmer

Many languages are supported

import { assertStrictEquals } from "./test_deps.ts";
import { RussianStemmer } from "https://deno.land/x/snowball/russian_stemmer.ts";

const sentence = "обязательно выпейте свой овалтин";

const russianStemmer = new RussianStemmer();

const stemmedSentence = sentence
  .split(/\s+/u)
  .map((token) => russianStemmer.stem(token))
  .join(" ");

assertStrictEquals(
  stemmedSentence,
  "обязательн вып сво овалтин",
);

LanguageStemmers

There is an Object containing all available languages and stemmers defined in mod.ts.

import { assertStrictEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { LanguageStemmers } from "https://deno.land/x/snowball/mod.ts";

const spanishStemmer = new LanguageStemmers["Spanish"]();

assertStrictEquals(
  spanishStemmer.stem("gracias"),
  "graci",
);

stopWords

Stop words generally provide little or no information. Some languages come with common stop words from the snowball-website. These can also be imported individually from the file containing the stopwords for that language. You should tokenize and stem these stop words the same way you do with your input text.

import { assert } from "https://deno.land/[email protected]/testing/asserts.ts";
import { EnglishStemmer } from "https://deno.land/x/snowball/english_stemmer.ts";

const englishStemmer = new EnglishStemmer();

assert(englishStemmer.stopWords.has("been"));

Supported Languages

Unless specified, there is only one stemmer available called LanguageStemmer which is exported from language_stemmer.ts and mod.ts. Replace language with the desired language respecting the hinted capitalization.

  1. Arabic
  2. Armenian
  3. Basque
  4. Catalan
  5. Danish
  6. Dutch
    1. DutchStemmer
    2. KraaijPohlmannStemmer
  7. English
    1. EnglishStemmer - Porter 2 or snowball algorithm
    2. PorterStemmer - Porter 1 stemmer
    3. LovinsStemmer - The first published stemming algorithm
  8. Finnish
  9. French
  10. German
    1. GermanStemmer
    2. German2Stemmer
  11. Greek
  12. Hindi
  13. Hungarian
  14. Indonesian
  15. Irish
  16. Italian
  17. Lithuanian
  18. Nepali
  19. Norwegian
  20. Protugese
  21. Romanian
  22. Russian
  23. Serbian
  24. Spanish
  25. Swedish
  26. Tamil
  27. Turkish
  28. Yiddish