@mailwoman/query-shape 4.10.0 → 4.12.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.
- package/README.md +65 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @mailwoman/query-shape
|
|
2
|
+
|
|
3
|
+
**Stage 1.5 of the Mailwoman runtime pipeline** — cheap structural priors.
|
|
4
|
+
|
|
5
|
+
Pure functions that compute a structural fingerprint of an address string in
|
|
6
|
+
microseconds — character class, segmentation, known-format detection — without
|
|
7
|
+
any ML or place-name dictionaries. The `QueryShape` result informs later
|
|
8
|
+
pipeline stages (locale detection, kind classification, phrase grouping).
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { computeQueryShape } from "@mailwoman/query-shape"
|
|
12
|
+
|
|
13
|
+
const shape = computeQueryShape("1600 Amphitheatre Parkway, Mountain View, CA 94043")
|
|
14
|
+
// shape.script → "Latin"
|
|
15
|
+
// shape.hasDigits → true
|
|
16
|
+
// shape.segments → [{text: "1600 Amphitheatre Parkway", ...}, {text: "Mountain View", ...}, ...]
|
|
17
|
+
// shape.knownFormats → [{type: "us_zip5", text: "94043"}, {type: "us_state_abbr", text: "CA"}]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## What it computes
|
|
21
|
+
|
|
22
|
+
| Signal | Purpose |
|
|
23
|
+
| -------------------------- | ------------------------------------------------------------------------------ |
|
|
24
|
+
| **Character class** | Per-codepoint and per-token script classification (Latin, CJK, Cyrillic, etc.) |
|
|
25
|
+
| **Segmentation** | Split into punctuation-bounded segments (comma, newline, tab) |
|
|
26
|
+
| **Known-format detection** | Regex hits for postcode patterns, state abbreviations, PO box formats |
|
|
27
|
+
| **Region abbreviations** | US/CA/AU state/province abbreviation detection |
|
|
28
|
+
| **Whitespace pattern** | Input shape (`structured`, `single_line`, `free_text`) |
|
|
29
|
+
|
|
30
|
+
## API
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
computeQueryShape(input: string, opts?: ComputeQueryShapeOpts): QueryShape
|
|
34
|
+
|
|
35
|
+
// Individual detectors
|
|
36
|
+
classifyCodepoint(cp: number): CharacterClass
|
|
37
|
+
classifyToken(token: string): TokenClass
|
|
38
|
+
detectKnownFormats(segments: Segment[]): KnownFormatHit[]
|
|
39
|
+
detectRegionAbbreviations(segments: Segment[]): RegionAbbreviationHit[]
|
|
40
|
+
segment(input: string): Segment[]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Pipeline position
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
normalize → query-shape → locale-gate → kind-classifier → phrase-grouper → ...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Design
|
|
50
|
+
|
|
51
|
+
- **Pure, zero-dependency, microseconds-cheap.** No ML inference, no I/O, no place-name dictionaries.
|
|
52
|
+
- **Bitter-lesson-safe:** only universal structural cues — script class, format regexes, segmentation
|
|
53
|
+
punctuation. Never memorizes locale-specific place names.
|
|
54
|
+
- Accepts a minimal `NormalizedInputLite` (just `{raw, normalized}` strings) from Stage 1.
|
|
55
|
+
|
|
56
|
+
## Related
|
|
57
|
+
|
|
58
|
+
- [`@mailwoman/normalize`](../normalize) — Stage 1, feeds into this stage
|
|
59
|
+
- [`@mailwoman/locale-gate`](../locale-gate) — Stage 2, consumes `QueryShape` for locale detection
|
|
60
|
+
- [`@mailwoman/kind-classifier`](../kind-classifier) — Stage 2.5, consumes `QueryShape` for kind classification
|
|
61
|
+
- [Query Shape design rationale](https://mailwoman.sister.software/articles/plan/reference/QUERY_SHAPE/)
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
[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/query-shape",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"description": "Cheap structural priors for the runtime pipeline: character class, segmentation, known-format detection. Pure functions, no ML.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|