File size: 1,411 Bytes
a7750f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2279b28
 
 
 
 
a7750f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
from __future__ import annotations

import sys
from difflib import SequenceMatcher
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))

from app.pipeline.orchestrator import rewrite_text

samples = [
    (
        "Academic",
        2,
        "Once upon a time, a tiny seed lay buried deep in the ground. "
        "Every day it heard the birds singing and wished it could see the bright blue sky.",
    ),
    (
        "Casual",
        1,
        "It is important to note that effective communication plays a crucial role "
        "in organizational success. Furthermore, this approach facilitates seamless "
        "collaboration across multifaceted teams.",
    ),
    (
        "Formal",
        1,
        "The team will start the project next week and try to finish early.",
    ),
    (
        "Neutral",
        2,
        "The team will start the project next week and try to finish early.",
    ),
]

for tone, strength, sample in samples:
    r = rewrite_text(sample, tone=tone, strength=strength, preserve_length=True)
    sim = SequenceMatcher(None, sample.lower(), r.text.lower()).ratio()
    print(f"\n=== {tone} s={strength} sim={sim:.2f} changed={r.changed} ===")
    print(r.text)
    assert "lay bury" not in r.text.lower()
    assert " it hear " not in f" {r.text.lower()} "
print("\nOK")