Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ckirby/sbd

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckirby/sbd

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

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50
increased by284.62%
Maintainers
1
Weekly downloads
 
Created
Source

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:

$ npm install sbd

How to

var tokenizer = require('@ckirby/sbd');

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 = {
    "preserve_whitespace" : false,
    "abbreviations"      : null
};
  • 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).
  • abbreviations: list of abbreviations to override the original ones for use with other languages. Don't put dots in 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

Keywords

FAQs

Package last updated on 30 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc