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.5.tar.gz (5.0 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.5-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for perfectum-0.1.5.tar.gz
Algorithm Hash digest
SHA256 51b44b38fe938d4633ef9210864cddd2f675fb111e53c9e56d3ba1db64f3b441
MD5 947c09b7c8293a66577f782ebfad2cc3
BLAKE2b-256 2c1c8cadab911dbc2f271a1ad591fad15a0b03c0aa10cfb910dbb733a503ea9d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for perfectum-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d851ba824f18bb30a1ec0b1e8cb16e9fb375e0b3669bdbcaefb743c18b9e4ccc
MD5 94eff37ee782546981615df61e3e2f95
BLAKE2b-256 166622a0e711ca565a6cab35271e4b4ef3a4caecb7412318e2de212d65f45ee6

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