@finbheara/domain 0.11.0 → 0.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 +4 -1
- package/dist/chunks/{place-tv86hmps.js → place-jksxqsqb.js} +111 -6
- package/dist/person.js +7 -0
- package/dist/place.js +5 -1
- package/dist/school.js +41 -2
- package/dist/types/person.d.ts +2 -0
- package/dist/types/place.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ ESM, Node ≥ 22 or Bun ≥ 1.4.2. MIT. Not affiliated with or endorsed by any d
|
|
|
43
43
|
| `@finbheara/domain/noun-index` | `createIndex`, `indexSchema`, `personEncoder`, and the `SqlHandle`/`NounEncoder` types: a database-backed name map (below) |
|
|
44
44
|
| `@finbheara/domain/dance-types` | `danceTypes()`, `DANCE_TYPES`, `rhythmOfTime`, and the shared `DanceMatch`/`DanceRelation`/`SetRhythm`/`TimeSignature` types |
|
|
45
45
|
| `@finbheara/domain/promotion` | `samePromotedRow`, `samePromotedSchool`, `samePromotedHeir`, `samePromotedName`, `questionMarksRead`, `foldCharSynonyms`: is a row the same row after a promotion (below) |
|
|
46
|
-
| `@finbheara/domain/person` | `seatName`, `dancerName`, `teacherName`, `roleName`, `roleSentinelOf`, the role lists and `SHARED_ROW_SENTINELS`: a person's print read in its role (below) |
|
|
46
|
+
| `@finbheara/domain/person` | `seatName`, `dancerName`, `teacherName`, `roleName`, `roleSentinelOf`, `rolePrintsNoName`, `dancerPrintsNoName`, the role lists and `SHARED_ROW_SENTINELS`: a person's print read in its role (below) |
|
|
47
47
|
|
|
48
48
|
The library does no I/O and installs nothing process-wide. Every reader has a default and a
|
|
49
49
|
factory: build your own with options when the default is not what you want.
|
|
@@ -482,6 +482,9 @@ seatName("Aoife Mhaolvarna").nn2; // "Mhaolvarna<<Aoife": nam
|
|
|
482
482
|
and the school cell's (`SCHOOL_CELL_SENTINELS` on `/school`, asked by the school reader before
|
|
483
483
|
its own register), so a sentinel a whole row prints has one definition.
|
|
484
484
|
- Each row is the folded print (`foldNameKey`), what it stands for, and where it was seen.
|
|
485
|
+
- **The print alone** has the same answer: `rolePrintsNoName(role, print)` (and
|
|
486
|
+
`dancerPrintsNoName(print)`) is `roleName(role, print).printsNoName()` without the parse, for
|
|
487
|
+
a walk that parses no name. Names' `isNoNamePrint` alone misses a role's own sentinel.
|
|
485
488
|
|
|
486
489
|
## Known gaps
|
|
487
490
|
|
|
@@ -205,6 +205,8 @@ var PLACE_NODES = [
|
|
|
205
205
|
"mid america region",
|
|
206
206
|
"mid america region usa",
|
|
207
207
|
"mid american region",
|
|
208
|
+
"middle america",
|
|
209
|
+
"middle america us",
|
|
208
210
|
"reigiun lar meiricea",
|
|
209
211
|
"usa mid america region"
|
|
210
212
|
],
|
|
@@ -234,7 +236,13 @@ var PLACE_NODES = [
|
|
|
234
236
|
name: "New England Region USA",
|
|
235
237
|
geo: "USA",
|
|
236
238
|
admin: "IDTANA",
|
|
237
|
-
prints: [
|
|
239
|
+
prints: [
|
|
240
|
+
"new england",
|
|
241
|
+
"new england region",
|
|
242
|
+
"new england region usa",
|
|
243
|
+
"new england us",
|
|
244
|
+
"reigiun sasana nua"
|
|
245
|
+
],
|
|
238
246
|
codes: ["NERO"],
|
|
239
247
|
oireachtas: "NERO"
|
|
240
248
|
},
|
|
@@ -251,6 +259,7 @@ var PLACE_NODES = [
|
|
|
251
259
|
"so usa",
|
|
252
260
|
"southern region",
|
|
253
261
|
"southern region usa",
|
|
262
|
+
"southern us",
|
|
254
263
|
"southern usa",
|
|
255
264
|
"usa southern region"
|
|
256
265
|
],
|
|
@@ -3965,7 +3974,7 @@ var PLACE_NODES = [
|
|
|
3965
3974
|
name: "District of Columbia",
|
|
3966
3975
|
geo: "USA",
|
|
3967
3976
|
admin: "IDTANA-SRO",
|
|
3968
|
-
prints: ["district of columbia"],
|
|
3977
|
+
prints: ["d c", "district of columbia", "washington d c", "washington dc"],
|
|
3969
3978
|
codes: ["DC", "DC-USA", "US-DC", "USA-DC"]
|
|
3970
3979
|
},
|
|
3971
3980
|
{
|
|
@@ -6478,6 +6487,15 @@ var PLACE_NODES = [
|
|
|
6478
6487
|
prints: ["salt lake city"],
|
|
6479
6488
|
codes: []
|
|
6480
6489
|
},
|
|
6490
|
+
{
|
|
6491
|
+
id: "USA-VA/dulles",
|
|
6492
|
+
kind: "city",
|
|
6493
|
+
name: "Dulles",
|
|
6494
|
+
geo: "USA-VA",
|
|
6495
|
+
admin: "IDTANA-SRO",
|
|
6496
|
+
prints: ["dulles", "washington dulles"],
|
|
6497
|
+
codes: []
|
|
6498
|
+
},
|
|
6481
6499
|
{
|
|
6482
6500
|
id: "USA-VA/leesburg",
|
|
6483
6501
|
kind: "city",
|
|
@@ -7847,10 +7865,89 @@ function createPlaceReader2(options = {}) {
|
|
|
7847
7865
|
return made;
|
|
7848
7866
|
}
|
|
7849
7867
|
function placeFromId(id) {
|
|
7850
|
-
const
|
|
7851
|
-
if (
|
|
7868
|
+
const key = id.trim();
|
|
7869
|
+
if (key.includes("+"))
|
|
7870
|
+
return pluralFromId(id, key);
|
|
7871
|
+
const n = idx().byId.get(key);
|
|
7872
|
+
if (n !== undefined)
|
|
7873
|
+
return build(id, [chainOf(n)], { heads: [n], match: "id", truncated: false, refusal: null }, []);
|
|
7874
|
+
for (let at = key.lastIndexOf("/");at > 0; at = key.lastIndexOf("/", at - 1)) {
|
|
7875
|
+
const above = idx().byId.get(key.slice(0, at));
|
|
7876
|
+
if (above !== undefined)
|
|
7877
|
+
return build(id, [chainOf(above)], { heads: [above], match: "id", truncated: true, refusal: null }, []);
|
|
7878
|
+
}
|
|
7879
|
+
return build(id, [], NOTHING, []);
|
|
7880
|
+
}
|
|
7881
|
+
function pluralFromId(id, key) {
|
|
7882
|
+
const members = [];
|
|
7883
|
+
for (const part of key.split("+")) {
|
|
7884
|
+
const n = idx().byId.get(part);
|
|
7885
|
+
if (n === undefined || members.some((m) => m.id === n.id))
|
|
7886
|
+
return build(id, [], NOTHING, []);
|
|
7887
|
+
members.push(n);
|
|
7888
|
+
}
|
|
7889
|
+
if (members.length < 2)
|
|
7852
7890
|
return build(id, [], NOTHING, []);
|
|
7853
|
-
|
|
7891
|
+
for (let a = 0;a < members.length; a++)
|
|
7892
|
+
for (let b = a + 1;b < members.length; b++)
|
|
7893
|
+
if (!twoPlaces(members[a], members[b]))
|
|
7894
|
+
return build(id, [], NOTHING, []);
|
|
7895
|
+
members.sort((x, y) => x.id.localeCompare(y.id));
|
|
7896
|
+
return build(id, chainsFor(members), {
|
|
7897
|
+
heads: members,
|
|
7898
|
+
match: "id",
|
|
7899
|
+
truncated: false,
|
|
7900
|
+
refusal: null,
|
|
7901
|
+
members
|
|
7902
|
+
}, []);
|
|
7903
|
+
}
|
|
7904
|
+
const MAX_WINDOW = 6;
|
|
7905
|
+
function segmentsOf(text) {
|
|
7906
|
+
return text.split(/[;:()[\]{}|]+/).map((seg) => seg.split(/[\s,\u2013\u2014]+|\s-\s|-(?=\p{Lu})/u).filter((t) => t !== "" && t !== "-")).filter((seg) => seg.length > 0);
|
|
7907
|
+
}
|
|
7908
|
+
function placeWindows(text, ctx) {
|
|
7909
|
+
const found = [];
|
|
7910
|
+
for (const tokens of segmentsOf(text)) {
|
|
7911
|
+
const taken = new Array(tokens.length).fill(false);
|
|
7912
|
+
const here = [];
|
|
7913
|
+
for (let w = Math.min(MAX_WINDOW, tokens.length);w >= 1; w--)
|
|
7914
|
+
for (let i = 0;i + w <= tokens.length; i++) {
|
|
7915
|
+
if (taken.slice(i, i + w).some((x) => x))
|
|
7916
|
+
continue;
|
|
7917
|
+
const span = tokens.slice(i, i + w);
|
|
7918
|
+
const p = place(span.join(" "), ctx);
|
|
7919
|
+
if (!p.isPlace() || p.truncated)
|
|
7920
|
+
continue;
|
|
7921
|
+
for (let k = i;k < i + w; k++)
|
|
7922
|
+
taken[k] = true;
|
|
7923
|
+
here.push({ at: i, r: { p, tokens: span } });
|
|
7924
|
+
}
|
|
7925
|
+
here.sort((a, b) => a.at - b.at);
|
|
7926
|
+
for (const [k, h] of here.entries()) {
|
|
7927
|
+
const n = here[k + 1];
|
|
7928
|
+
if (n !== undefined && n.at === h.at + h.r.tokens.length)
|
|
7929
|
+
h.r.next = n.r;
|
|
7930
|
+
}
|
|
7931
|
+
found.push(...here.map((f) => f.r));
|
|
7932
|
+
}
|
|
7933
|
+
return found;
|
|
7934
|
+
}
|
|
7935
|
+
function placeParts(print) {
|
|
7936
|
+
const core = unbracket(repair(print));
|
|
7937
|
+
const { tokens, seps } = cut(core);
|
|
7938
|
+
const pieces = [];
|
|
7939
|
+
let run = tokens[0] ?? "";
|
|
7940
|
+
for (let i = 0;i < seps.length; i++) {
|
|
7941
|
+
const next = tokens[i + 1] ?? "";
|
|
7942
|
+
if (seps[i] === "space")
|
|
7943
|
+
run = `${run} ${next}`;
|
|
7944
|
+
else {
|
|
7945
|
+
pieces.push(run);
|
|
7946
|
+
run = next;
|
|
7947
|
+
}
|
|
7948
|
+
}
|
|
7949
|
+
pieces.push(run);
|
|
7950
|
+
return pieces.filter((p) => p.trim() !== "").map((p) => place(p));
|
|
7854
7951
|
}
|
|
7855
7952
|
function oireachtasOfRegion(regionId) {
|
|
7856
7953
|
if (regionId === undefined)
|
|
@@ -7945,6 +8042,8 @@ function createPlaceReader2(options = {}) {
|
|
|
7945
8042
|
countryCodeOf,
|
|
7946
8043
|
areAllPlaceTokens,
|
|
7947
8044
|
placeFromId,
|
|
8045
|
+
placeParts,
|
|
8046
|
+
placeWindows,
|
|
7948
8047
|
oireachtasOfRegion,
|
|
7949
8048
|
regionOfOireachtas,
|
|
7950
8049
|
placeStats,
|
|
@@ -7971,6 +8070,12 @@ function areAllPlaceTokens2(tokens, off = 0, declared = false) {
|
|
|
7971
8070
|
function placeFromId2(id) {
|
|
7972
8071
|
return DEFAULT_PLACE_READER2.placeFromId(id);
|
|
7973
8072
|
}
|
|
8073
|
+
function placeWindows2(text, ctx) {
|
|
8074
|
+
return DEFAULT_PLACE_READER2.placeWindows(text, ctx);
|
|
8075
|
+
}
|
|
8076
|
+
function placeParts2(print) {
|
|
8077
|
+
return DEFAULT_PLACE_READER2.placeParts(print);
|
|
8078
|
+
}
|
|
7974
8079
|
function oireachtasOfRegion2(regionId) {
|
|
7975
8080
|
return DEFAULT_PLACE_READER2.oireachtasOfRegion(regionId);
|
|
7976
8081
|
}
|
|
@@ -7996,4 +8101,4 @@ function sameReading2(a, b) {
|
|
|
7996
8101
|
return DEFAULT_PLACE_READER2.sameReading(a, b);
|
|
7997
8102
|
}
|
|
7998
8103
|
|
|
7999
|
-
export { NEVER_NAME, printZones, opensLocation, DEFAULT_PLACE_CAPACITY2, createPlaceReader2, DEFAULT_PLACE_READER2, place2, isPlaceToken2, countryCodeOf2, areAllPlaceTokens2, placeFromId2, oireachtasOfRegion2, regionOfOireachtas2, placeStats2, resetPlaceCache2, placeRelation2, placesRelation2, probablySamePlace2, sameReading2 };
|
|
8104
|
+
export { NEVER_NAME, printZones, opensLocation, DEFAULT_PLACE_CAPACITY2, createPlaceReader2, DEFAULT_PLACE_READER2, place2, isPlaceToken2, countryCodeOf2, areAllPlaceTokens2, placeFromId2, placeWindows2, placeParts2, oireachtasOfRegion2, regionOfOireachtas2, placeStats2, resetPlaceCache2, placeRelation2, placesRelation2, probablySamePlace2, sameReading2 };
|
package/dist/person.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
NAME_REFUSED,
|
|
8
|
+
isNoNamePrint,
|
|
8
9
|
personName
|
|
9
10
|
} from "@finbheara/names/normalize";
|
|
10
11
|
var ADJUDICATOR_SENTINELS = [
|
|
@@ -110,6 +111,10 @@ function roleName(role, print, order) {
|
|
|
110
111
|
const sentinel = MATCHERS[role](print);
|
|
111
112
|
return sentinel === undefined ? read : new RoleRefusedName(read, role, sentinel);
|
|
112
113
|
}
|
|
114
|
+
function rolePrintsNoName(role, print) {
|
|
115
|
+
return MATCHERS[role](print) !== undefined || isNoNamePrint(print);
|
|
116
|
+
}
|
|
117
|
+
var dancerPrintsNoName = (print) => rolePrintsNoName("dancer", print);
|
|
113
118
|
var seatName = (print) => roleName("adjudicator", print, "given-first");
|
|
114
119
|
var dancerName = (print, order) => roleName("dancer", print, order);
|
|
115
120
|
var teacherName = (print, order) => roleName("teacher", print, order);
|
|
@@ -120,7 +125,9 @@ export {
|
|
|
120
125
|
SHARED_ROW_SENTINELS2 as SHARED_ROW_SENTINELS,
|
|
121
126
|
TEACHER_SENTINELS,
|
|
122
127
|
dancerName,
|
|
128
|
+
dancerPrintsNoName,
|
|
123
129
|
roleName,
|
|
130
|
+
rolePrintsNoName,
|
|
124
131
|
roleSentinelOf,
|
|
125
132
|
seatName,
|
|
126
133
|
sentinelIn2 as sentinelIn,
|
package/dist/place.js
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
countryCodeOf2,
|
|
8
8
|
areAllPlaceTokens2,
|
|
9
9
|
placeFromId2,
|
|
10
|
+
placeWindows2,
|
|
11
|
+
placeParts2,
|
|
10
12
|
oireachtasOfRegion2,
|
|
11
13
|
regionOfOireachtas2,
|
|
12
14
|
placeStats2,
|
|
@@ -15,7 +17,7 @@ import {
|
|
|
15
17
|
placesRelation2,
|
|
16
18
|
probablySamePlace2,
|
|
17
19
|
sameReading2
|
|
18
|
-
} from "./chunks/place-
|
|
20
|
+
} from "./chunks/place-jksxqsqb.js";
|
|
19
21
|
export {
|
|
20
22
|
DEFAULT_PLACE_CAPACITY2 as DEFAULT_PLACE_CAPACITY,
|
|
21
23
|
DEFAULT_PLACE_READER2 as DEFAULT_PLACE_READER,
|
|
@@ -26,8 +28,10 @@ export {
|
|
|
26
28
|
oireachtasOfRegion2 as oireachtasOfRegion,
|
|
27
29
|
place2 as place,
|
|
28
30
|
placeFromId2 as placeFromId,
|
|
31
|
+
placeParts2 as placeParts,
|
|
29
32
|
placeRelation2 as placeRelation,
|
|
30
33
|
placeStats2 as placeStats,
|
|
34
|
+
placeWindows2 as placeWindows,
|
|
31
35
|
placesRelation2 as placesRelation,
|
|
32
36
|
probablySamePlace2 as probablySamePlace,
|
|
33
37
|
regionOfOireachtas2 as regionOfOireachtas,
|
package/dist/school.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
areAllPlaceTokens2,
|
|
9
9
|
placeRelation2,
|
|
10
10
|
sameReading2
|
|
11
|
-
} from "./chunks/place-
|
|
11
|
+
} from "./chunks/place-jksxqsqb.js";
|
|
12
12
|
import {
|
|
13
13
|
SHARED_ROW_SENTINELS2,
|
|
14
14
|
sentinelIn2
|
|
@@ -35,7 +35,46 @@ var SCHOOL_CELL_OWN_SENTINELS = [
|
|
|
35
35
|
{
|
|
36
36
|
print: "independent dancer",
|
|
37
37
|
authority: "`Independent Dancer`, `Independent dancer`, `Independent Dancer?`: 8 school cells"
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
print: "non dancing",
|
|
41
|
+
authority: "`Non-dancing`: 107 school cells, an entry form's option for a non-dancer"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
print: "school not selected",
|
|
45
|
+
match: "prefix",
|
|
46
|
+
authority: "`SCHOOL NOT SELECTED - update your ... profile`: 45 school cells, an entry form's instruction"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
print: "choose one",
|
|
50
|
+
authority: "`-- Choose One --`: 41 school cells, an entry form's unchosen option"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
print: "no school selected",
|
|
54
|
+
match: "prefix",
|
|
55
|
+
authority: "`NO SCHOOL SELECTED - Please change your profile`: 16 school cells, an entry form's instruction"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
print: "no school associations",
|
|
59
|
+
authority: "`No School Associations`: 13 school cells"
|
|
60
|
+
},
|
|
61
|
+
{ print: "no lessons yet", authority: "`No lessons yet`: 5 school cells" },
|
|
62
|
+
{ print: "non dancer", authority: "`Non-dancer`: 4 school cells" },
|
|
63
|
+
{ print: "non dance competitions", authority: "`Non-Dance Competitions`: 3 school cells" },
|
|
64
|
+
{
|
|
65
|
+
print: "not listed",
|
|
66
|
+
match: "prefix",
|
|
67
|
+
authority: "`--Not Listed--`: 2 school cells, an entry form's option"
|
|
68
|
+
},
|
|
69
|
+
{ print: "other", authority: "`Other`: 2 school cells, an entry form's option" },
|
|
70
|
+
{ print: "not certified", authority: "`Not Certified`: 1 school cell" },
|
|
71
|
+
{ print: "n e e d", authority: "`(n e e d ) ____`: 1 school cell, keyboard filler" },
|
|
72
|
+
{ print: "none", authority: "`None`: 1 school cell" },
|
|
73
|
+
{
|
|
74
|
+
print: "unknown irish dancing school",
|
|
75
|
+
authority: "`Unknown Irish Dancing School`: 1 school cell"
|
|
76
|
+
},
|
|
77
|
+
{ print: "none inactive dancer", authority: "`None - Inactive Dancer`: 1 school cell" }
|
|
39
78
|
];
|
|
40
79
|
var SCHOOL_CELL_SENTINELS = [
|
|
41
80
|
...SHARED_ROW_SENTINELS2,
|
package/dist/types/person.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export declare const TEACHER_SENTINELS: readonly RowSentinel[];
|
|
|
9
9
|
export declare const ROLE_SENTINELS: Readonly<Record<PersonRole, readonly RowSentinel[]>>;
|
|
10
10
|
export declare function roleSentinelOf(role: PersonRole, print: string): RowSentinel | undefined;
|
|
11
11
|
export declare function roleName(role: PersonRole, print: string, order?: ParseOrder): PersonName;
|
|
12
|
+
export declare function rolePrintsNoName(role: PersonRole, print: string): boolean;
|
|
13
|
+
export declare const dancerPrintsNoName: (print: string) => boolean;
|
|
12
14
|
export declare const seatName: (print: string) => PersonName;
|
|
13
15
|
export declare const dancerName: (print: string, order?: ParseOrder) => PersonName;
|
|
14
16
|
export declare const teacherName: (print: string, order?: ParseOrder) => PersonName;
|
package/dist/types/place.d.ts
CHANGED
|
@@ -51,6 +51,11 @@ export interface UnreadPlace extends AbstractPlace {
|
|
|
51
51
|
readonly arm: "unread";
|
|
52
52
|
}
|
|
53
53
|
export type Place = ResolvedPlace | PluralPlaces | AmbiguousPlace | UnreadPlace;
|
|
54
|
+
export interface PlaceWindow {
|
|
55
|
+
readonly p: Place;
|
|
56
|
+
readonly tokens: readonly string[];
|
|
57
|
+
next?: PlaceWindow;
|
|
58
|
+
}
|
|
54
59
|
export type PlaceRefusals = (print: string) => PlaceRefusal | undefined;
|
|
55
60
|
export interface PlaceReaderOptions {
|
|
56
61
|
readonly tree?: readonly PlaceNode[];
|
|
@@ -64,6 +69,8 @@ export declare function createPlaceReader(options?: PlaceReaderOptions): {
|
|
|
64
69
|
countryCodeOf: (token: string) => string | undefined;
|
|
65
70
|
areAllPlaceTokens: (tokens: readonly string[], off?: number, declared?: boolean) => boolean;
|
|
66
71
|
placeFromId: (id: string) => Place;
|
|
72
|
+
placeParts: (print: string) => Place[];
|
|
73
|
+
placeWindows: (text: string, ctx?: string | PlaceContext) => PlaceWindow[];
|
|
67
74
|
oireachtasOfRegion: (regionId: string | undefined) => string | undefined;
|
|
68
75
|
regionOfOireachtas: (code: string) => Place;
|
|
69
76
|
placeStats: () => {
|
|
@@ -84,6 +91,8 @@ export declare function isPlaceToken(token: string, cut?: boolean, declared?: bo
|
|
|
84
91
|
export declare function countryCodeOf(token: string): string | undefined;
|
|
85
92
|
export declare function areAllPlaceTokens(tokens: readonly string[], off?: number, declared?: boolean): boolean;
|
|
86
93
|
export declare function placeFromId(id: string): Place;
|
|
94
|
+
export declare function placeWindows(text: string, ctx?: string | PlaceContext): PlaceWindow[];
|
|
95
|
+
export declare function placeParts(print: string): Place[];
|
|
87
96
|
export declare function oireachtasOfRegion(regionId: string | undefined): string | undefined;
|
|
88
97
|
export declare function regionOfOireachtas(code: string): Place;
|
|
89
98
|
export declare function placeStats(): {
|
package/package.json
CHANGED