Skip to main content

Perfect your text processing pipeline.

Project description

Perfectum -- chain-based text processing library aiming for simplicity and productivity.

Usage

To install, run:

pip install perfectum[gpt,translate]

And then, edit the main.py file:

from perfectum.all import *

chain = Chain(
    [
        Translate("en"),
        Asciify(),
        Trim(),
        CollapseWhitespace(),
        Gpt("gpt-4o-mini", "Summarize the text in a less than 10 words."),
    ]
)
print(chain)

text = open("sample.text").read()
text = chain.process(text)
print(text)

Multi-level chaining

from perfectum.all import *

normalize = Chain(
    [
        Asciify(),
        TabToWhitespace(),
        CollapseWhitespace(),
        Trim(),
    ]
)

translate_and_generate_poem = Chain(
    [
        Translate("en"),
        Gpt("gpt-4o-mini", "Write a short poem using text provided by user."),
    ]
)

chain = Chain(
    [
        normalize,
        translate_and_generate_poem,
    ]
)

text = "Привет! Я слышал, что ты сломала ногу позавчера. Как ты себя чувствуешь?"
text = chain.process(text)
print(text)

As you can see, processing text becomes straightforward by creating separate chains for each task and then combining them into a single chain.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

perfectum-0.1.6.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

perfectum-0.1.6-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file perfectum-0.1.6.tar.gz.

File metadata

  • Download URL: perfectum-0.1.6.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for perfectum-0.1.6.tar.gz
Algorithm Hash digest
SHA256 501c074a9fdf0c490e9b6727efe9d54db1bec7ea596569f244e0a6f8c5959439
MD5 dff1677c13ec6071fd9b45aa9408fb88
BLAKE2b-256 dfda15baf40f1e5dd1c4c79015f0e3c4ffa66864a9735bb29aa566837654ff2f

See more details on using hashes here.

File details

Details for the file perfectum-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: perfectum-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for perfectum-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d7d335b0649e73258b6b70e5345c4eaedc034aee2d6a6748844c3dbec2745a19
MD5 e65776928781849a8c84018c3978e22c
BLAKE2b-256 e9e8cd686d0064e81be8c4c4d1da8ba654fc0d73a7702f8fe56ec1a39912339f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page