name: normalize
description: >
Normalize text to handle PDF/Unicode encoding issues.
Converts Windows-1252, curly quotes, em/en dashes, ligatures,
directional formatting, zero-width chars, and more to clean ASCII.
allowed-tools: Bash, Read
triggers:
- normalize text
- clean text
- normalize unicode
- fix encoding
- clean pdf text
- normalize pdf
metadata:
short-description: Clean PDF/Unicode text to ASCII
project-path: /home/graham/workspace/experiments/pi-mono
provides:
- text-normalization
composes: [, task-monitor]
taxonomy:
- preprocessing
- text
- precision
Text Normalize
Comprehensive text normalization for handling PDF and Unicode encoding issues.
Quick Start
# Normalize text from stdin
echo "Hello\u2019world" | .pi/skills/normalize/run.sh
# Normalize a file
.pi/skills/normalize/run.sh document.txt
# Normalize with output file
.pi/skills/normalize/run.sh document.txt -o clean.txt
# Treat argument as text (not filename)
.pi/skills/normalize/run.sh -t "Hello\u201cworld\u201d"
# Show statistics
.pi/skills/normalize/run.sh document.txt --stats
What It Normalizes
| Category |
Examples |
Normalized To |
| Whitespace |
Non-breaking, em/en space, hair space |
Regular space |
| Hyphens |
En dash, em dash, minus sign, figure dash |
ASCII hyphen - |
| Quotes |
Curly quotes, guillemets, primes |
Straight ' and " |
| Windows-1252 |
\x93, \x94, \x92 |
", ", ' |
| Ligatures |
fi, fl, ffi, ffl |
Expanded letters |
| Bullets |
Various bullet points |
Hyphen - |
| Zero-width |
ZWSP, ZWNJ, ZWJ, BOM |
Removed |
| Directional |
LTR/RTL marks |
Removed |
| Control chars |
C0/C1 (except newline/tab) |
Removed |
| Line breaks |
intro-\nduction |
introduction |
Pipeline Integration
This skill is based on the same normalization used in the extractor pipeline's
s02_marker_extractor.py. The code is kept in sync with text_toolz patterns.
Python Usage
from normalize import normalize_text
# Clean text for pattern matching
text = "1.\u00a0Introduction" # Non-breaking space
clean = normalize_text(text) # "1. Introduction"
Normalization Steps
- Windows-1252 conversion - Handle legacy MS Office encoding
- NFKC normalization - Unicode compatibility decomposition
- Remove directional formatting - LTR/RTL marks
- Remove control characters - C0/C1 (preserve newlines)
- Normalize whitespace - All special spaces to ASCII
- Normalize hyphens - All dash variants to
-
- Normalize quotes - Curly to straight
- Normalize dots - Ellipsis, leader dots
- Normalize bullets - All bullet types to
-
- Expand ligatures - fi/fl/ffi/ffl
- Fix line-break hyphens - Join hyphenated words
- Collapse whitespace - Multiple spaces to single
Based On
- text_toolz library patterns
- extractor pipeline s02 normalization
- NFKC Unicode standard
1---2name: normalize-43description: Comprehensive text normalization for handling PDF and Unicode encoding issues.4---56---7name: normalize8description: >9 Normalize text to handle PDF/Unicode encoding issues.10 Converts Windows-1252, curly quotes, em/en dashes, ligatures,11 directional formatting, zero-width chars, and more to clean ASCII.12allowed-tools: Bash, Read13triggers:14 - normalize text15 - clean text16 - normalize unicode17 - fix encoding18 - clean pdf text19 - normalize pdf20metadata:21 short-description: Clean PDF/Unicode text to ASCII22 project-path: /home/graham/workspace/experiments/pi-mono23provides:24 - text-normalization25composes: [, task-monitor]2627taxonomy:28 - preprocessing29 - text30 - precision31---3233# Text Normalize3435Comprehensive text normalization for handling PDF and Unicode encoding issues.3637## Quick Start3839```bash40# Normalize text from stdin41echo "Hello\u2019world" | .pi/skills/normalize/run.sh4243# Normalize a file44.pi/skills/normalize/run.sh document.txt4546# Normalize with output file47.pi/skills/normalize/run.sh document.txt -o clean.txt4849# Treat argument as text (not filename)50.pi/skills/normalize/run.sh -t "Hello\u201cworld\u201d"5152# Show statistics53.pi/skills/normalize/run.sh document.txt --stats54```5556## What It Normalizes5758| Category | Examples | Normalized To |59|----------|----------|---------------|60| **Whitespace** | Non-breaking, em/en space, hair space | Regular space |61| **Hyphens** | En dash, em dash, minus sign, figure dash | ASCII hyphen `-` |62| **Quotes** | Curly quotes, guillemets, primes | Straight `'` and `"` |63| **Windows-1252** | `\x93`, `\x94`, `\x92` | `"`, `"`, `'` |64| **Ligatures** | fi, fl, ffi, ffl | Expanded letters |65| **Bullets** | Various bullet points | Hyphen `-` |66| **Zero-width** | ZWSP, ZWNJ, ZWJ, BOM | Removed |67| **Directional** | LTR/RTL marks | Removed |68| **Control chars** | C0/C1 (except newline/tab) | Removed |69| **Line breaks** | `intro-\nduction` | `introduction` |7071## Pipeline Integration7273This skill is based on the same normalization used in the extractor pipeline's74s02_marker_extractor.py. The code is kept in sync with text_toolz patterns.7576### Python Usage7778```python79from normalize import normalize_text8081# Clean text for pattern matching82text = "1.\u00a0Introduction" # Non-breaking space83clean = normalize_text(text) # "1. Introduction"84```8586## Normalization Steps87881. **Windows-1252 conversion** - Handle legacy MS Office encoding892. **NFKC normalization** - Unicode compatibility decomposition903. **Remove directional formatting** - LTR/RTL marks914. **Remove control characters** - C0/C1 (preserve newlines)925. **Normalize whitespace** - All special spaces to ASCII936. **Normalize hyphens** - All dash variants to `-`947. **Normalize quotes** - Curly to straight958. **Normalize dots** - Ellipsis, leader dots969. **Normalize bullets** - All bullet types to `-`9710. **Expand ligatures** - fi/fl/ffi/ffl9811. **Fix line-break hyphens** - Join hyphenated words9912. **Collapse whitespace** - Multiple spaces to single100101## Based On102103- text_toolz library patterns104- extractor pipeline s02 normalization105- NFKC Unicode standard