1- # python/phaeton/__init__.py
1+ from .engine import Engine
2+ from .pipeline import Pipeline
3+
4+ __all__ = ["Engine" , "Pipeline" ]
5+ _DEFAULT_ENGINE = Engine (workers = 0 )
26
3- # Coba import binary Rust (ini bakal gagal kalau belum dicompile,
4- # jadi kita kasih try-except biar gak error pas lagi coding python doang)
57try :
68 from ._phaeton import __version__ as _rust_version
79except ImportError :
810 _rust_version = "0.0.0-dev"
911
10- # Import submodule biar user bisa akses phaeton.text, dll
11- from . import text , io , guard
12-
13- # --- ROOT FUNCTIONS & CONFIG ---
14-
15- _CONFIG = {
16- "threads" : 4 ,
17- "strict" : True
18- }
19-
20- def configure (threads : int = 4 , strict : bool = True ):
21- """Global configuration settings for Phaeton engine."""
22- global _CONFIG
23- _CONFIG ["threads" ] = threads
24- _CONFIG ["strict" ] = strict
25- # Nanti di sini kita pass config ke Rust
26- print (f"DEBUG: Config updated -> { _CONFIG } " )
27-
2812def version () -> str :
29- """Check library and engine version."""
13+ """Returns the library version string ."""
3014 return f"Phaeton v0.1.0 (Engine: Rust v{ _rust_version } )"
3115
32- def sanitize (text : str ) -> str :
33- """
34- [DUMMY] Otomatis mendeteksi PII umum dan menggantinya dengan ***.
35- """
36- # Placeholder logic (Python side)
37- if not text : return ""
38- return text .replace ("@" , "***" ).replace ("08" , "**" )
16+ def filter (source : str , filter : str ) -> str :
17+ """Shortcut function to filter data from source."""
18+ results = (
19+ _DEFAULT_ENGINE .ingest (source )
20+ .filter (filter )
21+ .run ()
22+ )
23+ return results
24+
25+ def clean (source : str , operation : dict ) -> str :
26+ """Shortcut function to clean data from source."""
27+ pipeline = _DEFAULT_ENGINE .ingest (source )
28+ for op , mode in operation .items ():
29+ if op == "sanitize" :
30+ pipeline = pipeline .sanitize (mode )
31+ elif op == "filter" :
32+ pipeline = pipeline .filter (mode )
33+ results = pipeline .run ()
34+ return results
0 commit comments