# sbd

> Split text into sentences with Sentence Boundary Detection (SBD).

Latest version **1.0.19** (published 2021-05-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install sbd
pnpm add sbd
yarn add sbd
bun add sbd
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.19 |
| Published | 2021-05-11 |
| First published | 2014-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/sbd) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 72.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 226 |
| Author | Fabiën Tesselaar |
| Maintainers | tessmore |
| Keywords | sentence, detection, boundary |

## Links

- npm: https://www.npmjs.com/package/sbd
- Repository: https://github.com/Tessmore/sbd
- Homepage: http://github.com/Tessmore/sbd
- Issues: https://github.com/Tessmore/sbd/issues
- npm.io page: https://npm.io/package/sbd

## Dependencies (1)

- [sanitize-html](https://npm.io/package/sanitize-html.md) ^2.3.2

## Recent versions

- 1.0.19 (latest) — 2021-05-11
- 1.0.18 — 2020-04-14
- 1.0.17 — 2020-04-01
- 1.0.16 — 2019-07-16
- 1.0.15 — 2019-03-19
- 1.0.14 — 2018-08-13
- 1.0.13 — 2018-08-13
- 1.0.12 — 2017-01-10
- 1.0.11 — 2016-12-05
- 1.0.10 — 2016-10-20
- 1.0.9 — 2016-08-30
- 1.0.8 — 2016-08-26
- 1.0.6 — 2016-04-07
- 1.0.5 — 2016-04-07
- 1.0.4 — 2016-04-07
- … 10 more at https://npm.io/package/sbd/versions

## README

Sentence Boundary Detection (SBD)
=================================

Split text into sentences with a `vanilla` rule based approach (i.e working ~95% of the time).

* Split a text based on period, question- and exclamation marks.
    * Skips (most) abbreviations (Mr., Mrs., PhD.)
    * Skips numbers/currency
    * Skips urls, websites, email addresses, phone nr.
    * Counts ellipsis and ?! as single punctuation

## Installation

Use [npm](http://npmjs.org) or [yarn](https://yarnpkg.com/en/):

    $ npm install sbd

    $ yarn add sbd


## How to

```javascript
var tokenizer = require('sbd');

var optional_options = {};
var text = "On Jan. 20, former Sen. Barack Obama became the 44th President of the U.S. Millions attended the Inauguration.";
var sentences = tokenizer.sentences(text, optional_options);

// [
//  'On Jan. 20, former Sen. Barack Obama became the 44th President of the U.S.',
//  'Millions attended the Inauguration.',
// ]
```


#### Optional options

```
var options = {
    "newline_boundaries" : false,
    "html_boundaries"    : false,
    "sanitize"           : false,
    "allowed_tags"       : false,
    "preserve_whitespace" : false,
    "abbreviations"      : null
};
```

* `newline_boundaries`, force sentence split at newlines
* `html_boundaries`, force sentence split at specific tags (br, and closing p, div, ul, ol)
* `sanitize`: If you don't expect nor want html in your text.
* `allowed_tags`: To sanitize html, the library [santize-html](https://github.com/punkave/sanitize-html) is used. You can pass the allowed tags option.
* `preserve_whitespace`: Preserve the literal whitespace between words and sentences (otherwise, internal spaces are normalized to a single space char, and inter-sentence whitespace is omitted). Preserve whitespace has no effect if either newline_boundaries or html_boundaries is specified.
* `abbreviations`: list of abbreviations to override the original ones for use with other languages. Don't put dots in your custom abbreviations.



## Contributing

You can run unit tests with `npm test`.

If you feel something is missing, you can open an issue stating the problem sentence and desired result. If code is unclear give me a @mention. Pull requests are welcome.


## Building the (minified) scripts

```
npm install -g browserify

npm run-script build
```

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