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.
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
perfectum-0.1.6-py3-none-any.whl
(10.4 kB
view details)
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
501c074a9fdf0c490e9b6727efe9d54db1bec7ea596569f244e0a6f8c5959439
|
|
| MD5 |
dff1677c13ec6071fd9b45aa9408fb88
|
|
| BLAKE2b-256 |
dfda15baf40f1e5dd1c4c79015f0e3c4ffa66864a9735bb29aa566837654ff2f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7d335b0649e73258b6b70e5345c4eaedc034aee2d6a6748844c3dbec2745a19
|
|
| MD5 |
e65776928781849a8c84018c3978e22c
|
|
| BLAKE2b-256 |
e9e8cd686d0064e81be8c4c4d1da8ba654fc0d73a7702f8fe56ec1a39912339f
|