@mailwoman/core 2.1.0 → 2.2.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/out/api/APIClient.d.ts +57 -0
- package/out/api/APIClient.d.ts.map +1 -0
- package/out/api/APIClient.js +108 -0
- package/out/api/APIClient.js.map +1 -0
- package/out/api/headless.d.ts +17 -0
- package/out/api/headless.d.ts.map +1 -0
- package/out/api/headless.js +18 -0
- package/out/api/headless.js.map +1 -0
- package/out/api/index.d.ts +11 -0
- package/out/api/index.d.ts.map +1 -0
- package/out/api/index.js +11 -0
- package/out/api/index.js.map +1 -0
- package/out/api/responses.d.ts +48 -0
- package/out/api/responses.d.ts.map +1 -0
- package/out/api/responses.js +68 -0
- package/out/api/responses.js.map +1 -0
- package/out/collections.d.ts +66 -0
- package/out/collections.d.ts.map +1 -0
- package/out/collections.js +97 -0
- package/out/collections.js.map +1 -0
- package/out/db/schema.d.ts +21 -0
- package/out/db/schema.d.ts.map +1 -0
- package/out/db/schema.js +16 -0
- package/out/db/schema.js.map +1 -0
- package/out/decoder/build-tree.d.ts +14 -1
- package/out/decoder/build-tree.d.ts.map +1 -1
- package/out/decoder/build-tree.js +37 -9
- package/out/decoder/build-tree.js.map +1 -1
- package/out/decoder/proposals-to-tree.d.ts.map +1 -1
- package/out/decoder/proposals-to-tree.js +2 -0
- package/out/decoder/proposals-to-tree.js.map +1 -1
- package/out/decoder/serialize-xml.d.ts +22 -1
- package/out/decoder/serialize-xml.d.ts.map +1 -1
- package/out/decoder/serialize-xml.js +64 -4
- package/out/decoder/serialize-xml.js.map +1 -1
- package/out/decoder/types.d.ts +45 -0
- package/out/decoder/types.d.ts.map +1 -1
- package/out/decoder/types.js +6 -0
- package/out/decoder/types.js.map +1 -1
- package/out/errors/index.d.ts +9 -0
- package/out/errors/index.d.ts.map +1 -0
- package/out/errors/index.js +9 -0
- package/out/errors/index.js.map +1 -0
- package/out/errors/schema.d.ts +69 -0
- package/out/errors/schema.d.ts.map +1 -0
- package/out/errors/schema.js +102 -0
- package/out/errors/schema.js.map +1 -0
- package/out/identifiers.d.ts +18 -0
- package/out/identifiers.d.ts.map +1 -0
- package/out/identifiers.js +49 -0
- package/out/identifiers.js.map +1 -0
- package/out/index.d.ts +3 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -4
- package/out/index.js.map +1 -1
- package/out/kysley/adapter.d.ts +13 -0
- package/out/kysley/adapter.d.ts.map +1 -0
- package/out/kysley/adapter.js +25 -0
- package/out/kysley/adapter.js.map +1 -0
- package/out/kysley/client.d.ts +16 -0
- package/out/kysley/client.d.ts.map +1 -0
- package/out/kysley/client.js +22 -0
- package/out/kysley/client.js.map +1 -0
- package/out/kysley/dialect-config.d.ts +27 -0
- package/out/kysley/dialect-config.d.ts.map +1 -0
- package/out/kysley/dialect-config.js +7 -0
- package/out/kysley/dialect-config.js.map +1 -0
- package/out/kysley/dialect.d.ts +39 -0
- package/out/kysley/dialect.d.ts.map +1 -0
- package/out/kysley/dialect.js +49 -0
- package/out/kysley/dialect.js.map +1 -0
- package/out/kysley/driver.d.ts +22 -0
- package/out/kysley/driver.d.ts.map +1 -0
- package/out/kysley/driver.js +114 -0
- package/out/kysley/driver.js.map +1 -0
- package/out/lifecycle/ServiceSymbol.d.ts +59 -0
- package/out/lifecycle/ServiceSymbol.d.ts.map +1 -0
- package/out/lifecycle/ServiceSymbol.js +62 -0
- package/out/lifecycle/ServiceSymbol.js.map +1 -0
- package/out/lifecycle/index.d.ts +11 -0
- package/out/lifecycle/index.d.ts.map +1 -0
- package/out/lifecycle/index.js +11 -0
- package/out/lifecycle/index.js.map +1 -0
- package/out/lifecycle/lru-cache.d.ts +22 -0
- package/out/lifecycle/lru-cache.d.ts.map +1 -0
- package/out/lifecycle/lru-cache.js +31 -0
- package/out/lifecycle/lru-cache.js.map +1 -0
- package/out/lifecycle/services.d.ts +145 -0
- package/out/lifecycle/services.d.ts.map +1 -0
- package/out/lifecycle/services.js +190 -0
- package/out/lifecycle/services.js.map +1 -0
- package/out/logging/index.d.ts +7 -0
- package/out/logging/index.d.ts.map +1 -0
- package/out/logging/index.js +7 -0
- package/out/logging/index.js.map +1 -0
- package/out/logging/shared.d.ts +60 -0
- package/out/logging/shared.d.ts.map +1 -0
- package/out/logging/shared.js +100 -0
- package/out/logging/shared.js.map +1 -0
- package/out/logging/tables.d.ts +7 -0
- package/out/logging/tables.d.ts.map +1 -0
- package/out/logging/tables.js +75 -0
- package/out/logging/tables.js.map +1 -0
- package/out/objects.d.ts +96 -0
- package/out/objects.d.ts.map +1 -0
- package/out/objects.js +96 -0
- package/out/objects.js.map +1 -0
- package/out/parser/proposal-pipeline.d.ts.map +1 -1
- package/out/parser/proposal-pipeline.js +0 -1
- package/out/parser/proposal-pipeline.js.map +1 -1
- package/out/pipeline/index.d.ts +14 -0
- package/out/pipeline/index.d.ts.map +1 -0
- package/out/pipeline/index.js +11 -0
- package/out/pipeline/index.js.map +1 -0
- package/out/pipeline/reconcile.d.ts +135 -0
- package/out/pipeline/reconcile.d.ts.map +1 -0
- package/out/pipeline/reconcile.js +355 -0
- package/out/pipeline/reconcile.js.map +1 -0
- package/out/pipeline/runtime-pipeline.d.ts +29 -0
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -0
- package/out/pipeline/runtime-pipeline.js +288 -0
- package/out/pipeline/runtime-pipeline.js.map +1 -0
- package/out/pipeline/span-logit-aggregation.d.ts +57 -0
- package/out/pipeline/span-logit-aggregation.d.ts.map +1 -0
- package/out/pipeline/span-logit-aggregation.js +105 -0
- package/out/pipeline/span-logit-aggregation.js.map +1 -0
- package/out/pipeline/types.d.ts +189 -0
- package/out/pipeline/types.d.ts.map +1 -0
- package/out/pipeline/types.js +16 -0
- package/out/pipeline/types.js.map +1 -0
- package/out/resolver/index.d.ts +9 -0
- package/out/resolver/index.d.ts.map +1 -0
- package/out/resolver/index.js +8 -0
- package/out/resolver/index.js.map +1 -0
- package/out/resolver/resolve.d.ts +21 -0
- package/out/resolver/resolve.d.ts.map +1 -0
- package/out/resolver/resolve.js +118 -0
- package/out/resolver/resolve.js.map +1 -0
- package/out/resolver/types.d.ts +118 -0
- package/out/resolver/types.d.ts.map +1 -0
- package/out/resolver/types.js +24 -0
- package/out/resolver/types.js.map +1 -0
- package/out/resources/git.d.ts +1 -1
- package/out/resources/index.d.ts +0 -1
- package/out/resources/index.d.ts.map +1 -1
- package/out/resources/index.js +0 -1
- package/out/resources/index.js.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.d.ts +0 -1
- package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.js +0 -1
- package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +2 -2
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.js +9 -6
- package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
- package/out/routing/index.d.ts +67 -0
- package/out/routing/index.d.ts.map +1 -0
- package/out/routing/index.js +114 -0
- package/out/routing/index.js.map +1 -0
- package/out/sets.d.ts +2 -0
- package/out/sets.d.ts.map +1 -0
- package/out/sets.js +2 -0
- package/out/sets.js.map +1 -0
- package/package.json +28 -2
- package/out/resources/db/index.d.ts +0 -57
- package/out/resources/db/index.d.ts.map +0 -1
- package/out/resources/db/index.js +0 -57
- package/out/resources/db/index.js.map +0 -1
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `reconcileSpans` — Stage 5 joint-decoding path.
|
|
7
|
+
*
|
|
8
|
+
* Today's runtime Stage 5 (in `runtime-pipeline.ts`) just keeps the classifier-emitted spans in
|
|
9
|
+
* start order. That fallback covers callers who don't yet have top-k inputs from Stages 2.7 / 3 /
|
|
10
|
+
* 6. This file is the **opt-in** joint-decoding path that turns Stage 5 from a sort into a
|
|
11
|
+
* reconciler: pick the parse tree that maximizes
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* ∏ phrase_grouper_confidence
|
|
15
|
+
* × classifier_confidence
|
|
16
|
+
* × resolver_score
|
|
17
|
+
* × concordance_bonus(parent_id chain)
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Closes the kryptonite catalogue (`NY-NY Steakhouse, Houston, TX`, `Paris, Texas`, `Saint
|
|
21
|
+
* Petersburg, FL`, `Buffalo Buffalo`) where today's argmax-per-stage produces internally-
|
|
22
|
+
* inconsistent parses that the layer above can't repair.
|
|
23
|
+
*
|
|
24
|
+
* The implementation is a beam search over candidate slots — each slot is one `(phrase_span,
|
|
25
|
+
* classifier_tag, resolver_place)` triple. Three knobs prune the cross product: `kSpan` (de-duped
|
|
26
|
+
* phrase span proposals), `kTag` (classifier tag interpretations per span), and `kResolver`
|
|
27
|
+
* (resolver candidates per `(span, tag)`). Concordance scoring is incremental — when a slot is
|
|
28
|
+
* added, we check the new place's `parent_id` chain against the running admin assignment and
|
|
29
|
+
* adjust the running score before pruning.
|
|
30
|
+
*
|
|
31
|
+
* The Thread C-s classifier top-k contract is mocked locally for v0.5.0 (see `ClassifierCandidate`
|
|
32
|
+
* below). The real classifier output adapter ships with `@mailwoman/neural` once Thread C-s
|
|
33
|
+
* lands; the existing `ResolvedPlace` shape from `@mailwoman/core/resolver` is what backs the
|
|
34
|
+
* resolver-candidates axis (parent_id chains live there).
|
|
35
|
+
*
|
|
36
|
+
* See `docs/articles/plan/phases/PHASE_8_v0_5_0_fresh_slate.md` § D for the v0.5.0 context and
|
|
37
|
+
* `docs/articles/concepts/the-knowledge-ladder.md` § Reconcile for the design rationale.
|
|
38
|
+
*/
|
|
39
|
+
const DEFAULTS = {
|
|
40
|
+
kSpan: 3,
|
|
41
|
+
kTag: 3,
|
|
42
|
+
kResolver: 5,
|
|
43
|
+
concordanceWeight: 1.0,
|
|
44
|
+
beamWidth: 16,
|
|
45
|
+
runnersUp: 3,
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Log-space bonus per accepted slot. Counterweight for the multiplicative penalty inherent in
|
|
49
|
+
* "score = ∏ confidences": each factor in [0, 1] strictly lowers the running score, which would
|
|
50
|
+
* otherwise make the empty parse always win. log(2.5) — a slot whose product of factors exceeds
|
|
51
|
+
* 1/2.5 = 0.4 is worth including; below that, the search prefers to skip.
|
|
52
|
+
*
|
|
53
|
+
* The choice of 2.5 is a tuning constant, not a free parameter we expose — exposing it would invite
|
|
54
|
+
* callers to disable inclusion entirely (defeating the purpose of the reconciler) and the sensible
|
|
55
|
+
* range is narrow. Lives here rather than `ReconcileOpts` for that reason.
|
|
56
|
+
*/
|
|
57
|
+
const INCLUSION_LOG_BONUS = Math.log(2.5);
|
|
58
|
+
/**
|
|
59
|
+
* Admin levels from coarse to fine. Concordance scoring walks pairs (parent_level, child_level) and
|
|
60
|
+
* checks the child's parent_id chain for the parent's place id.
|
|
61
|
+
*/
|
|
62
|
+
const ADMIN_LEVELS = ["country", "region", "locality", "dependent_locality"];
|
|
63
|
+
const ADMIN_LEVEL_SET = new Set(ADMIN_LEVELS);
|
|
64
|
+
/**
|
|
65
|
+
* Joint-decode the best parse tree from Stage 2.7 phrase proposals, Stage 3 classifier top-k, and
|
|
66
|
+
* Stage 6 resolver candidates. See file header for the scoring formula.
|
|
67
|
+
*
|
|
68
|
+
* The result tree's roots are the winning `(span, tag, place)` triples in source order. Each node's
|
|
69
|
+
* `placeId`, `lat`, `lon` come from the chosen resolver candidate; `confidence` reflects the per-
|
|
70
|
+
* factor score for that slot. `runnersUp` are the next-best parses for caller inspection.
|
|
71
|
+
*
|
|
72
|
+
* Empty `classifierTopK` short-circuits to an empty tree at confidence 0 — no joint decode is
|
|
73
|
+
* possible without tag interpretations. Callers without top-k should use the runtime-pipeline
|
|
74
|
+
* fallback (which keeps classifier-emitted spans sorted by start).
|
|
75
|
+
*/
|
|
76
|
+
export function reconcileSpans(inputs) {
|
|
77
|
+
const opts = { ...DEFAULTS, ...inputs.opts };
|
|
78
|
+
const slots = buildSlots(inputs, opts);
|
|
79
|
+
if (slots.length === 0) {
|
|
80
|
+
return emptyParseTree(inputs.raw);
|
|
81
|
+
}
|
|
82
|
+
// Beam search over left-to-right slot inclusion. Each slot is either accepted (if non-
|
|
83
|
+
// overlapping with the beam's claimed range) or skipped. Beam pruning keeps the top
|
|
84
|
+
// `beamWidth` by running log-score.
|
|
85
|
+
const slotsByStart = slots.slice().sort((a, b) => a.span.start - b.span.start);
|
|
86
|
+
let beams = [{ assignments: [], logScore: 0, lastEnd: -1 }];
|
|
87
|
+
for (const slot of slotsByStart) {
|
|
88
|
+
const next = [];
|
|
89
|
+
for (const beam of beams) {
|
|
90
|
+
next.push(beam);
|
|
91
|
+
if (slot.span.start >= beam.lastEnd) {
|
|
92
|
+
const concordanceDelta = concordanceDeltaFor(beam.assignments, slot, inputs, opts);
|
|
93
|
+
if (concordanceDelta === Number.NEGATIVE_INFINITY)
|
|
94
|
+
continue;
|
|
95
|
+
const slotLog = logSafe(slot.phraseConf) +
|
|
96
|
+
logSafe(slot.classifierScore) +
|
|
97
|
+
logSafe(slot.resolverScore) +
|
|
98
|
+
concordanceDelta +
|
|
99
|
+
INCLUSION_LOG_BONUS;
|
|
100
|
+
next.push({
|
|
101
|
+
assignments: [...beam.assignments, slot],
|
|
102
|
+
logScore: beam.logScore + slotLog,
|
|
103
|
+
lastEnd: slot.span.end,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
next.sort((a, b) => b.logScore - a.logScore);
|
|
108
|
+
beams = next.slice(0, opts.beamWidth);
|
|
109
|
+
}
|
|
110
|
+
beams.sort((a, b) => b.logScore - a.logScore);
|
|
111
|
+
// Drop the empty beam if there's at least one non-empty competitor (the empty beam scores 0,
|
|
112
|
+
// which would otherwise dominate when all real candidates have very low log-scores).
|
|
113
|
+
const populated = beams.filter((b) => b.assignments.length > 0);
|
|
114
|
+
const ordered = populated.length > 0 ? populated : beams;
|
|
115
|
+
const top = ordered[0];
|
|
116
|
+
const runners = ordered.slice(1, 1 + opts.runnersUp);
|
|
117
|
+
const trees = ordered.map((b) => buildTree(b, inputs.raw));
|
|
118
|
+
const confidences = softmax(ordered.map((b) => b.logScore));
|
|
119
|
+
return {
|
|
120
|
+
tree: trees[0],
|
|
121
|
+
confidence: confidences[0],
|
|
122
|
+
runnersUp: runners.map((_, i) => trees[i + 1]),
|
|
123
|
+
scoreBreakdown: breakdownFor(top, inputs, opts),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Build the candidate slot set: dedupe phrase proposals by (start, end), join with classifier top-k
|
|
128
|
+
* tag candidates, join with resolver places per (span, tag).
|
|
129
|
+
*
|
|
130
|
+
* Spans with no classifier candidate are dropped — the reconciler cannot tag them. Spans with no
|
|
131
|
+
* resolver candidate still survive; the resolver score defaults to 1 (neutral) and the slot's place
|
|
132
|
+
* is null (won't contribute to concordance).
|
|
133
|
+
*/
|
|
134
|
+
function buildSlots(inputs, opts) {
|
|
135
|
+
const bySpanKey = new Map();
|
|
136
|
+
for (const p of inputs.phraseProposals) {
|
|
137
|
+
const k = spanKey(p.span.start, p.span.end);
|
|
138
|
+
const cur = bySpanKey.get(k);
|
|
139
|
+
if (!cur || p.confidence > cur.confidence) {
|
|
140
|
+
bySpanKey.set(k, p);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// `kSpan` limits the number of overlapping proposals anchored at each start position — NOT a
|
|
144
|
+
// global cap on phrase proposals. Two phrases at different starts (e.g. `Houston` at 18 +
|
|
145
|
+
// `TX` at 27) are independent candidates and both must survive `kSpan = 3`. Without this per-
|
|
146
|
+
// start grouping, a low-confidence-but-correct proposal (e.g. `Houston` @ 0.65) is dropped
|
|
147
|
+
// just because the input has many higher-confidence proposals elsewhere.
|
|
148
|
+
const byStart = new Map();
|
|
149
|
+
for (const p of bySpanKey.values()) {
|
|
150
|
+
const arr = byStart.get(p.span.start) ?? [];
|
|
151
|
+
arr.push(p);
|
|
152
|
+
byStart.set(p.span.start, arr);
|
|
153
|
+
}
|
|
154
|
+
const spans = [];
|
|
155
|
+
for (const arr of byStart.values()) {
|
|
156
|
+
spans.push(...topN(arr, opts.kSpan, (p) => p.confidence));
|
|
157
|
+
}
|
|
158
|
+
const tagsBySpan = new Map();
|
|
159
|
+
for (const c of inputs.classifierTopK) {
|
|
160
|
+
const k = spanKey(c.span.start, c.span.end);
|
|
161
|
+
const arr = tagsBySpan.get(k) ?? [];
|
|
162
|
+
arr.push(c);
|
|
163
|
+
tagsBySpan.set(k, arr);
|
|
164
|
+
}
|
|
165
|
+
const slots = [];
|
|
166
|
+
for (const phrase of spans) {
|
|
167
|
+
const key = spanKey(phrase.span.start, phrase.span.end);
|
|
168
|
+
const tagCandidates = topN(tagsBySpan.get(key) ?? [], opts.kTag, (c) => c.score);
|
|
169
|
+
for (const tagC of tagCandidates) {
|
|
170
|
+
const places = inputs.resolverCandidates
|
|
171
|
+
? inputs.resolverCandidates.candidatesFor(tagC.span, tagC.tag).slice(0, opts.kResolver)
|
|
172
|
+
: [];
|
|
173
|
+
if (places.length === 0) {
|
|
174
|
+
slots.push({
|
|
175
|
+
span: phrase.span,
|
|
176
|
+
phraseConf: phrase.confidence,
|
|
177
|
+
tag: tagC.tag,
|
|
178
|
+
classifierScore: tagC.score,
|
|
179
|
+
place: null,
|
|
180
|
+
resolverScore: 1,
|
|
181
|
+
});
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
for (const place of places) {
|
|
185
|
+
slots.push({
|
|
186
|
+
span: phrase.span,
|
|
187
|
+
phraseConf: phrase.confidence,
|
|
188
|
+
tag: tagC.tag,
|
|
189
|
+
classifierScore: tagC.score,
|
|
190
|
+
place,
|
|
191
|
+
resolverScore: normalizeResolverScore(place.score),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return slots;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Concordance delta for adding `slot` to an existing beam. Returns the log-space contribution to
|
|
200
|
+
* add to the beam's running score, or `-Infinity` if the slot introduces a hard contradiction
|
|
201
|
+
* (would be admissible into the beam's admin chain but explicitly disagrees).
|
|
202
|
+
*
|
|
203
|
+
* Behavior at the boundaries:
|
|
204
|
+
*
|
|
205
|
+
* - Slot has no place or is non-admin → 0 (no chain contribution).
|
|
206
|
+
* - No admin neighbors yet → 0 (nothing to agree with).
|
|
207
|
+
* - Admin chain agrees → `+ concordanceWeight × log(1 + match_ratio)`.
|
|
208
|
+
* - Some admin pairs cannot be verified (missing parents) → 0 contribution per neutral pair.
|
|
209
|
+
* - Admin chain has any explicit contradiction → `-Infinity` (hard veto).
|
|
210
|
+
*/
|
|
211
|
+
function concordanceDeltaFor(existing, candidate, inputs, opts) {
|
|
212
|
+
if (!candidate.place || !ADMIN_LEVEL_SET.has(candidate.tag))
|
|
213
|
+
return 0;
|
|
214
|
+
const chainOf = inputs.parentChain;
|
|
215
|
+
if (!chainOf)
|
|
216
|
+
return 0;
|
|
217
|
+
const candIdx = ADMIN_LEVELS.indexOf(candidate.tag);
|
|
218
|
+
let matches = 0;
|
|
219
|
+
let neutrals = 0;
|
|
220
|
+
let pairs = 0;
|
|
221
|
+
for (const prior of existing) {
|
|
222
|
+
if (!prior.place || !ADMIN_LEVEL_SET.has(prior.tag))
|
|
223
|
+
continue;
|
|
224
|
+
const priorIdx = ADMIN_LEVELS.indexOf(prior.tag);
|
|
225
|
+
const child = priorIdx > candIdx ? prior : candidate;
|
|
226
|
+
const parent = priorIdx > candIdx ? candidate : prior;
|
|
227
|
+
if (child === parent)
|
|
228
|
+
continue;
|
|
229
|
+
const chain = chainOf.parentsOf(child.place);
|
|
230
|
+
pairs++;
|
|
231
|
+
if (chain.length === 0) {
|
|
232
|
+
neutrals++;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const hit = chain.some((p) => idsEqual(p.id, parent.place.id));
|
|
236
|
+
if (hit) {
|
|
237
|
+
matches++;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return Number.NEGATIVE_INFINITY;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (pairs === 0)
|
|
244
|
+
return 0;
|
|
245
|
+
const matchRatio = matches / pairs;
|
|
246
|
+
// Linear in matchRatio so a fully-consistent chain contributes exactly `+concordanceWeight`
|
|
247
|
+
// log-space — the briefing's "+1 for fully consistent" reading. Matches contribute
|
|
248
|
+
// proportionally; neutrals (no chain data) don't penalize.
|
|
249
|
+
return opts.concordanceWeight * matchRatio;
|
|
250
|
+
}
|
|
251
|
+
function idsEqual(a, b) {
|
|
252
|
+
return String(a) === String(b);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Compute the per-factor breakdown for the winning beam. Independently of the search's `logScore`
|
|
256
|
+
* (which carries the inclusion-bonus prior), the breakdown surfaces the bare `phrase × classifier ×
|
|
257
|
+
* resolver × concordance` product so callers can introspect why a tree won.
|
|
258
|
+
*/
|
|
259
|
+
function breakdownFor(beam, inputs, opts) {
|
|
260
|
+
let phrase = 1;
|
|
261
|
+
let classifier = 1;
|
|
262
|
+
let resolver = 1;
|
|
263
|
+
for (const a of beam.assignments) {
|
|
264
|
+
phrase *= Math.max(a.phraseConf, 0);
|
|
265
|
+
classifier *= Math.max(a.classifierScore, 0);
|
|
266
|
+
resolver *= Math.max(a.resolverScore, 0);
|
|
267
|
+
}
|
|
268
|
+
const concordanceLog = totalConcordanceLog(beam.assignments, inputs, opts);
|
|
269
|
+
const concordance = Math.exp(concordanceLog);
|
|
270
|
+
const total = phrase * classifier * resolver * concordance;
|
|
271
|
+
return { phrase, classifier, resolver, concordance, total };
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Recompute the joint concordance contribution for the entire assignment list (vs the incremental
|
|
275
|
+
* `concordanceDeltaFor` used during search). Used by the breakdown.
|
|
276
|
+
*/
|
|
277
|
+
function totalConcordanceLog(assignments, inputs, opts) {
|
|
278
|
+
if (!inputs.parentChain)
|
|
279
|
+
return 0;
|
|
280
|
+
let acc = 0;
|
|
281
|
+
for (let i = 0; i < assignments.length; i++) {
|
|
282
|
+
const delta = concordanceDeltaFor(assignments.slice(0, i), assignments[i], inputs, opts);
|
|
283
|
+
if (delta === Number.NEGATIVE_INFINITY)
|
|
284
|
+
return Number.NEGATIVE_INFINITY;
|
|
285
|
+
acc += delta;
|
|
286
|
+
}
|
|
287
|
+
return acc;
|
|
288
|
+
}
|
|
289
|
+
function buildTree(beam, raw) {
|
|
290
|
+
const roots = beam.assignments
|
|
291
|
+
.slice()
|
|
292
|
+
.sort((a, b) => a.span.start - b.span.start)
|
|
293
|
+
.map((slot) => ({
|
|
294
|
+
tag: slot.tag,
|
|
295
|
+
value: raw.slice(slot.span.start, slot.span.end),
|
|
296
|
+
start: slot.span.start,
|
|
297
|
+
end: slot.span.end,
|
|
298
|
+
confidence: slot.classifierScore * slot.phraseConf,
|
|
299
|
+
children: [],
|
|
300
|
+
source: "reconcile",
|
|
301
|
+
sourceId: "reconcile:stage-5-joint",
|
|
302
|
+
...(slot.place
|
|
303
|
+
? {
|
|
304
|
+
lat: slot.place.lat,
|
|
305
|
+
lon: slot.place.lon,
|
|
306
|
+
placeId: `${placeIdPrefix(slot.place)}:${slot.place.id}`,
|
|
307
|
+
}
|
|
308
|
+
: {}),
|
|
309
|
+
}));
|
|
310
|
+
return { raw, roots };
|
|
311
|
+
}
|
|
312
|
+
function emptyParseTree(raw) {
|
|
313
|
+
return {
|
|
314
|
+
tree: { raw, roots: [] },
|
|
315
|
+
confidence: 0,
|
|
316
|
+
runnersUp: [],
|
|
317
|
+
scoreBreakdown: { phrase: 0, classifier: 0, resolver: 0, concordance: 1, total: 0 },
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function placeIdPrefix(place) {
|
|
321
|
+
// Mirror the convention used by @mailwoman/resolver-wof-sqlite (`wof:<id>`). Resolver
|
|
322
|
+
// backends that don't carry an implicit vendor in `id` get a neutral `place:` prefix.
|
|
323
|
+
return typeof place.id === "number" ? "wof" : "place";
|
|
324
|
+
}
|
|
325
|
+
function spanKey(start, end) {
|
|
326
|
+
return `${start}:${end}`;
|
|
327
|
+
}
|
|
328
|
+
function topN(items, n, key) {
|
|
329
|
+
return items
|
|
330
|
+
.slice()
|
|
331
|
+
.sort((a, b) => key(b) - key(a))
|
|
332
|
+
.slice(0, n);
|
|
333
|
+
}
|
|
334
|
+
function logSafe(x) {
|
|
335
|
+
return x > 0 ? Math.log(x) : -50;
|
|
336
|
+
}
|
|
337
|
+
function normalizeResolverScore(score) {
|
|
338
|
+
// Resolver score scale is implementation-defined; clamp to (0, 1] for the multiplicative
|
|
339
|
+
// combiner. A backend that returns 0 still counts as a candidate (e.g. a partial match) but
|
|
340
|
+
// contributes a tiny log-factor.
|
|
341
|
+
if (!Number.isFinite(score) || score <= 0)
|
|
342
|
+
return 0.01;
|
|
343
|
+
if (score > 1)
|
|
344
|
+
return 1;
|
|
345
|
+
return score;
|
|
346
|
+
}
|
|
347
|
+
function softmax(scores) {
|
|
348
|
+
if (scores.length === 0)
|
|
349
|
+
return [];
|
|
350
|
+
const max = Math.max(...scores);
|
|
351
|
+
const exps = scores.map((s) => Math.exp(s - max));
|
|
352
|
+
const sum = exps.reduce((a, b) => a + b, 0);
|
|
353
|
+
return exps.map((e) => e / sum);
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=reconcile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile.js","sourceRoot":"","sources":["../../pipeline/reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAuFH,MAAM,QAAQ,GAAG;IAChB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,SA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O,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `runPipeline` — the runtime coordinator that composes all six stages.
|
|
7
|
+
*
|
|
8
|
+
* Generic over stage implementations (see `types.ts::RuntimePipelineStages`). Each stage is
|
|
9
|
+
* injected; the coordinator handles composition, timing, fast-path routing, and graceful
|
|
10
|
+
* degradation when stages are absent.
|
|
11
|
+
*
|
|
12
|
+
* Implementation contract per `docs/articles/plan/reference/STAGES.md`.
|
|
13
|
+
*/
|
|
14
|
+
import type { PipelineOpts, PipelineResult, RuntimePipelineStages } from "./types.js";
|
|
15
|
+
/**
|
|
16
|
+
* Run the runtime pipeline.
|
|
17
|
+
*
|
|
18
|
+
* Composition order (per STAGES.md):
|
|
19
|
+
*
|
|
20
|
+
* 1. Normalize (or identity)
|
|
21
|
+
* 2. Compute QueryShape (or empty)
|
|
22
|
+
* 3. Locale gate (or caller-trust)
|
|
23
|
+
* 4. Kind classifier (or default structured_address)
|
|
24
|
+
* 5. Branch: fast-path → resolver; full → classifier → resolver
|
|
25
|
+
*
|
|
26
|
+
* Per-stage timing recorded on `result.timing`. Fast-path stages are absent from the timing map.
|
|
27
|
+
*/
|
|
28
|
+
export declare function runPipeline(raw: string, stages: RuntimePipelineStages, opts?: PipelineOpts): Promise<PipelineResult>;
|
|
29
|
+
//# sourceMappingURL=runtime-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-pipeline.d.ts","sourceRoot":"","sources":["../../pipeline/runtime-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAMX,YAAY,EACZ,cAAc,EAGd,qBAAqB,EACrB,MAAM,YAAY,CAAA;AA6HnB;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAChC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,IAAI,CAAC,EAAE,YAAY,GACjB,OAAO,CAAC,cAAc,CAAC,CA8IzB"}
|