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 🙏

© 2026 – Pkg Stats / Ryan Hefner

text-preprocessor

v1.1.1

Published

Normalizing texts before any natural language processing

Downloads

66

Readme

Text Preprocessor

Normalizing texts before any natural language processing

Instalation

Using Yarn:

yarn add text-preprocessor

Or using NPM:

npm i --save text-preprocessor

Usage

const preprocessor = require('text-preprocessor');

const text = preprocessor('     that`s great!    \n \t  &  but don’t take too long okay?   \n bjŏȒk—Ɏó ');

text.clean()
    .toLowerCase()
    .unescape()
    .killUnicode()
    .normalizeSingleCurlyQuotes()
    .expandContractions();

console.log(text.toString());
// OUTPUT: "that is great! & but do not take too long okay? bjork-yo"

preprocessor(text) ⇒ TextPreprocessor

Constructs a TextPreprocessor instance

| Param | Type | | --- | --- | | text | String |

Methods

new TextPreprocessor(text)

Normalizing texts before any natural language processing

| Param | Type | | --- | --- | | text | string |

textPreprocessor.clean()

and strips extra whitespace from all documents, leaving only at most one whitespace between any two other characters.

Kind: instance method of TextPreprocessor

textPreprocessor.unescape()

Converts the HTML entities &, <, >, ", and ' in string to their corresponding characters.

Kind: instance method of TextPreprocessor

textPreprocessor.toLowerCase()

Converts all the alphabetic characters in a string to lowercase.

Kind: instance method of TextPreprocessor

textPreprocessor.toString()

returns the result of chains so far

Kind: instance method of TextPreprocessor

textPreprocessor.expandContractions()

Replaces all occuring English contractions by their expanded equivalents, e.g. "don't" is changed to "do not".

Kind: instance method of TextPreprocessor

textPreprocessor.killUnicode()

Replaces hugely-ignorant, and widely subjective transliteration of latin, cryllic, greek unicode characters with english ascii.

Kind: instance method of TextPreprocessor

textPreprocessor.replace(regexp, value)

Replaces any occurrence of the given expression with the givven string

Kind: instance method of TextPreprocessor

| Param | Type | | --- | --- | | regexp | RegExp | | value | String |

textPreprocessor.remove(regexp)

Removes any occurrence of the given expression

Kind: instance method of TextPreprocessor

| Param | Type | | --- | --- | | regexp | RegExp |

textPreprocessor.removeTagsAndMentions()

Removes #tags, @mentions from start of the text

Kind: instance method of TextPreprocessor

textPreprocessor.removeSpecialCharachters()

Removes all special charachters

Kind: instance method of TextPreprocessor

textPreprocessor.removeURLs()

Removes Urls and emails

Kind: instance method of TextPreprocessor

textPreprocessor.removeParenthesesContents()

Remove brackets and parentheses contents.

Kind: instance method of TextPreprocessor Example

`Hello, this is Mike (example)` to `Hello, this is Mike `

textPreprocessor.removePunctuation()

Removes punctuation from end of the text

Kind: instance method of TextPreprocessor

textPreprocessor.normalizeSingleCurlyQuotes()

Coerce single curly quotes. don’t to don't

Kind: instance method of TextPreprocessor

textPreprocessor.normalizeDoubleCurlyQuotes()

Coerce double curly quotes. it is «Khorzu” to it is "Khorzu"

Kind: instance method of TextPreprocessor

textPreprocessor.defaults()

clean,toLowerCase,unescape,killUnicode and normalizeSingleCurlyQuotes

Kind: instance method of TextPreprocessor

textPreprocessor.chain()

Executes chain of givven method names

Kind: instance method of TextPreprocessor

preprocessor(text) ⇒ TextPreprocessor

Normalizing texts before any natural language processing

Kind: global function

| Param | Type | | --- | --- | | text | String |