@ckirby/sbd

中文文档
2.2.0发布于 2024/05/31MITTypeScriptCommonJS零依赖近 30 天下载 3112

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

原始使用文档
文档目录4 节
  1. Installation
  2. How to
  3. Contributing
  4. Building the (minified) scripts

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

版本与发布记录

@ckirby/sbd 共发布 5 个版本,首次发布于 2018/05/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.2.0latest2024/05/312 年前
2.1.22023/05/263 年前
2.1.12023/05/263 年前
2.1.02018/06/168 年前
2.0.22018/05/238 年前

关于 @ckirby/sbd 的常见问题

@ckirby/sbd 是什么?

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

如何安装 @ckirby/sbd?

在项目目录运行 npm install @ckirby/sbd,或使用 pnpm add / yarn add / bun add。

@ckirby/sbd 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ckirby/sbd 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@ckirby/sbd 可以商用吗?

@ckirby/sbd 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ckirby/sbd 的下载量有多少?

根据 npm 官方下载统计,@ckirby/sbd 在 2026/10/10 – 2026/11/08 这 30 天内被下载 3,112 次,日均约 104 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ckirby/sbd 还在维护吗?

最新版本 2.2.0 发布于 2024/05/31(2 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/05/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。