Skip to main content

PipeSay

一个可插拔的「句子流水线」框架:抓取 → 加工 → 输出。

PipeSay 将句子处理抽象为一条可配置的流水线。每个环节都通过装饰器注册、通过 YAML 组合,你无需改动核心代码,就能拼装出自己的玩法。

设计理念

  • 三段式流水线:Fetcher → Processor → Outputer,职责清晰,互不耦合。
  • 注册式插件系统:@processor('name') / @processor('name') / @outputer('name') 一键注册,签名自动反射为可配置参数。
  • YAML 驱动:处理器与输出器均以声明式配置组合,支持全局参数与步骤级参数合并。
  • 面向扩展:核心只提供约定与调度,具体能力全部来自插件。

安装

    pip install -r requirements.txt

快速开始

## 命令行
```text
    usage: pipesay [-h] [-p {}] [-c PIPELINE_CONFIG]
参数 说明 默认值
-p, --parser-mode parser解析器模式 None
-c, --pipeline-config 流水线配置 None

配置

处理器配置:

    processes:
      - processor: to_weak
      - processor: i18n
        params:
          lan: [en, ja]

    global: {}

输出器配置:

    outputs:
      - outputer: term
        params:
          auto_clear: True

    global: {}

params 会与 global 中同名步骤的配置合并,步骤级优先。

扩展

新增处理器:

    from pipesay.processor.base import processor

    @processor('shout')
    def shout(sentences: list, mark: str = '!', log=None):
        """给每句话加上强调符号"""
        return [s + mark for s in sentences]

新增输出器:

    from pipesay.outputers.base import outputer

    @outputer('count')
    def count(sentences: list, log=None):
        """只统计句子数量"""
        log(f"共 {len(sentences)} 句")

注册后即可在 YAML 中直接引用。函数签名中的 sentences 与 log 会被自动跳过,其余参数反射为可配置项。

查看已注册的步骤:

    from pipesay.processor.base import Processor
    from pipesay.outputers.base import Outputer

    Processor.list_all()
    Outputer.list_all()

项目结构

    src/pipesay/
    ├── main.py                # 入口
    ├── constants/             # 常量
    ├── fetcher/               # 获取器
    ├── processor/             # 处理器与注册表
    ├── outputers/             # 输出器与注册表
    ├── core/                  # 流水线执行器与注册装饰器
    ├── parser/                # 命令行解析
    └── utils/                 # 通用工具

工作原理

    Fetcher ──▶ Processor ──▶ Outputer
        ▲              ▲        ▲
        └ pipeline.yaml┘--------┘
  1. Fetcher 读取fetchers段,从数据源获取数据。
  2. Processor 读取 pipeline 段,按序加工并逐级传递。
  3. Outputer 读取 outputs 段,将结果交给输出器展示。

License

MIT

Release files for pipesay 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipesay 0.0.10
File Size Uploaded
pipesay-0.0.10.tar.gz 16.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pipesay 0.0.10
File Interpreter ABI Platform
pipesay-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 34.6 kB

Release files / pipesay-0.0.10.tar.gz

Download URL pipesay-0.0.10.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f976755d7bac5f0e06447d1cf530786843e32e95c2cf7cb01e12327e51b288a0
BLAKE2b-256 checksum
How to use checksums
b2d33b41c1899f122dcd5af486813be3444399659bc05bccb6c961c79451e2bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / pipesay-0.0.10-py3-none-any.whl

Download URL pipesay-0.0.10-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47399735a1f793e64f9822b84439af858b59127ef906a7e3478d5dca557962df
BLAKE2b-256 checksum
How to use checksums
b21e9820ce195fa6dd6420ca73a0de7ead46be684b25b5256487545915cee642
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page