Giter Site home page Giter Site logo

ktp-forked-repos / sbd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tessmore/sbd

0.0 1.0 0.0 115 KB

Sentence Boundary Detection in javascript for node. http://tessmore.github.io/sbd/

License: MIT License

Makefile 0.24% HTML 9.63% JavaScript 90.13%

sbd's Introduction

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 or yarn:

$ npm install sbd

$ yarn add sbd

How to

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 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

sbd's People

Contributors

tessmore avatar chadkirby avatar fpereira1 avatar naugtur avatar darobin avatar toddself avatar sballesteros avatar

Watchers

Tadeusz Kurpiel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.