@finbheara/domain 0.58.0 → 0.59.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/dist/age.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  youngFloor2,
41
41
  tooYoungForMajor2,
42
42
  tooYoungForFeis2
43
- } from "./chunks/place-w6d4xfzc.js";
43
+ } from "./chunks/place-mbtx4htf.js";
44
44
  export {
45
45
  ADULT_FLOOR2 as ADULT_FLOOR,
46
46
  AVERAGE_AGE_DECIMALS2 as AVERAGE_AGE_DECIMALS,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Age2,
3
3
  ageRelation2
4
- } from "./place-w6d4xfzc.js";
4
+ } from "./place-mbtx4htf.js";
5
5
  import {
6
6
  validity
7
7
  } from "./place-q9kwsmzd.js";
@@ -44,6 +44,7 @@ var AND_UNDER_RANGE = /(?<![a-z0-9])(\d{1,2})\s*(?:&|\band\b)\s*under\s*(\d{1,2}
44
44
  var AND_RANGE = /(?<![a-z0-9])(?<!\b(?:under|und|over|faoi|cionn|u|o)\.?\s*)(?<!\d\s*,\s*)(?<!\(\s*)(\d{1,2})\s*(?:&|\band\b)\s*(\d{1,2})(?![a-z0-9])(?!\s*-?\s*hand)(?!\s*(?:&|\+|\/|,|\)|\band\b|\bor\b))/i;
45
45
  var SLASH_RANGE = /(?<![a-z0-9/])(\d{1,2})\s*\/\s*(\d{1,2})(?=\s*(?:years?|yrs?|boys?|girls?|ladies|men)\b)/i;
46
46
  var AGE_N = /(?<!\b(?:under|over)\s*)\bage\s*(\d{1,2})(?![a-z0-9])(?!\s*-?\s*hand)/i;
47
+ var AGE_RANGE = /(?<!\b(?:under|over)\s*)\bage\s*(\d{1,2})\s+(\d{1,2})(?![a-z0-9])(?!\s*-?\s*hand)/i;
47
48
  var YEARS = /(?<![a-z0-9])(?<!\d\s*(?:&|\/|\band\b|[-\u0096–—]|\bto\b)\s*)(\d{1,2})\s*(?:years?|yrs?)(?![a-z0-9])(?!\s*(?:&|\+|\/|\band\b|\bor\b|old))/i;
48
49
  var RANGE_DASH = String.raw`(?:\u00c2?[-\u0096–—]|\bto\b)`;
49
50
  var RANGE = new RegExp(String.raw`(?<![0-9])(?<![0-9][a-z]*)(?<!(?:^|[^a-z0-9])[a-z])(?:u\s*)?(\d{1,2})\s*${RANGE_DASH}\s*(\d{1,2})(?![a-z0-9])`, "i");
@@ -126,6 +127,9 @@ function readAnchored(title, s, offset, adultWord, aside = false) {
126
127
  const r = RANGE.exec(stripped);
127
128
  if (r?.[1] !== undefined && r[2] !== undefined && inFence(r[1], r[2]))
128
129
  return at(title, offset + shift, r.index, r.index + r[0].length, `${Number(r[1])}-${Number(r[2])}`);
130
+ const ar = AGE_RANGE.exec(s);
131
+ if (ar?.[1] !== undefined && ar[2] !== undefined && inFence(ar[1], ar[2]))
132
+ return at(title, offset, ar.index, ar.index + ar[0].length, `${Number(ar[1])}-${Number(ar[2])}`);
129
133
  const au = AND_UNDER.exec(s);
130
134
  if (au?.[1] !== undefined)
131
135
  return at(title, offset, au.index, au.index + au[0].length, `u${Number(au[1]) + 1}`);
package/dist/code.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Age2
3
- } from "./chunks/place-w6d4xfzc.js";
3
+ } from "./chunks/place-mbtx4htf.js";
4
4
  import {
5
5
  populationIn2,
6
6
  compTitle2
7
- } from "./chunks/place-dn6qk21g.js";
7
+ } from "./chunks/place-00sx835a.js";
8
8
  import {
9
9
  validity
10
10
  } from "./chunks/place-q9kwsmzd.js";
