@finbheara/domain 0.12.0 → 0.13.1

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 CHANGED
@@ -105,7 +105,7 @@ A `Place` is one of four arms: `resolved`, `plural` (a print naming more than on
105
105
  says they cannot be one place; `same`, `contains` and `overlaps` do not.
106
106
 
107
107
  A print that is clearly not a place is refused, with its reason: a placeholder
108
- (`[address withheld]`, `Other`), a URL anywhere in the print (`web`), an online event in the
108
+ (`[address withheld]`, `TBA`), a URL anywhere in the print (`web`), an online event in the
109
109
  venue field (`online`), a change-of-venue notice (`notice`), or a replacement character where
110
110
  the source lost bytes (`damaged`). These are asked only where the store reads nothing, so a
111
111
  refusal never takes a reading away. Mojibake that can be decoded back is not refused: repair it
@@ -171,7 +171,8 @@ compareSchoolNames("Ardvarna Academy", "Ardvarna Academy (Ontario)", reader);
171
171
  ### Your own garbage
172
172
 
173
173
  The shipped refusals are generic: a card number, keyboard filler, a run with no letter in it,
174
- the shared placeholder list of `@finbheara/names` (`N/A`, `No School`, ...). What YOUR data
174
+ what a school cell prints where no school was entered (`N/A`, `No School`, `-- Choose One --`,
175
+ ...). What YOUR data
175
176
  prints in a school field and is not a school, such as an entry system's own "school not
176
177
  listed" instruction, a test entry, or a note typed into the wrong field, is yours to declare.
177
178
  Pass it as `garbage`, the same idea as `phraseClassifier(lexicon, { garbageVocab })` in
@@ -1,9 +1,11 @@
1
+ import {
2
+ SHARED_ROW_SENTINELS2,
3
+ sentinelIn2
4
+ } from "./place-tcgfvemw.js";
1
5
  import {
2
6
  validity
3
7
  } from "./place-q9kwsmzd.js";
4
8
 
5
- import { isPlaceholderPrint } from "@finbheara/names/normalize";
6
-
7
9
  var PLACE_NODES = [
8
10
  {
9
11
  id: "world",
@@ -6781,6 +6783,8 @@ function inWebSpan(at, index) {
6781
6783
  }
6782
6784
 
6783
6785
  var DEFAULT_PLACE_CAPACITY2 = 8192;
6786
+ var PLACE_CELL_SENTINELS = [...SHARED_ROW_SENTINELS2];
6787
+ var placeCellSentinelOf = sentinelIn2(PLACE_CELL_SENTINELS);
6784
6788
  function createPlaceReader2(options = {}) {
6785
6789
  const nodes = options.tree ?? PLACE_NODES;
6786
6790
  let index;
@@ -6822,7 +6826,7 @@ function createPlaceReader2(options = {}) {
6822
6826
  return "online";
6823
6827
  if (folded === NOTICE || folded.startsWith(`${NOTICE} `))
6824
6828
  return "notice";
6825
- if (isPlaceholderPrint(raw))
6829
+ if (placeCellSentinelOf(raw) !== undefined)
6826
6830
  return "placeholder";
6827
6831
  return;
6828
6832
  }
@@ -6939,9 +6943,11 @@ function createPlaceReader2(options = {}) {
6939
6943
  ancestorsOf.set(n.id, out);
6940
6944
  }
6941
6945
  const phrases = [...byPrint.keys()].filter((k) => k.includes(" ")).sort((a, b) => b.length - a.length);
6946
+ const printsSorted = [...byPrint.keys()].map((k, i) => [k, i]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
6942
6947
  return {
6943
6948
  byId,
6944
6949
  byPrint,
6950
+ printsSorted,
6945
6951
  byCode,
6946
6952
  byTruncation,
6947
6953
  byCountryCode,
@@ -7186,13 +7192,32 @@ function createPlaceReader2(options = {}) {
7186
7192
  function completions(folded) {
7187
7193
  if (folded.length < MIN_STEM)
7188
7194
  return [];
7195
+ const i = idx();
7196
+ const sorted = i.printsSorted;
7197
+ let lo = 0;
7198
+ let hi = sorted.length;
7199
+ while (lo < hi) {
7200
+ const mid = lo + hi >>> 1;
7201
+ if (sorted[mid][0] < folded)
7202
+ lo = mid + 1;
7203
+ else
7204
+ hi = mid;
7205
+ }
7206
+ const run = [];
7207
+ for (let k = lo;k < sorted.length; k++) {
7208
+ const at = sorted[k];
7209
+ if (!at[0].startsWith(folded))
7210
+ break;
7211
+ run.push(at);
7212
+ }
7213
+ run.sort((a, b) => a[1] - b[1]);
7189
7214
  const out = [];
7190
- for (const [key, found] of idx().byPrint) {
7191
- if (key.length <= folded.length || !key.startsWith(folded))
7215
+ for (const [key] of run) {
7216
+ if (key.length <= folded.length)
7192
7217
  continue;
7193
7218
  if (key[folded.length] === " ")
7194
7219
  continue;
7195
- for (const n of found)
7220
+ for (const n of i.byPrint.get(key))
7196
7221
  if (n.kind !== "body" && n.listedCutsOnly !== true)
7197
7222
  out.push({ node: n, length: key.length });
7198
7223
  }
@@ -7415,6 +7440,24 @@ function createPlaceReader2(options = {}) {
7415
7440
  }
7416
7441
  return;
7417
7442
  }
7443
+ function taggedHead(core, declared) {
7444
+ const m = /^(.*\S)\s*(?:\(([^()[\]{}]*)\)|\[([^()[\]{}]*)\])$/su.exec(core);
7445
+ if (m === null)
7446
+ return;
7447
+ const head = m[1];
7448
+ const tag = (m[2] ?? m[3] ?? "").trim();
7449
+ if (fold(head) === "" || fold(tag) === "")
7450
+ return;
7451
+ const h = read(head, declared);
7452
+ const t = read(tag, declared);
7453
+ if (h.refusal !== null || t.refusal !== null || h.heads.length === 0 || t.heads.length === 0)
7454
+ return;
7455
+ const held = (n) => t.heads.some((x) => isAncestor(x, n));
7456
+ if (h.members !== undefined)
7457
+ return h.members.every(held) ? h : undefined;
7458
+ const kept = h.heads.filter(held);
7459
+ return kept.length === 0 ? undefined : { ...h, heads: kept };
7460
+ }
7418
7461
  function pieced(left, country) {
7419
7462
  if (namedInside(left, country).length > 0)
7420
7463
  return [left];
@@ -7569,7 +7612,7 @@ function createPlaceReader2(options = {}) {
7569
7612
  }
7570
7613
  const first = sane[0];
7571
7614
  if (first === undefined)
7572
- return (smushed ? desmush(core, declared) : undefined) ?? NOTHING;
7615
+ return taggedHead(core, declared) ?? (smushed ? desmush(core, declared) : undefined) ?? NOTHING;
7573
7616
  if (sane.length === 1)
7574
7617
  return first;
7575
7618
  const heads = [];
package/dist/place.js CHANGED
@@ -17,7 +17,8 @@ import {
17
17
  placesRelation2,
18
18
  probablySamePlace2,
19
19
  sameReading2
20
- } from "./chunks/place-jksxqsqb.js";
20
+ } from "./chunks/place-sa6438qr.js";
21
+ import"./chunks/place-tcgfvemw.js";
21
22
  export {
22
23
  DEFAULT_PLACE_CAPACITY2 as DEFAULT_PLACE_CAPACITY,
23
24
  DEFAULT_PLACE_READER2 as DEFAULT_PLACE_READER,
package/dist/promotion.js CHANGED
@@ -46,7 +46,7 @@ function samePromotedRow(was, now) {
46
46
  }
47
47
  var STOOD_FOR = /^(?:'|(?![A-Za-z])\p{L})$/u;
48
48
  function questionMarksRead(was, now) {
49
- const a = [...collapse(mojibakeRead(was))];
49
+ const a = [...collapse(cp437Read(mojibakeRead(was), now))];
50
50
  if (!a.includes("?"))
51
51
  return a.join("");
52
52
  const b = [...collapse(now)];
@@ -67,6 +67,47 @@ function questionMarksRead(was, now) {
67
67
  }
68
68
  return out.join("");
69
69
  }
70
+ var CP437_LETTERS = new Map([
71
+ [128, "Ç"],
72
+ [129, "ü"],
73
+ [130, "é"],
74
+ [131, "â"],
75
+ [132, "ä"],
76
+ [133, "à"],
77
+ [134, "å"],
78
+ [135, "ç"],
79
+ [136, "ê"],
80
+ [137, "ë"],
81
+ [138, "è"],
82
+ [139, "ï"],
83
+ [140, "î"],
84
+ [141, "ì"],
85
+ [142, "Ä"],
86
+ [143, "Å"],
87
+ [144, "É"],
88
+ [145, "æ"],
89
+ [147, "ô"],
90
+ [148, "ö"],
91
+ [149, "ò"],
92
+ [150, "û"],
93
+ [151, "ù"],
94
+ [152, "ÿ"],
95
+ [153, "Ö"],
96
+ [154, "Ü"],
97
+ [160, "á"],
98
+ [161, "í"],
99
+ [162, "ó"],
100
+ [163, "ú"],
101
+ [164, "ñ"],
102
+ [165, "Ñ"]
103
+ ].map(([byte, letter]) => [String.fromCodePoint(byte), letter]));
104
+ function cp437Read(was, now) {
105
+ const a = [...was];
106
+ const b = [...now];
107
+ if (a.length !== b.length)
108
+ return was;
109
+ return a.map((x, i) => CP437_LETTERS.get(x) === b[i] ? b[i] : x).join("");
110
+ }
70
111
  function mojibakeRead(print) {
71
112
  let out = print;
72
113
  const codes = [...out].map((c) => c.codePointAt(0) ?? 0);
package/dist/school.js CHANGED
@@ -1,3 +1,7 @@
1
+ import {
2
+ SHARED_ROW_SENTINELS2,
3
+ sentinelIn2
4
+ } from "./chunks/place-tcgfvemw.js";
1
5
  import {
2
6
  NEVER_NAME,
3
7
  printZones,
@@ -8,11 +12,7 @@ import {
8
12
  areAllPlaceTokens2,
9
13
  placeRelation2,
10
14
  sameReading2
11
- } from "./chunks/place-jksxqsqb.js";
12
- import {
13
- SHARED_ROW_SENTINELS2,
14
- sentinelIn2
15
- } from "./chunks/place-tcgfvemw.js";
15
+ } from "./chunks/place-sa6438qr.js";
16
16
  import {
17
17
  validity
18
18
  } from "./chunks/place-q9kwsmzd.js";
@@ -21,8 +21,6 @@ import { normalizeApostrophes as normalizeApostrophes2 } from "@finbheara/names/
21
21
  import { SURNAME_SEPARATOR, lexiconKey, titleCaseNamePart } from "@finbheara/names/normalize";
22
22
  import { personName } from "@finbheara/names/normalize";
23
23
 
24
- import { placeholderOf } from "@finbheara/names/normalize";
25
-
26
24
  var SCHOOL_CELL_OWN_SENTINELS = [
27
25
  {
28
26
  print: "no school",
@@ -74,7 +72,31 @@ var SCHOOL_CELL_OWN_SENTINELS = [
74
72
  print: "unknown irish dancing school",
75
73
  authority: "`Unknown Irish Dancing School`: 1 school cell"
76
74
  },
77
- { print: "none inactive dancer", authority: "`None - Inactive Dancer`: 1 school cell" }
75
+ { print: "none inactive dancer", authority: "`None - Inactive Dancer`: 1 school cell" },
76
+ { print: "not applicable", authority: "`Not applicable`: a school print, no school entered" },
77
+ {
78
+ print: "no school judge",
79
+ authority: "`No School - Judge`: an entry form's option for an adjudicator"
80
+ },
81
+ { print: "no dance school", authority: "`No Dance School`: an entry form's option" },
82
+ { print: "unknown music school", authority: "`Unknown Music School`: an entry form's option" },
83
+ { print: "school deleted", authority: "`---SCHOOL DELETED`: an entry form's option" },
84
+ { print: "select school", authority: "`--Select School--`: an entry form's unchosen option" },
85
+ { print: "school other", authority: "`School Other`: an entry form's option" },
86
+ { print: "non", authority: "`Non`: an entry form's option, the truncation of `Non-dancer`" },
87
+ {
88
+ print: "x closed select new school",
89
+ authority: "`X - CLOSED - Select New School`: an entry form's option for a closed school"
90
+ },
91
+ {
92
+ print: "x school closed please select another school",
93
+ authority: "`X -SCHOOL CLOSED - Please select another school`: an entry form's option"
94
+ },
95
+ { print: "default school", authority: "`Default School`: an entry form's default" },
96
+ {
97
+ print: "my school of irish dance",
98
+ authority: "`My School of Irish Dance`: an entry form's example text"
99
+ }
78
100
  ];
79
101
  var SCHOOL_CELL_SENTINELS = [
80
102
  ...SHARED_ROW_SENTINELS2,
@@ -321,7 +343,7 @@ function notASchoolIn(rows) {
321
343
  const text = normalizeForRefusal(print);
322
344
  if (text === "")
323
345
  return;
324
- const placeholder = schoolCellSentinelOf(text) ?? placeholderOf(text);
346
+ const placeholder = schoolCellSentinelOf(text);
325
347
  if (placeholder !== undefined)
326
348
  return placeholderRow(placeholder);
327
349
  for (const row of rows) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finbheara/domain",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "description": "Places, CLRG regions, school names, ages, dances and a person's print in its role, as they are printed: read, compared and told apart",
5
5
  "keywords": [
6
6
  "places",