Refinery components for the Sayou Data Platform
Project description
sayou-refinery
The Universal Data Cleaning & Normalization Engine for Sayou Fabric.
sayou-refinery acts as the "Cleaning Plant" in your data pipeline.
It transforms heterogeneous raw data (JSON Documents, HTML, DB Records) into a standardized stream of SayouBlocks, ensuring that downstream components (like Chunkers or LLMs) receive clean, uniform data regardless of the original source format.
💡 Core Philosophy
"Flatten Structure, Polish Content."
Refinery operates in two distinct stages to guarantee data quality:
- Normalization (Shape Shifting): Converts complex structures (nested JSON, HTML trees, DB Rows) into a linear list of
SayouBlocks. - Processing (Cleaning): Applies a chain of cleaning agents (Regex, Masking, Deduplication) to improve data hygiene.
📦 Installation
pip install sayou-refinery
⚡ Quick Start
The RefineryPipeline orchestrates the normalization and processing chain.
from sayou.refinery.pipeline import RefineryPipeline
def run_demo():
# 1. Initialize with specific cleaning rules
pipeline = RefineryPipeline()
pipeline.initialize(
mask_email=True,
outlier_rules={"price": {"min": 0, "max": 1000, "action": "clamp"}}
)
# 2. Raw Data (e.g., from sayou-document)
raw_doc = {
"metadata": {"title": "Test Doc"},
"pages": [{
"elements": [
{"type": "text", "text": "Contact: admin@sayou.ai"},
{"type": "text", "text": " Dirty Whitespace "}
]
}]
}
# 3. Run Pipeline
# strategy: 'standard_doc', 'html', 'json', etc.
blocks = pipeline.run(raw_doc, strategy="standard_doc")
# 4. Result
for block in blocks:
print(f"[{block.type}] {block.content}")
# Output:
# [md_meta] --- title: Test Doc ...
# [md] Contact: [EMAIL]
# [md] Dirty Whitespace
if __name__ == "__main__":
run_demo()
🔑 Key Components
Normalizers
DocMarkdownNormalizer: Converts Sayou Document Dicts into Markdown blocks.HtmlTextNormalizer: Strips HTML tags and scripts, extracting clean text.RecordNormalizer: Converts DB rows or JSON objects into 'record' blocks.
Processors
TextCleaner: Normalizes whitespace and removes noise via regex.PiiMasker: Masks sensitive info like emails and phone numbers.Deduplicator: Removes duplicate content blocks.Imputer: Fills missing values in record blocks.OutlierHandler: Filters or clamps numerical outliers in records.
🤝 Contributing
We welcome contributions for new Normalizers (e.g., CsvNormalizer, LogNormalizer) or Processors (e.g., LangChainFilter).
📜 License
Apache 2.0 License © 2025 Sayouzone
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file sayou_refinery-0.2.4.tar.gz.
File metadata
- Download URL: sayou_refinery-0.2.4.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4272d8ef934f439cbbc2d7a435adaaff8b76f72dc1c72acbe3fa3d5bdd9e1a09
|
|
| MD5 |
29db2e6a571cf3cca93ffc849364d2c4
|
|
| BLAKE2b-256 |
f6f7685597e84a6ea30a02fe3130fff07f98aaa5f597f4d9020a90a85abd903e
|
File details
Details for the file sayou_refinery-0.2.4-py3-none-any.whl.
File metadata
- Download URL: sayou_refinery-0.2.4-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cf29c9ff6622902a934121d3c78ee11a1efcc35ff455aaafd2f1b4499269d5a
|
|
| MD5 |
d85916f5aeb055c76c935a77c936cb01
|
|
| BLAKE2b-256 |
be5667b083b41b9aada60a79288bdc57b0683ad9f8c177f62e597b650cbbe080
|