# html-stemmer

> Extracts all [porter2] stemmed words from an HTML file, with the goal of aiding web-based NLP

Latest version **1.0.5** (published 2015-02-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-stemmer
pnpm add html-stemmer
yarn add html-stemmer
bun add html-stemmer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2015-02-05 |
| First published | 2015-02-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Marcel Puyat |
| Maintainers | marcelp |
| Keywords | nlp, stemmer, html, html-stemmer, stop-words, stem, porter, porter2, stopwords, unescaper, unescape |

## Links

- npm: https://www.npmjs.com/package/html-stemmer
- Repository: https://github.com/marcelpuyat/html-stemmer
- Issues: https://github.com/marcelpuyat/html-stemmer/issues
- npm.io page: https://npm.io/package/html-stemmer

## Dependencies (3)

- [fs](https://npm.io/package/fs.md) 0.0.2
- [stopwords](https://npm.io/package/stopwords.md) 0.0.4
- [stem-porter](https://npm.io/package/stem-porter.md) 0.0.1

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2015-02-05
- 1.0.4 — 2015-02-04
- 1.0.3 — 2015-02-04
- 1.0.2 — 2015-02-04
- 1.0.1 — 2015-02-04
- 1.0.0 — 2015-02-04

## README

# html-stemmer #

Main repo: [https://github.com/marcelpuyat/html-stemmer](https://github.com/marcelpuyat/html-stemmer)

## Overview ##

Extracts all words from a file, filtering out HTML tags, stemming using Porter2 and filtering out stop words.  

## Install ##

	npm install html-stemmer

## Usage ##

	var htmlStemmer = require('html-stemmer');

	htmlStemmer.initialize();

	htmlStemmer.getStemmedWords('filename', function(stemmedWordsArray) {
		console.log(stemmedWordsArray); // Prints out all stemmed words in 'filename'
	});

## Documentation ##

### initialize(options)

Initializes the stemmer, using default options when not specified.

__Example:__
<pre>
htmlStemmer.initialize({
  includeTags: true,
  caseSensitive: true,
  delimiter: /[^A-Za-Z0-9]+/gi
});
</pre>
	
__Options:__

*Note that all of these are optional*
* `includeTags` - true or false. Filters out html tags (i.e. '\<body\>' is deleted) when false. false by default
* `filters` - An object that maps regular expressions to what they should be replaced by.
	```
	// Example that filters '&apos;' into an apostrophe and '&quot;' into a quotation mark
	filters = {};
	
	filters[/&apos;/gi] = '\'';
	filters[/&quot;/gi] = '"';
	
	htmlStemmer.initialize({
	  filters: filters
	});
	```
* `stopWords` - true or false. Excludes stop words (i.e. 'for', 'to', etc.) from final array returned by getStemmedWords if true. List of stop words used is available [here](https://github.com/huned/node-stopwords/blob/master/english.js). true by default.
* `caseSensitive` - true or false. Converts all characters to lowercase when false. false by default.
* `stemmed` - true or false. Stems each word using [Porter2](https://www.npmjs.com/package/stem-porter) when true. true by default.
* `delimiter` - A RegExp delimiter that is used to split the data into tokens. By default, /[^A-Za-z]+/gi is used.

### getStemmedWords(filePath, callbackFn)

Returns an array containing all stemmed words according to the options specified in `initialize`. Because file reading is done asynchronously, a callback function is required to get the array of stemmed words.

__Example:__
<pre>
htmlStemmer.getStemmedWords('filename', function(stemmedWordsArray) {
  console.log(stemmedWordsArray); // Prints out all stemmed words in 'filename'
});
</pre>

---
_Source: https://npm.io/package/html-stemmer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
