Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pipeline): replace char special by oe #255

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pipeline/dags/dag_utils/sources/monenfant.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
logger = logging.getLogger(__name__)


def unaccent(text: str) -> str:
def normalize(text: str) -> str:
# Decompose the unicode string into its base and combining characters
nfkd_form = unicodedata.normalize("NFKD", text)

# Filter out the combining characters (like accents)
return "".join([c for c in nfkd_form if not unicodedata.combining(c)])
normalized_text = "".join([c for c in nfkd_form if not unicodedata.combining(c)])
# replace ligature oe
return normalized_text.replace("œ", "oe")


def get_location(city_code: str, commune: str, region: str) -> str:
Expand All @@ -33,8 +36,8 @@ def get_location(city_code: str, commune: str, region: str) -> str:
The location string is formatted as "Xeme Arrondissement Paris" for Paris.
For other cities, it is formatted like "Lille Nord".
"""
commune = unaccent(commune)
region = unaccent(region)
commune = normalize(commune)
region = normalize(region)

if "Arrondissement" in commune:
commune = commune.split()[0]
Expand Down
Loading