29 lines
2.4 KiB
Python
29 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
|
|
EN_LINE_REPLACEMENTS = {
|
|
"Service packages (from) Transparent starting points.": "Service packages (from) Clear starting points.",
|
|
"Frequently Asked Questions Transparent about planning, approach, and management.": "Frequently Asked Questions Clear guidance on planning, approach, and management.",
|
|
"After your intake Clear scope and steps Clear planning Transparent investment Name * E-mail * Company * Project details Book business call Ready to start with Business Website?": "After your intake Clear scope and steps Clear planning Transparent pricing Name * E-mail * Company * Project details Book business call Ready to start with Business Website?",
|
|
"After your intake Clear scope and steps Clear planning Transparent investment Name * E-mail * Company * Project details Book starter call Ready to start with Starter Website?": "After your intake Clear scope and steps Clear planning Transparent pricing Name * E-mail * Company * Project details Book starter call Ready to start with Starter Website?",
|
|
"After your intake Clear scope and steps Clear planning Transparent investment Name * E-mail * Company * Project details Request support plan Ready to start with Support & Growth?": "After your intake Clear scope and steps Clear planning Transparent pricing Name * E-mail * Company * Project details Request support plan Ready to start with Support & Growth?",
|
|
"After your intake Clear scope and steps Clear planning Transparent investment Name * E-mail * Company * Project details Start webshop project Ready to start with Webshop?": "After your intake Clear scope and steps Clear planning Transparent pricing Name * E-mail * Company * Project details Start webshop project Ready to start with Webshop?",
|
|
}
|
|
|
|
EN_PHRASE_REPLACEMENTS = {
|
|
"Transparent investment": "Transparent pricing",
|
|
"Transparent about planning, approach, and management.": "Clear guidance on planning, approach, and management.",
|
|
"Transparent starting points.": "Clear starting points.",
|
|
}
|
|
|
|
|
|
def normalize_en_text(text: str, field_path: str = "") -> str:
|
|
if text in EN_LINE_REPLACEMENTS:
|
|
return EN_LINE_REPLACEMENTS[text]
|
|
cleaned = text
|
|
for source, target in sorted(EN_PHRASE_REPLACEMENTS.items(), key=lambda item: len(item[0]), reverse=True):
|
|
cleaned = cleaned.replace(source, target)
|
|
return re.sub(r"\s+", " ", cleaned).strip()
|