@diplodoc/sentenizer

中文文档
0.0.12发布于 2026/09/24MITTypeScriptCommonJS构建来源已验证近 30 天下载 8895

text segmentation into sentences

原始使用文档
文档目录11 节
  1. Features
  2. Installation
  3. Usage
  4. Basic Example
  5. ES Modules
  6. API
  7. sentenize(text: string): string[]
  8. How It Works
  9. Integration
  10. Development
  11. License

NPM version Quality Gate Status Coverage Maintainability Rating Reliability Rating Security Rating

@diplodoc/sentenizer

Rule-based NLP library for sentence segmentation with Russian language support. Splits text into sentences using hand-crafted rules that handle Russian-specific cases like abbreviations, initials, and punctuation.

Features

  • Rule-based segmentation — Hand-crafted rules optimized for Russian text
  • Russian-specific handling — Correctly handles abbreviations (e.g., "и т. д.", "т. п."), initials (e.g., "И. В. Иванов"), quotations, and brackets
  • Functional programming — Uses Ramda for clean, composable code
  • High accuracy — Tested on various Russian text samples
  • Lightweight — No external NLP libraries, fast and self-contained

Installation

npm install @diplodoc/sentenizer

Usage

Basic Example

const {sentenize} = require('@diplodoc/sentenizer');

const text = 'Он купил фрукты - яблоки, бананы, и т. д. все были очень рады угощению. Вот такой он добродушный наш родственник И. В. Иванов.';

const sentences = sentenize(text);
// sentences:
// [
//  'Он купил фрукты - яблоки, бананы, и т. д. все были очень рады угощению.',
//  'Вот такой он добродушный наш родственник И. В. Иванов.'
// ]

ES Modules

import {sentenize} from '@diplodoc/sentenizer';

const sentences = sentenize('Первое предложение. Второе предложение!');
// ['Первое предложение.', ' Второе предложение!']

API

sentenize(text: string): string[]

Splits text into sentences.

Parameters:

  • text (string) — Text to segment

Returns:

  • string[] — Array of segmented sentences

Type signature:

sentenize :: string -> string[]

How It Works

The library uses a rule-based approach with two types of conditions:

Join Conditions (chunks should be merged):

  • Abbreviations (e.g., "и т. д.", "т. п.")
  • Initials (e.g., "И. В. Иванов")
  • Quotations and brackets
  • Lowercase continuation
  • Delimiters and spaces

Break Conditions (chunks should be split):

  • Hard breaks (double newlines)
  • Uppercase start after sentence end

Integration

This package is used by @diplodoc/translation for text segmentation during translation.

Development

See AGENTS.md for detailed development guidelines.

License

MIT

版本与发布记录

@diplodoc/sentenizer 共发布 13 个版本,首次发布于 2023/04/25;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.12latest2026/09/241 个月前
0.0.112026/08/063 个月前
0.0.102026/05/285 个月前
0.0.92026/01/129 个月前
0.0.82024/03/112 年前
0.0.72024/02/272 年前

关于 @diplodoc/sentenizer 的常见问题

@diplodoc/sentenizer 是什么?

text segmentation into sentences

如何安装 @diplodoc/sentenizer?

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

@diplodoc/sentenizer 支持 TypeScript 吗?

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

@diplodoc/sentenizer 支持 ESM 还是 CommonJS?

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

@diplodoc/sentenizer 可以商用吗?

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

@diplodoc/sentenizer 的下载量有多少?

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

@diplodoc/sentenizer 还在维护吗?

最新版本 0.0.12 发布于 2026/09/24(1 个月前);至今共发布 13 个版本,其中过去 12 个月发布了 4 个;首次发布于 2023/04/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。