package/dist/schedule.js CHANGED
@@ -1,8 +1,8 @@
1
- import"./chunks/place-w6d4xfzc.js";
1
+ import"./chunks/place-mbtx4htf.js";
2
2
  import {
3
3
  compTitle2,
4
4
  matchTitle2
5
- } from "./chunks/place-dn6qk21g.js";
5
+ } from "./chunks/place-00sx835a.js";
6
6
 
7
7
  function hallKey(hall) {
8
8
  return hall.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
package/dist/school.js CHANGED
@@ -999,6 +999,48 @@ var MATCH_KEY_INSTITUTION_WORDS = [
999
999
  ].sort();
1000
1000
 
1001
1001
  import { normalizeApostrophes } from "@finbheara/names/lexicon";
1002
+
1003
+ var CP1252_HIGH = "€‚ƒ„…†‡ˆ‰Š‹Œ" + "Ž‘’“”•–—˜™š›" + "œžŸ";
1004
+ var BYTE_OF_CP1252 = new Map([...CP1252_HIGH].map((ch, i) => [ch.codePointAt(0), 128 + i]));
1005
+ var MOJIBAKE = /[Â-ßà-ï][€-¿‚-›ŒŠŽ]/u;
1006
+ var MOJIBAKE_ALL = new RegExp(MOJIBAKE.source, "gu");
1007
+ var FLATTENED_NBSP = /(?<=\S)[Â-Å] /u;
1008
+ function isNbspLead(code) {
1009
+ return code >= 194 && code <= 197;
1010
+ }
1011
+ var NON_LATIN_LETTER = /(?!\p{Script=Latin})\p{L}/u;
1012
+ function isRepair(before, after) {
1013
+ if (!NON_LATIN_LETTER.test(after))
1014
+ return true;
1015
+ return (before.match(MOJIBAKE_ALL)?.length ?? 0) >= 2;
1016
+ }
1017
+ function undoMojibake(s) {
1018
+ const bytes = new Uint8Array(s.length);
1019
+ for (let i = 0;i < s.length; i++) {
1020
+ const code = s.charCodeAt(i);
1021
+ const flattened = code === 32 && i > 1 && isNbspLead(s.charCodeAt(i - 1)) && /\S/u.test(s[i - 2]);
1022
+ const byte = flattened ? 160 : BYTE_OF_CP1252.get(code) ?? code;
1023
+ if (byte > 255)
1024
+ return;
1025
+ bytes[i] = byte;
1026
+ }
1027
+ try {
1028
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
1029
+ } catch {
1030
+ return;
1031
+ }
1032
+ }
1033
+ function repairSchoolMojibake(print) {
1034
+ let s = print;
1035
+ for (let round = 0;round < 3 && (MOJIBAKE.test(s) || FLATTENED_NBSP.test(s)); round++) {
1036
+ const undone = undoMojibake(s);
1037
+ if (undone === undefined || undone === s || !isRepair(s, undone))
1038
+ return s;
1039
+ s = undone;
1040
+ }
1041
+ return s;
1042
+ }
1043
+
1002
1044
  var SCHOOL_FLUFF_WORDS = new Set([
1003
1045
  ...[...SCHOOL_FLUFF_VOCABULARY.values()].filter((entry) => entry.tokenFluff).map((entry) => entry.canonical),
1004
1046
  ...MATCH_KEY_INSTITUTION_WORDS
@@ -1039,7 +1081,7 @@ function distinctiveTokens(tokens) {
1039
1081
  return tokens.filter((t) => t.length > 2 && !SCHOOL_FLUFF_WORDS.has(t));
1040
1082
  }
1041
1083
  function foldSchoolName(raw) {
1042
- let s = raw.toLowerCase();
1084
+ let s = repairSchoolMojibake(raw).toLowerCase();
1043
1085
  s = s.normalize("NFD").replace(/[̀-ͯ]/g, "");
1044
1086
  s = s.replace(/ß/g, "ss").replace(/æ/g, "ae").replace(/œ/g, "oe").replace(/ø/g, "o");
1045
1087
  s = normalizeApostrophes(s);
@@ -1124,41 +1166,6 @@ function createSchoolNameReader(options = {}) {
1124
1166
  ...options.garbage ?? [],
1125
1167
  ...options.refusals ?? NOT_A_SCHOOL
1126
1168
  ]);
1127
- const CP1252_HIGH = "€‚ƒ„…†‡ˆ‰Š‹Œ" + "Ž‘’“”•–—˜™š›" + "œžŸ";
1128
- const BYTE_OF_CP1252 = new Map([...CP1252_HIGH].map((ch, i) => [ch.codePointAt(0), 128 + i]));
1129
- const MOJIBAKE = /[Â-ßà-ï][€-¿‚-›ŒŠŽ]/u;
1130
- const MOJIBAKE_ALL = new RegExp(MOJIBAKE.source, "gu");
1131
- const NON_LATIN_LETTER = /(?!\p{Script=Latin})\p{L}/u;
1132
- function isRepair(before, after) {
1133
- if (!NON_LATIN_LETTER.test(after))
1134
- return true;
1135
- return (before.match(MOJIBAKE_ALL)?.length ?? 0) >= 2;
1136
- }
1137
- function undoMojibake(s) {
1138
- const bytes = new Uint8Array(s.length);
1139
- for (let i = 0;i < s.length; i++) {
1140
- const code = s.charCodeAt(i);
1141
- const byte = BYTE_OF_CP1252.get(code) ?? code;
1142
- if (byte > 255)
1143
- return;
1144
- bytes[i] = byte;
1145
- }
1146
- try {
1147
- return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
1148
- } catch {
1149
- return;
1150
- }
1151
- }
1152
- function repairMojibake(print) {
1153
- let s = print;
1154
- for (let round = 0;round < 3 && MOJIBAKE.test(s); round++) {
1155
- const undone = undoMojibake(s);
1156
- if (undone === undefined || undone === s || !isRepair(s, undone))
1157
- return s;
1158
- s = undone;
1159
- }
1160
- return s;
1161
- }
1162
1169
  const SPACING_ACUTE_AFTER_VOWEL = /((?<=\p{L})[AEIOUaeiou]|[AEIUaeiu])[´ˊ](?![sS]\b)/gu;
1163
1170
  const SPACING_ACUTE = /[´ˊ]/gu;
1164
1171
  function readSpacingAcute(print) {
@@ -1166,7 +1173,7 @@ function createSchoolNameReader(options = {}) {
1166
1173
  }
1167
1174
  const INJECTED_LINK = /(?<=^|[\s([])(?:https?:\/\/|www\.)[^\s)\]]+/giu;
1168
1175
  function renderSn1(print) {
1169
- return normalizeApostrophes2(readSpacingAcute(repairMojibake(print)).normalize("NFKC")).replace(/\p{Cf}+/gu, "").replace(/\p{Cc}+/gu, " ").replace(INJECTED_LINK, " ").replace(/\s+/gu, " ").trim();
1176
+ return normalizeApostrophes2(readSpacingAcute(repairSchoolMojibake(print)).normalize("NFKC")).replace(/\p{Cf}+/gu, "").replace(/\p{Cc}+/gu, " ").replace(INJECTED_LINK, " ").replace(/\s+/gu, " ").trim();
1170
1177
  }
1171
1178
  const COMPOUND_OPENERS = new Set([
1172
1179
  "hyphen",
package/dist/title.js CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  titleRelation2,
10
10
  ladderOf2,
11
11
  matchTitle2
12
- } from "./chunks/place-dn6qk21g.js";
13
- import"./chunks/place-w6d4xfzc.js";
12
+ } from "./chunks/place-00sx835a.js";
13
+ import"./chunks/place-mbtx4htf.js";
14
14
  export {
15
15
  codePopulation2 as codePopulation,
16
16
  compTitle2 as compTitle,
@@ -0,0 +1 @@
1
+ export declare function repairSchoolMojibake(print: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finbheara/domain",
3
- "version": "0.58.0",
3
+ "version": "0.59.0",
4
4
  "description": "Places, CLRG regions and events, school names and the links between schools, ages, dances, competition titles, codes and schedules, and a person's print in its role, as they are printed: read, compared and told apart",
5
5
  "keywords": [
6
6
  "places",