@mailwoman/normalize 4.9.0 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +68 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @mailwoman/normalize
2
+
3
+ **Stage 1 of the Mailwoman runtime pipeline** — deterministic input preprocessing.
4
+
5
+ Pure-function text normalization that prepares free-text address strings for
6
+ downstream parsing stages. Every transform produces a load-bearing `offsetMap`
7
+ so downstream stages can map normalized-string spans back to raw-string character
8
+ offsets.
9
+
10
+ ```ts
11
+ import { normalize } from "@mailwoman/normalize"
12
+
13
+ const result = normalize("123 Main St.")
14
+ // result.normalized → "123 Main St."
15
+ // result.offsetMap → maps each normalized char back to raw
16
+ ```
17
+
18
+ ## What it does
19
+
20
+ | Transform | Purpose |
21
+ | ----------------------------- | --------------------------------------------------------------------------- |
22
+ | **NFC normalization** | Unicode canonical composition |
23
+ | **Punctuation normalization** | Smart-quotes → straight, fullwidth → ASCII, elision/apostrophe preservation |
24
+ | **Whitespace collapse** | Multi-space, tab, non-breaking → single space; leading/trailing trim |
25
+ | **Abbreviation expansion** | Opt-in — `"St."` → `"Street"`, `"Ave"` → `"Avenue"` etc. |
26
+ | **CJK normalization** | CJK-specific whitespace and punctuation handling |
27
+
28
+ ## API
29
+
30
+ ```ts
31
+ // Full normalization pipeline (NFC → punctuation → whitespace)
32
+ normalize(input: string, opts?: NormalizeOpts): NormalizedInput
33
+
34
+ // Individual transforms (if you need only one)
35
+ applyNfc(input: string): NormalizedInput
36
+ applyPunctuation(input: string): NormalizedInput
37
+ collapseWhitespace(input: string): NormalizedInput
38
+ expandAbbreviations(input: string, opts?: ExpandOpts): NormalizedInput
39
+ applyCjkNormalization(input: string): CjkResult
40
+
41
+ // Offset map utilities
42
+ composeMaps(inner: OffsetMap, outer: OffsetMap): OffsetMap
43
+ identityMap(length: number): OffsetMap
44
+ ```
45
+
46
+ ## Pipeline position
47
+
48
+ ```
49
+ raw string → normalize → query-shape → locale-gate → kind-classifier → phrase-grouper → ...
50
+ ```
51
+
52
+ Stage 1 in the [Staged Pipeline Contract](https://mailwoman.sister.software/articles/plan/reference/STAGES/). No runtime dependencies.
53
+
54
+ ## Design
55
+
56
+ - **Pure functions, no side effects, no ML.** The output is byte-for-byte deterministic for the same input.
57
+ - **`offsetMap` is load-bearing.** Every transform tracks how normalized positions map back to raw input positions. This is essential for the parser to report spans in the original string.
58
+ - **Configurable via `NormalizeOpts`:** toggle `expandAbbreviations`, `normalizeCase`, and `cjk`.
59
+
60
+ ## Related
61
+
62
+ - [`@mailwoman/query-shape`](../query-shape) — Stage 1.5, structural priors that consume the normalized output
63
+ - [Staged Pipeline Contract](https://mailwoman.sister.software/articles/plan/reference/STAGES/)
64
+ - [Tokenization concepts](https://mailwoman.sister.software/articles/concepts/tokenization/)
65
+
66
+ ## License
67
+
68
+ [AGPL-3.0-only](https://www.gnu.org/licenses/agpl-3.0.html)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailwoman/normalize",
3
- "version": "4.9.0",
3
+ "version": "4.11.0",
4
4
  "description": "Stage 1 of the runtime pipeline — deterministic input preprocessing (Unicode NFC, punctuation, whitespace, abbreviation). Pure functions, no ML.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {