@finbheara/domain 0.60.0 → 0.62.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.
@@ -0,0 +1,1105 @@
1
+ import {
2
+ SHARED_ROW_SENTINELS2,
3
+ sentinelIn2
4
+ } from "./place-tcgfvemw.js";
5
+
6
+ var SCHOOL_CELL_OWN_SENTINELS2 = [
7
+ {
8
+ print: "no school",
9
+ authority: "`No School`: 76 school cells, the dancer entered with no school"
10
+ },
11
+ {
12
+ print: "independent",
13
+ authority: "`Independent`, `independent`, `Independent?`: 5 school cells, no school by the dancer's own description"
14
+ },
15
+ {
16
+ print: "independent dancer",
17
+ authority: "`Independent Dancer`, `Independent dancer`, `Independent Dancer?`: 8 school cells"
18
+ },
19
+ {
20
+ print: "non dancing",
21
+ authority: "`Non-dancing`: 107 school cells, an entry form's option for a non-dancer"
22
+ },
23
+ {
24
+ print: "school not selected",
25
+ match: "prefix",
26
+ authority: "`SCHOOL NOT SELECTED - update your ... profile`: 45 school cells, an entry form's instruction"
27
+ },
28
+ {
29
+ print: "choose one",
30
+ authority: "`-- Choose One --`: 41 school cells, an entry form's unchosen option"
31
+ },
32
+ {
33
+ print: "no school selected",
34
+ match: "prefix",
35
+ authority: "`NO SCHOOL SELECTED - Please change your profile`: 16 school cells, an entry form's instruction"
36
+ },
37
+ {
38
+ print: "no school associations",
39
+ authority: "`No School Associations`: 13 school cells"
40
+ },
41
+ { print: "no lessons yet", authority: "`No lessons yet`: 5 school cells" },
42
+ { print: "non dancer", authority: "`Non-dancer`: 4 school cells" },
43
+ { print: "non dance competitions", authority: "`Non-Dance Competitions`: 3 school cells" },
44
+ {
45
+ print: "not listed",
46
+ match: "prefix",
47
+ authority: "`--Not Listed--`: 2 school cells, an entry form's option"
48
+ },
49
+ { print: "other", authority: "`Other`: 2 school cells, an entry form's option" },
50
+ { print: "not certified", authority: "`Not Certified`: 1 school cell" },
51
+ { print: "n e e d", authority: "`(n e e d ) ____`: 1 school cell, keyboard filler" },
52
+ { print: "none", authority: "`None`: 1 school cell" },
53
+ {
54
+ print: "unknown irish dancing school",
55
+ authority: "`Unknown Irish Dancing School`: 1 school cell"
56
+ },
57
+ { print: "none inactive dancer", authority: "`None - Inactive Dancer`: 1 school cell" },
58
+ {
59
+ print: "school hidden",
60
+ authority: "`(School Hidden)`: 1,221 school cells of 8 registrant lists, the entry platform's print for a competitor who asked not to be published"
61
+ },
62
+ { print: "not applicable", authority: "`Not applicable`: a school print, no school entered" },
63
+ {
64
+ print: "no school judge",
65
+ authority: "`No School - Judge`: an entry form's option for an adjudicator"
66
+ },
67
+ { print: "no dance school", authority: "`No Dance School`: an entry form's option" },
68
+ { print: "unknown music school", authority: "`Unknown Music School`: an entry form's option" },
69
+ { print: "school deleted", authority: "`---SCHOOL DELETED`: an entry form's option" },
70
+ { print: "select school", authority: "`--Select School--`: an entry form's unchosen option" },
71
+ { print: "school other", authority: "`School Other`: an entry form's option" },
72
+ { print: "non", authority: "`Non`: an entry form's option, the truncation of `Non-dancer`" },
73
+ {
74
+ print: "x closed select new school",
75
+ authority: "`X - CLOSED - Select New School`: an entry form's option for a closed school"
76
+ },
77
+ {
78
+ print: "x school closed please select another school",
79
+ authority: "`X -SCHOOL CLOSED - Please select another school`: an entry form's option"
80
+ },
81
+ { print: "default school", authority: "`Default School`: an entry form's default" },
82
+ {
83
+ print: "my school of irish dance",
84
+ authority: "`My School of Irish Dance`: an entry form's example text"
85
+ }
86
+ ];
87
+ var SCHOOL_CELL_SENTINELS2 = [
88
+ ...SHARED_ROW_SENTINELS2,
89
+ ...SCHOOL_CELL_OWN_SENTINELS2
90
+ ];
91
+ var schoolCellSentinelOf2 = sentinelIn2(SCHOOL_CELL_SENTINELS2);
92
+
93
+ var SCHOOL_NAME_EXCEPTIONS2 = [
94
+ {
95
+ phrase: "the academy",
96
+ scope: "label",
97
+ as: "NAME_PART",
98
+ token: "theacademy"
99
+ },
100
+ {
101
+ phrase: "the academy irish dance co",
102
+ scope: "label",
103
+ as: "NAME_PART",
104
+ token: "theacademy"
105
+ },
106
+ {
107
+ phrase: "rhythm of ireland",
108
+ scope: "phrase",
109
+ as: "NAME_PART",
110
+ token: "rhythmofireland"
111
+ },
112
+ {
113
+ phrase: "irish dance center",
114
+ scope: "label",
115
+ as: "NAME_PART",
116
+ token: "irishdancecenter"
117
+ },
118
+ {
119
+ phrase: "the irish dance center",
120
+ scope: "label",
121
+ as: "NAME_PART",
122
+ token: "irishdancecenter"
123
+ },
124
+ {
125
+ phrase: "the irish dance academy",
126
+ scope: "label",
127
+ as: "NAME_PART",
128
+ token: "theirishdanceacademy"
129
+ },
130
+ {
131
+ phrase: "irish dance academy",
132
+ scope: "label",
133
+ as: "NAME_PART",
134
+ token: "theirishdanceacademy"
135
+ },
136
+ {
137
+ phrase: "the irish dance company",
138
+ scope: "label",
139
+ as: "NAME_PART",
140
+ token: "theirishdancecompany"
141
+ },
142
+ {
143
+ phrase: "gra na rince",
144
+ scope: "phrase",
145
+ as: "NAME_PART",
146
+ token: "granarince"
147
+ },
148
+ {
149
+ phrase: "clann na cara",
150
+ scope: "phrase",
151
+ as: "NAME_PART",
152
+ token: "clannnacara"
153
+ },
154
+ {
155
+ phrase: "rince academy",
156
+ scope: "label",
157
+ as: "NAME_PART",
158
+ token: "rinceacademy"
159
+ },
160
+ {
161
+ phrase: "i d a s",
162
+ scope: "label",
163
+ as: "NAME_PART",
164
+ token: "idas"
165
+ },
166
+ {
167
+ phrase: "ml dance academy",
168
+ scope: "phrase",
169
+ as: "NAME_PART",
170
+ token: "mldanceacademy"
171
+ },
172
+ {
173
+ phrase: "cm dance",
174
+ scope: "label",
175
+ as: "NAME_PART",
176
+ token: "cmdance"
177
+ },
178
+ {
179
+ phrase: "traditional irish dance academy",
180
+ scope: "label",
181
+ as: "NAME_PART",
182
+ token: "traditionalirishdanceacademy"
183
+ },
184
+ {
185
+ phrase: "irish dance centre",
186
+ scope: "label",
187
+ as: "NAME_PART",
188
+ token: "irishdancecenter"
189
+ },
190
+ {
191
+ phrase: "tj academy",
192
+ scope: "phrase",
193
+ as: "NAME_PART",
194
+ token: "tjacademy"
195
+ },
196
+ {
197
+ phrase: "m d l academy",
198
+ scope: "label",
199
+ as: "NAME_PART",
200
+ token: "mdlacademy"
201
+ },
202
+ {
203
+ phrase: "wa academy",
204
+ scope: "phrase",
205
+ as: "NAME_PART",
206
+ token: "waacademy"
207
+ },
208
+ {
209
+ phrase: "fd academy",
210
+ scope: "phrase",
211
+ as: "NAME_PART",
212
+ token: "fdacademy"
213
+ },
214
+ {
215
+ phrase: "em academy",
216
+ scope: "label",
217
+ as: "NAME_PART",
218
+ token: "emacademy"
219
+ },
220
+ {
221
+ phrase: "aoibhneas an rince",
222
+ scope: "phrase",
223
+ as: "NAME_PART",
224
+ token: "aoibhneasanrince"
225
+ },
226
+ {
227
+ phrase: "an rince mor",
228
+ scope: "phrase",
229
+ as: "NAME_PART",
230
+ token: "anrincemor"
231
+ },
232
+ {
233
+ phrase: "clan rince",
234
+ scope: "phrase",
235
+ as: "NAME_PART",
236
+ token: "clanrince"
237
+ },
238
+ {
239
+ phrase: "acadamh rince",
240
+ scope: "phrase",
241
+ as: "NAME_PART",
242
+ token: "acadamhrince"
243
+ },
244
+ {
245
+ phrase: "spreagadh na rince",
246
+ scope: "phrase",
247
+ as: "NAME_PART",
248
+ token: "spreagadhnarince"
249
+ },
250
+ {
251
+ phrase: "clann na rince",
252
+ scope: "label",
253
+ as: "NAME_PART",
254
+ token: "clannnarince"
255
+ },
256
+ {
257
+ phrase: "mise eire",
258
+ scope: "phrase",
259
+ as: "NAME_PART",
260
+ token: "miseeire"
261
+ },
262
+ {
263
+ phrase: "reel eire",
264
+ scope: "phrase",
265
+ as: "NAME_PART",
266
+ token: "reeleire"
267
+ }
268
+ ];
269
+ var EXCEPTIONS_BY_LENGTH = [
270
+ ...SCHOOL_NAME_EXCEPTIONS2
271
+ ].sort((a, b) => b.phrase.length - a.phrase.length);
272
+ var NOT_A_SCHOOL2 = [
273
+ {
274
+ pattern: "north west regional council",
275
+ kind: "exact",
276
+ reason: "organization"
277
+ },
278
+ {
279
+ pattern: "^#\\s*\\d+$",
280
+ kind: "regex",
281
+ reason: "placeholder"
282
+ },
283
+ {
284
+ pattern: "cce other",
285
+ kind: "exact",
286
+ reason: "placeholder"
287
+ },
288
+ {
289
+ pattern: "^x{4,}$",
290
+ kind: "regex",
291
+ reason: "placeholder"
292
+ },
293
+ {
294
+ pattern: "^.+['’]s team$",
295
+ kind: "regex",
296
+ reason: "not-a-name"
297
+ },
298
+ {
299
+ pattern: "^\\d+(st|nd|rd|th) team up$",
300
+ kind: "regex",
301
+ reason: "not-a-name"
302
+ },
303
+ {
304
+ pattern: "^[abc] team$",
305
+ kind: "regex",
306
+ reason: "not-a-name"
307
+ },
308
+ {
309
+ pattern: "^[^\\p{L}]*$",
310
+ kind: "regex",
311
+ reason: "not-a-name"
312
+ }
313
+ ];
314
+ var INVISIBLE = /[​‌‍ ]/g;
315
+ var COMBINING = /[̀-ͯ]/g;
316
+ function normalizeForRefusal(print) {
317
+ return print.replace(INVISIBLE, " ").normalize("NFD").replace(COMBINING, "").toLowerCase().replace(/\s+/g, " ").trim();
318
+ }
319
+ var PLACEHOLDER_ROWS = new Map;
320
+ function placeholderRow(p) {
321
+ let row = PLACEHOLDER_ROWS.get(p);
322
+ if (row === undefined)
323
+ PLACEHOLDER_ROWS.set(p, row = { pattern: p.print, kind: p.match ?? "exact", reason: "placeholder" });
324
+ return row;
325
+ }
326
+ function notASchoolIn2(rows) {
327
+ const regexes = new Map(rows.filter((row) => row.kind === "regex").map((row) => [row, new RegExp(row.pattern, "iu")]));
328
+ return (print) => {
329
+ const text = normalizeForRefusal(print);
330
+ if (text === "")
331
+ return;
332
+ const placeholder = schoolCellSentinelOf2(text);
333
+ if (placeholder !== undefined)
334
+ return placeholderRow(placeholder);
335
+ for (const row of rows) {
336
+ if (row.kind === "exact" && text === row.pattern)
337
+ return row;
338
+ if (row.kind === "prefix" && text.startsWith(row.pattern))
339
+ return row;
340
+ if (row.kind === "regex" && regexes.get(row)?.test(text))
341
+ return row;
342
+ }
343
+ return;
344
+ };
345
+ }
346
+ function exceptionsByLength(rows) {
347
+ return [...rows].sort((a, b) => b.phrase.length - a.phrase.length);
348
+ }
349
+
350
+ var SCHOOL_FLUFF_VOCABULARY = new Map([
351
+ [
352
+ "irish",
353
+ {
354
+ canonical: "irish",
355
+ kind: "word",
356
+ lowerInside: false,
357
+ descriptor: true,
358
+ truncatable: true,
359
+ tokenFluff: true
360
+ }
361
+ ],
362
+ [
363
+ "dance",
364
+ {
365
+ canonical: "dance",
366
+ kind: "word",
367
+ lowerInside: false,
368
+ descriptor: true,
369
+ truncatable: true,
370
+ tokenFluff: true
371
+ }
372
+ ],
373
+ [
374
+ "dancing",
375
+ {
376
+ canonical: "dancing",
377
+ kind: "word",
378
+ lowerInside: false,
379
+ descriptor: true,
380
+ truncatable: true,
381
+ tokenFluff: true
382
+ }
383
+ ],
384
+ [
385
+ "dancers",
386
+ {
387
+ canonical: "dancers",
388
+ kind: "word",
389
+ lowerInside: false,
390
+ descriptor: true,
391
+ truncatable: true,
392
+ tokenFluff: true
393
+ }
394
+ ],
395
+ [
396
+ "traditional",
397
+ {
398
+ canonical: "traditional",
399
+ kind: "word",
400
+ lowerInside: false,
401
+ descriptor: true,
402
+ truncatable: true,
403
+ tokenFluff: true
404
+ }
405
+ ],
406
+ [
407
+ "the",
408
+ {
409
+ canonical: "the",
410
+ kind: "word",
411
+ lowerInside: true,
412
+ descriptor: true,
413
+ truncatable: false,
414
+ tokenFluff: true
415
+ }
416
+ ],
417
+ [
418
+ "of",
419
+ {
420
+ canonical: "of",
421
+ kind: "word",
422
+ lowerInside: true,
423
+ descriptor: true,
424
+ truncatable: false,
425
+ tokenFluff: true
426
+ }
427
+ ],
428
+ [
429
+ "and",
430
+ {
431
+ canonical: "and",
432
+ kind: "word",
433
+ lowerInside: true,
434
+ descriptor: true,
435
+ truncatable: false,
436
+ tokenFluff: true
437
+ }
438
+ ],
439
+ [
440
+ "na",
441
+ {
442
+ canonical: "na",
443
+ kind: "word",
444
+ lowerInside: true,
445
+ descriptor: false,
446
+ truncatable: false,
447
+ tokenFluff: true
448
+ }
449
+ ],
450
+ [
451
+ "an",
452
+ {
453
+ canonical: "an",
454
+ kind: "word",
455
+ lowerInside: true,
456
+ descriptor: false,
457
+ truncatable: false,
458
+ tokenFluff: true
459
+ }
460
+ ],
461
+ [
462
+ "a",
463
+ {
464
+ canonical: "a",
465
+ kind: "word",
466
+ lowerInside: true,
467
+ descriptor: false,
468
+ truncatable: false,
469
+ tokenFluff: false
470
+ }
471
+ ],
472
+ [
473
+ "do",
474
+ {
475
+ canonical: "do",
476
+ kind: "word",
477
+ lowerInside: true,
478
+ descriptor: false,
479
+ truncatable: false,
480
+ tokenFluff: false
481
+ }
482
+ ],
483
+ [
484
+ "irish dance",
485
+ {
486
+ canonical: "irish dance",
487
+ kind: "phrase",
488
+ lowerInside: false,
489
+ descriptor: true,
490
+ truncatable: true,
491
+ tokenFluff: false
492
+ }
493
+ ],
494
+ [
495
+ "irish dancing",
496
+ {
497
+ canonical: "irish dancing",
498
+ kind: "phrase",
499
+ lowerInside: false,
500
+ descriptor: true,
501
+ truncatable: true,
502
+ tokenFluff: false
503
+ }
504
+ ],
505
+ [
506
+ "of irish dance",
507
+ {
508
+ canonical: "of irish dance",
509
+ kind: "phrase",
510
+ lowerInside: false,
511
+ descriptor: true,
512
+ truncatable: true,
513
+ tokenFluff: false
514
+ }
515
+ ],
516
+ [
517
+ "of irish dancing",
518
+ {
519
+ canonical: "of irish dancing",
520
+ kind: "phrase",
521
+ lowerInside: false,
522
+ descriptor: true,
523
+ truncatable: true,
524
+ tokenFluff: false
525
+ }
526
+ ],
527
+ [
528
+ "school of irish dance",
529
+ {
530
+ canonical: "school of irish dance",
531
+ kind: "phrase",
532
+ lowerInside: false,
533
+ descriptor: true,
534
+ truncatable: true,
535
+ tokenFluff: false
536
+ }
537
+ ],
538
+ [
539
+ "school of irish dancing",
540
+ {
541
+ canonical: "school of irish dancing",
542
+ kind: "phrase",
543
+ lowerInside: false,
544
+ descriptor: true,
545
+ truncatable: true,
546
+ tokenFluff: false
547
+ }
548
+ ],
549
+ [
550
+ "school of dance",
551
+ {
552
+ canonical: "school of dance",
553
+ kind: "phrase",
554
+ lowerInside: false,
555
+ descriptor: true,
556
+ truncatable: true,
557
+ tokenFluff: false
558
+ }
559
+ ],
560
+ [
561
+ "school of dancing",
562
+ {
563
+ canonical: "school of dancing",
564
+ kind: "phrase",
565
+ lowerInside: false,
566
+ descriptor: true,
567
+ truncatable: true,
568
+ tokenFluff: false
569
+ }
570
+ ],
571
+ [
572
+ "irish dance school",
573
+ {
574
+ canonical: "irish dance school",
575
+ kind: "phrase",
576
+ lowerInside: false,
577
+ descriptor: true,
578
+ truncatable: true,
579
+ tokenFluff: false
580
+ }
581
+ ],
582
+ [
583
+ "irish dancing school",
584
+ {
585
+ canonical: "irish dancing school",
586
+ kind: "phrase",
587
+ lowerInside: false,
588
+ descriptor: true,
589
+ truncatable: true,
590
+ tokenFluff: false
591
+ }
592
+ ],
593
+ [
594
+ "irish dance academy",
595
+ {
596
+ canonical: "irish dance academy",
597
+ kind: "phrase",
598
+ lowerInside: false,
599
+ descriptor: true,
600
+ truncatable: true,
601
+ tokenFluff: false
602
+ }
603
+ ],
604
+ [
605
+ "dance academy",
606
+ {
607
+ canonical: "dance academy",
608
+ kind: "phrase",
609
+ lowerInside: false,
610
+ descriptor: true,
611
+ truncatable: true,
612
+ tokenFluff: false
613
+ }
614
+ ],
615
+ [
616
+ "irish step dance",
617
+ {
618
+ canonical: "irish step dance",
619
+ kind: "phrase",
620
+ lowerInside: false,
621
+ descriptor: true,
622
+ truncatable: true,
623
+ tokenFluff: false
624
+ }
625
+ ],
626
+ [
627
+ "irish step dancing",
628
+ {
629
+ canonical: "irish step dancing",
630
+ kind: "phrase",
631
+ lowerInside: false,
632
+ descriptor: true,
633
+ truncatable: true,
634
+ tokenFluff: false
635
+ }
636
+ ]
637
+ ]);
638
+ function schoolFluff(text) {
639
+ return SCHOOL_FLUFF_VOCABULARY.get(text.toLocaleLowerCase());
640
+ }
641
+ function isFluffWord2(token) {
642
+ return schoolFluff(token)?.kind === "word";
643
+ }
644
+ var TRUNCATABLE_FLUFF_WORDS = [...SCHOOL_FLUFF_VOCABULARY.values()].filter((entry) => entry.kind === "word" && entry.truncatable).map((entry) => entry.canonical);
645
+ function isTruncatedFluff(token) {
646
+ const t = token.toLocaleLowerCase();
647
+ return t !== "" && isProperPrefixOfAny(t, TRUNCATABLE_FLUFF_WORDS);
648
+ }
649
+ function isProperPrefixOfAny(token, words) {
650
+ for (const w of words)
651
+ if (w.length > token.length && w.startsWith(token))
652
+ return true;
653
+ return false;
654
+ }
655
+ var FLUFF_PHRASES = [...SCHOOL_FLUFF_VOCABULARY.values()].filter((entry) => entry.kind === "phrase").map((entry) => entry.canonical).sort((a, b) => b.length - a.length || a.localeCompare(b));
656
+ function isFluffPhrasePrefix(text) {
657
+ const t = text.toLocaleLowerCase();
658
+ if (t === "")
659
+ return false;
660
+ return FLUFF_PHRASES.some((phrase) => phrase.startsWith(t));
661
+ }
662
+ function trailingFluffRun2(tokens, distinctive) {
663
+ let start = tokens.length;
664
+ for (let i = tokens.length - 1;i >= 0; i -= 1) {
665
+ if (!isFluffPhrasePrefix(tokens.slice(i).join(" ")))
666
+ continue;
667
+ if (!tokens.slice(0, i).some(distinctive))
668
+ continue;
669
+ start = i;
670
+ }
671
+ while (start > 0) {
672
+ const token = tokens[start - 1] ?? "";
673
+ if (!isFluffWord2(token) && !isTruncatedFluff(token) && distinctive(token))
674
+ break;
675
+ if (!tokens.slice(0, start - 1).some(distinctive))
676
+ break;
677
+ start -= 1;
678
+ }
679
+ return start;
680
+ }
681
+
682
+ import { nameParticle } from "@finbheara/names/particles";
683
+ var FUSED_PREFIXES = new Set(["O", "Mc", "Mac"]);
684
+ function joinedPrefix2(printed, next) {
685
+ if (!/^\p{L}{2}/u.test(next))
686
+ return;
687
+ const particle = nameParticle(printed);
688
+ if (particle === undefined || !particle.standalone)
689
+ return;
690
+ if (!FUSED_PREFIXES.has(particle.canonical))
691
+ return;
692
+ return particle.join === "apostrophe" ? `${particle.canonical}'${next}` : `${particle.canonical}${next}`;
693
+ }
694
+
695
+ var SCHOOL_INSTITUTION_VOCABULARY = new Map([
696
+ [
697
+ "academy",
698
+ {
699
+ canonical: "academy",
700
+ label: "Academy",
701
+ kind: "word",
702
+ position: "suffix",
703
+ truncatable: true,
704
+ glued: true,
705
+ matchKey: true
706
+ }
707
+ ],
708
+ [
709
+ "acadamy",
710
+ {
711
+ canonical: "academy",
712
+ label: "Academy",
713
+ kind: "word",
714
+ position: "suffix",
715
+ truncatable: false,
716
+ glued: false,
717
+ matchKey: false
718
+ }
719
+ ],
720
+ [
721
+ "acadamh",
722
+ {
723
+ canonical: "academy",
724
+ label: "Academy",
725
+ kind: "word",
726
+ position: "suffix",
727
+ truncatable: false,
728
+ glued: false,
729
+ matchKey: false
730
+ }
731
+ ],
732
+ [
733
+ "accademia",
734
+ {
735
+ canonical: "academy",
736
+ label: "Academy",
737
+ kind: "word",
738
+ position: "suffix",
739
+ truncatable: false,
740
+ glued: false,
741
+ matchKey: false
742
+ }
743
+ ],
744
+ [
745
+ "school",
746
+ {
747
+ canonical: "school",
748
+ label: "School",
749
+ kind: "word",
750
+ position: "suffix",
751
+ truncatable: true,
752
+ glued: true,
753
+ matchKey: true
754
+ }
755
+ ],
756
+ [
757
+ "schools",
758
+ {
759
+ canonical: "school",
760
+ label: "School",
761
+ kind: "word",
762
+ position: "suffix",
763
+ truncatable: false,
764
+ glued: false,
765
+ matchKey: false
766
+ }
767
+ ],
768
+ [
769
+ "sd",
770
+ {
771
+ canonical: "school",
772
+ label: "School",
773
+ kind: "word",
774
+ position: "suffix",
775
+ truncatable: false,
776
+ glued: false,
777
+ matchKey: false
778
+ }
779
+ ],
780
+ [
781
+ "s d",
782
+ {
783
+ canonical: "school",
784
+ label: "School",
785
+ kind: "phrase",
786
+ position: "suffix",
787
+ truncatable: false,
788
+ glued: false,
789
+ matchKey: false
790
+ }
791
+ ],
792
+ [
793
+ "ecole",
794
+ {
795
+ canonical: "school",
796
+ label: "School",
797
+ kind: "word",
798
+ position: "prefix",
799
+ truncatable: false,
800
+ glued: false,
801
+ matchKey: false
802
+ }
803
+ ],
804
+ [
805
+ "escuela",
806
+ {
807
+ canonical: "school",
808
+ label: "School",
809
+ kind: "word",
810
+ position: "prefix",
811
+ truncatable: false,
812
+ glued: false,
813
+ matchKey: false
814
+ }
815
+ ],
816
+ [
817
+ "scoil",
818
+ {
819
+ canonical: "scoilrince",
820
+ label: "S.R.",
821
+ kind: "word",
822
+ position: "prefix",
823
+ truncatable: false,
824
+ glued: false,
825
+ matchKey: true
826
+ }
827
+ ],
828
+ [
829
+ "scoil rince",
830
+ {
831
+ canonical: "scoilrince",
832
+ label: "S.R.",
833
+ kind: "phrase",
834
+ position: "prefix",
835
+ truncatable: false,
836
+ glued: false,
837
+ matchKey: true
838
+ }
839
+ ],
840
+ [
841
+ "s r",
842
+ {
843
+ canonical: "scoilrince",
844
+ label: "S.R.",
845
+ kind: "phrase",
846
+ position: "prefix",
847
+ truncatable: false,
848
+ glued: false,
849
+ matchKey: false
850
+ }
851
+ ],
852
+ [
853
+ "sr",
854
+ {
855
+ canonical: "scoilrince",
856
+ label: "S.R.",
857
+ kind: "word",
858
+ position: "prefix",
859
+ truncatable: false,
860
+ glued: false,
861
+ matchKey: false
862
+ }
863
+ ],
864
+ [
865
+ "studio",
866
+ {
867
+ canonical: "studio",
868
+ label: "Studio",
869
+ kind: "word",
870
+ position: "suffix",
871
+ truncatable: true,
872
+ glued: false,
873
+ matchKey: true
874
+ }
875
+ ],
876
+ [
877
+ "studios",
878
+ {
879
+ canonical: "studio",
880
+ label: "Studio",
881
+ kind: "word",
882
+ position: "suffix",
883
+ truncatable: false,
884
+ glued: false,
885
+ matchKey: false
886
+ }
887
+ ],
888
+ [
889
+ "company",
890
+ {
891
+ canonical: "company",
892
+ label: "Company",
893
+ kind: "word",
894
+ position: "suffix",
895
+ truncatable: true,
896
+ glued: false,
897
+ matchKey: true
898
+ }
899
+ ],
900
+ [
901
+ "institute",
902
+ {
903
+ canonical: "institute",
904
+ label: "Institute",
905
+ kind: "word",
906
+ position: "suffix",
907
+ truncatable: true,
908
+ glued: false,
909
+ matchKey: true
910
+ }
911
+ ],
912
+ [
913
+ "center",
914
+ {
915
+ canonical: "center",
916
+ label: "Center",
917
+ kind: "word",
918
+ position: "suffix",
919
+ truncatable: true,
920
+ glued: false,
921
+ matchKey: true
922
+ }
923
+ ],
924
+ [
925
+ "centre",
926
+ {
927
+ canonical: "center",
928
+ label: "Center",
929
+ kind: "word",
930
+ position: "suffix",
931
+ truncatable: false,
932
+ glued: false,
933
+ matchKey: true
934
+ }
935
+ ],
936
+ [
937
+ "club",
938
+ {
939
+ canonical: "club",
940
+ label: "Club",
941
+ kind: "word",
942
+ position: "suffix",
943
+ truncatable: false,
944
+ glued: false,
945
+ matchKey: false
946
+ }
947
+ ]
948
+ ]);
949
+ function foldText(text) {
950
+ return text.toLocaleLowerCase().normalize("NFD").replace(/\p{M}/gu, "").replace(/[^a-z0-9]+/g, " ").trim();
951
+ }
952
+ function schoolInstitution(text) {
953
+ return SCHOOL_INSTITUTION_VOCABULARY.get(foldText(text));
954
+ }
955
+ function isInstitutionWord2(text) {
956
+ return schoolInstitution(text) !== undefined;
957
+ }
958
+ function namesInstitution2(text) {
959
+ for (const m of text.matchAll(/[\p{L}\p{N}.'’]+/gu))
960
+ if (isInstitutionWord2(m[0]))
961
+ return true;
962
+ return false;
963
+ }
964
+ var LABEL_BY_TYPE = new Map([...SCHOOL_INSTITUTION_VOCABULARY.values()].map((v) => [v.canonical, v.label]));
965
+ function institutionLabel(type) {
966
+ return LABEL_BY_TYPE.get(type);
967
+ }
968
+ var INSTITUTION_TYPES = [...LABEL_BY_TYPE.keys()].sort();
969
+ var INSTITUTION_PHRASES2 = [...SCHOOL_INSTITUTION_VOCABULARY].filter(([, v]) => v.kind === "phrase").map(([k]) => k).sort();
970
+ var GLUED_INSTITUTION_SUFFIXES2 = [...SCHOOL_INSTITUTION_VOCABULARY].filter(([, v]) => v.glued).map(([k]) => k).sort();
971
+ function truncatedInstitution2(tail) {
972
+ const folded = foldText(tail);
973
+ if (folded === "")
974
+ return;
975
+ let found;
976
+ for (const [key, entry] of SCHOOL_INSTITUTION_VOCABULARY) {
977
+ if (!entry.truncatable)
978
+ continue;
979
+ if (key.length <= folded.length || !key.startsWith(folded))
980
+ continue;
981
+ if (found !== undefined && found.canonical !== entry.canonical)
982
+ return;
983
+ found ??= entry;
984
+ }
985
+ return found;
986
+ }
987
+ var MATCH_KEY_INSTITUTION_WORDS = [
988
+ ...new Set([...SCHOOL_INSTITUTION_VOCABULARY].filter(([, v]) => v.matchKey).flatMap(([k]) => k.split(" ")))
989
+ ].sort();
990
+
991
+ import { normalizeApostrophes } from "@finbheara/names/lexicon";
992
+
993
+ var CP1252_HIGH = "€‚ƒ„…†‡ˆ‰Š‹Œ" + "Ž‘’“”•–—˜™š›" + "œžŸ";
994
+ var BYTE_OF_CP1252 = new Map([...CP1252_HIGH].map((ch, i) => [ch.codePointAt(0), 128 + i]));
995
+ var MOJIBAKE = /[Â-ßà-ï][€-¿‚-›ŒŠŽ]/u;
996
+ var MOJIBAKE_ALL = new RegExp(MOJIBAKE.source, "gu");
997
+ var FLATTENED_NBSP = /(?<=\S)[Â-Å] /u;
998
+ function isNbspLead(code) {
999
+ return code >= 194 && code <= 197;
1000
+ }
1001
+ var NON_LATIN_LETTER = /(?!\p{Script=Latin})\p{L}/u;
1002
+ function isRepair(before, after) {
1003
+ if (!NON_LATIN_LETTER.test(after))
1004
+ return true;
1005
+ return (before.match(MOJIBAKE_ALL)?.length ?? 0) >= 2;
1006
+ }
1007
+ function undoMojibake(s) {
1008
+ const bytes = new Uint8Array(s.length);
1009
+ for (let i = 0;i < s.length; i++) {
1010
+ const code = s.charCodeAt(i);
1011
+ const flattened = code === 32 && i > 1 && isNbspLead(s.charCodeAt(i - 1)) && /\S/u.test(s[i - 2]);
1012
+ const byte = flattened ? 160 : BYTE_OF_CP1252.get(code) ?? code;
1013
+ if (byte > 255)
1014
+ return;
1015
+ bytes[i] = byte;
1016
+ }
1017
+ try {
1018
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
1019
+ } catch {
1020
+ return;
1021
+ }
1022
+ }
1023
+ function repairSchoolMojibake(print) {
1024
+ let s = print;
1025
+ for (let round = 0;round < 3 && (MOJIBAKE.test(s) || FLATTENED_NBSP.test(s)); round++) {
1026
+ const undone = undoMojibake(s);
1027
+ if (undone === undefined || undone === s || !isRepair(s, undone))
1028
+ return s;
1029
+ s = undone;
1030
+ }
1031
+ return s;
1032
+ }
1033
+
1034
+ var SCHOOL_FLUFF_WORDS = new Set([
1035
+ ...[...SCHOOL_FLUFF_VOCABULARY.values()].filter((entry) => entry.tokenFluff).map((entry) => entry.canonical),
1036
+ ...MATCH_KEY_INSTITUTION_WORDS
1037
+ ]);
1038
+ var SCHOOL_GENERIC_NAME_PARTS = new Set(["celtic", "clann"]);
1039
+ function hasSpecificToken2(tokens) {
1040
+ for (const t of tokens)
1041
+ if (!SCHOOL_GENERIC_NAME_PARTS.has(t))
1042
+ return true;
1043
+ return false;
1044
+ }
1045
+ var GLUED_FLUFF_SUFFIXES = ["academy", "school"];
1046
+ function deglueToken(token) {
1047
+ let t = token;
1048
+ let changed = true;
1049
+ while (changed) {
1050
+ changed = false;
1051
+ for (const suf of GLUED_FLUFF_SUFFIXES) {
1052
+ if (t.length > suf.length + 2 && t.endsWith(suf)) {
1053
+ t = t.slice(0, -suf.length);
1054
+ changed = true;
1055
+ }
1056
+ }
1057
+ }
1058
+ return t;
1059
+ }
1060
+ function isTruncatedFluff2(token) {
1061
+ return isProperPrefixOfAny(token, SCHOOL_FLUFF_WORDS);
1062
+ }
1063
+ function isFluffOrFragment2(token) {
1064
+ return SCHOOL_FLUFF_WORDS.has(token) || isTruncatedFluff2(token);
1065
+ }
1066
+ function isDiscardedAnyway(token) {
1067
+ return token.length <= 2 || SCHOOL_FLUFF_WORDS.has(token);
1068
+ }
1069
+ function distinctiveTokens(tokens) {
1070
+ return tokens.filter((t) => t.length > 2 && !SCHOOL_FLUFF_WORDS.has(t));
1071
+ }
1072
+ function foldSchoolName2(raw) {
1073
+ let s = repairSchoolMojibake(raw).toLowerCase();
1074
+ s = s.normalize("NFD").replace(/[̀-ͯ]/g, "");
1075
+ s = s.replace(/ß/g, "ss").replace(/æ/g, "ae").replace(/œ/g, "oe").replace(/ø/g, "o");
1076
+ s = normalizeApostrophes(s);
1077
+ s = s.replace(/'/g, "");
1078
+ const words = [];
1079
+ for (const word of s.split(/[^a-z0-9]+/)) {
1080
+ if (word === "")
1081
+ continue;
1082
+ const prev = words[words.length - 1];
1083
+ const joined = prev === undefined ? undefined : joinedPrefix2(prev, word);
1084
+ if (joined === undefined)
1085
+ words.push(word);
1086
+ else
1087
+ words[words.length - 1] = joined.toLowerCase().replace(/'/g, "");
1088
+ }
1089
+ return words.join(" ");
1090
+ }
1091
+ function schoolKeyTokens2(raw) {
1092
+ const folded = foldSchoolName2(raw).split(" ").filter((t) => t !== "").map(deglueToken);
1093
+ let end = folded.length;
1094
+ while (end > 0) {
1095
+ const last = folded[end - 1];
1096
+ if (!isTruncatedFluff2(last) && !isDiscardedAnyway(last))
1097
+ break;
1098
+ if (!hasSpecificToken2(distinctiveTokens(folded.slice(0, end - 1))))
1099
+ break;
1100
+ end -= 1;
1101
+ }
1102
+ return [...new Set(distinctiveTokens(folded.slice(0, end)))];
1103
+ }
1104
+
1105
+ export { SCHOOL_CELL_OWN_SENTINELS2, SCHOOL_CELL_SENTINELS2, schoolCellSentinelOf2, SCHOOL_NAME_EXCEPTIONS2, EXCEPTIONS_BY_LENGTH, NOT_A_SCHOOL2, notASchoolIn2, exceptionsByLength, SCHOOL_FLUFF_VOCABULARY, schoolFluff, isFluffWord2, trailingFluffRun2, joinedPrefix2, SCHOOL_INSTITUTION_VOCABULARY, schoolInstitution, isInstitutionWord2, namesInstitution2, institutionLabel, INSTITUTION_PHRASES2, GLUED_INSTITUTION_SUFFIXES2, truncatedInstitution2, repairSchoolMojibake, hasSpecificToken2, isFluffOrFragment2, foldSchoolName2, schoolKeyTokens2 };