Graph-Native Infrastructure for Context and Accountable AI Systems
Python agent-memoryaiai-governanceai-infrastructureartificial-intelligencecontext-engineeringcontext-graphsdata-engineeringdecision-intelligencedeveloper-toolsexplainable-aigenerative-aigraph-ragknowledge-graphllmontologyprovenancepythonreasoningsemantic-search
test(normalize): fix preserve-case expectation; feat(normalize): use explicit unicode mappings for punctuation normalization
KaifAhmad14ec94b6a5d16
diff --git a/semantica/normalize/text_normalizer.py b/semantica/normalize/text_normalizer.pyindex 9784289a..2f55193e 100644--- a/semantica/normalize/text_normalizer.py+++ b/semantica/normalize/text_normalizer.py@@ -562,15 +562,19 @@ class SpecialCharacterProcessor:Returns:str: Text with normalized punctuation marks"""- # Normalize quotes- text = re.sub(r'["""]', '"', text)- text = re.sub(r"[''']", "'", text)-- # Normalize dashes- text = re.sub(r"[–—]", "-", text)+ # Replace common smart punctuation with ASCII equivalents+ replacements = {+ "\u2018": "'", # Left single quotation mark+ "\u2019": "'", # Right single quotation mark+ "\u201C": '"', # Left double quotation mark+ "\u201D": '"', # Right double quotation mark+ "\u2013": "-", # En dash+ "\u2014": "--", # Em dash+ "\u2026": "...", # Ellipsis+ }- # Normalize ellipsis- text = text.replace("…", "...")+ for old, new in replacements.items():+ text = text.replace(old, new)return textdiff --git a/tests/normalize/test_text_normalizer.py b/tests/normalize/test_text_normalizer.pyindex ae3bec33..84076975 100644--- a/tests/normalize/test_text_normalizer.py+++ b/tests/normalize/test_text_normalizer.py@@ -90,7 +90,7 @@ class TestTextNormalizer(unittest.TestCase):# preserve test ---- defaultself.assertEqual(- self.normalizer.normalize_text(text, case="preserve"), "HeLLo WoRLD"+ self.normalizer.normalize_text(text, case="preserve"), "HeLLo WoRLd")def test_normalize_delegation(self):