semantica.normalize standardizes raw data before extraction and graph construction:
  • Text cleaning: Unicode NFC/NFKC, whitespace collapse, smart-quote and dash normalization
  • Entity canonicalization: alias resolution and disambiguation via configurable alias maps
  • Date normalization: any format → ISO 8601, including relative dates
  • Number conversion: "$1.2B"1200000000.0 with unit and currency handling
  • Language detection and encoding repair for inconsistent source data
All normalizers expose convenience functions (one-liners) and stateful class instances (full control).

Why Normalize Before Extraction

Unstructured data is inconsistent by nature. Without normalization, the same real-world entity appears as dozens of variants in your graph:
  • "Apple Inc.", "Apple Computer Inc.", "APPLE INC.": multiple nodes, one company
  • "Jan 1st, 2020", "01/01/2020", "2020-01-01": three formats, one date
  • "$1.2B", "1,200,000,000", "1.2 billion USD": three strings, one number
  • "Hello World" vs "Hello World": a non-breaking space that breaks string matching
Normalization collapses these variants before any extractor, deduplicator, or graph builder sees the data.

Exported Classes

Getting Started

1

EncodingHandler: fix encoding first

Broken bytes corrupt everything downstream. Always run this before anything else.
Run encoding repair before anything else. A single cp1252 character in a UTF-8 stream silently corrupts the surrounding text. Call handler.convert_to_utf8(raw_bytes) first, before any other normalizer sees the data.
2

TextNormalizer: unicode, whitespace, special chars

Don’t lowercase before NER. normalize_text(text, case="lower") before entity extraction destroys capitalization signals that NER relies on. Apply case normalization only after extraction if needed.
3

EntityNormalizer: canonicalize entity names

EntityNormalizer has no built-in corporate suffix expansion. There is no automatic mapping of "Apple Computer Inc.""Apple Inc.". To canonicalize corporate names, provide an explicit alias_map with lowercase keys: EntityNormalizer(alias_map={"apple computer inc.": "Apple Inc."}).
4

DateNormalizer and NumberNormalizer: parse structured values

5

LanguageDetector: detect language on clean text

Convenience Functions

The fastest path: one import, one call:

Normalizers

TextNormalizer takes config=None, **kwargs in its constructor. Normalization options are passed per-call to normalize_text():
Unicode form guide:Sub-normalizers for fine-grained control:

DataCleaner

Cleans structured record sets: useful before loading into a vector store or graph:

DataCleaner Methods

DataCleaner.remove_duplicates() does not exist as a standalone method. Use detect_duplicates() to get DuplicateGroup objects, or call clean_data(records, remove_duplicates=True) to remove them in-place.
DataCleaner operates on flat records, not graph entities. For entity-level semantic deduplication, use DuplicateDetector from the Deduplication module instead.

Pipeline Integration

Custom Normalizers

Register a custom normalizer in the method registry:
  • Parse — Parse documents before normalization.
  • Split — Chunk normalized text for embedding.
  • Deduplication — Resolve duplicate entities after normalization.
  • Pipeline — Include normalization as a named pipeline step.