File size: 1,313 Bytes
f82f941 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
from app.pipeline.orchestrator import rewrite_text
orig = (
"Nowadays many peoples are living unhealthy life because they don't have "
"enough times. Eating fast foods are becoming very common and peoples don't "
"realizes how much it affect their health."
)
for tone, st in [("Neutral", 1), ("Academic", 2), ("Casual", 2)]:
r = rewrite_text(orig, tone=tone, strength=st, preserve_length=True, ml_polish=False)
print("===", tone, "strength", st, "| changed=", r.changed, "| engine=", r.engine)
print(r.text)
print("notes:", r.notes)
print()
# Collocation protection: 'fast food' must never become 'rapid food' etc.
assert "rapid food" not in " ".join(
rewrite_text(orig, tone=t, strength=2, preserve_length=True).text.lower()
for t in ("Neutral", "Academic", "Casual")
)
# Grammar propagation: these ESL errors must be gone from Neutral output.
neutral = rewrite_text(orig, tone="Neutral", strength=1, preserve_length=True).text.lower()
for bad in ("peoples", "don't realizes", "it affect "):
assert bad not in neutral + " ", f"still present: {bad!r}"
print("ALL ASSERTIONS PASSED")
|