@finbheara/domain 0.0.0-stage → 0.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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +273 -2
  3. package/dist/age.js +420 -0
  4. package/dist/ceili.js +15 -0
  5. package/dist/chunks/place-7gqecaxd.js +201 -0
  6. package/dist/chunks/place-g6yw4cq6.js +134 -0
  7. package/dist/chunks/place-kr42294h.js +267 -0
  8. package/dist/chunks/place-qbp3xfb4.js +7412 -0
  9. package/dist/clrg-regions.js +603 -0
  10. package/dist/dance-types.js +14 -0
  11. package/dist/dance.js +41 -0
  12. package/dist/noun-index.js +233 -0
  13. package/dist/place.js +36 -0
  14. package/dist/school.js +2269 -0
  15. package/dist/tune.js +23 -0
  16. package/dist/types/age-types.d.ts +31 -0
  17. package/dist/types/age.d.ts +84 -0
  18. package/dist/types/ceili.d.ts +53 -0
  19. package/dist/types/clrg-regions.d.ts +31 -0
  20. package/dist/types/dance-match.d.ts +28 -0
  21. package/dist/types/dance-types.d.ts +9 -0
  22. package/dist/types/dance.d.ts +14 -0
  23. package/dist/types/noun-index.d.ts +67 -0
  24. package/dist/types/place-tree.d.ts +4 -0
  25. package/dist/types/place-types.d.ts +24 -0
  26. package/dist/types/place.d.ts +98 -0
  27. package/dist/types/school-compare.d.ts +39 -0
  28. package/dist/types/school-encoder.d.ts +8 -0
  29. package/dist/types/school-exception-vocabulary.d.ts +23 -0
  30. package/dist/types/school-fluff-vocabulary.d.ts +16 -0
  31. package/dist/types/school-fused-prefix.d.ts +1 -0
  32. package/dist/types/school-identity.d.ts +9 -0
  33. package/dist/types/school-institution-vocabulary.d.ts +20 -0
  34. package/dist/types/school-location.d.ts +16 -0
  35. package/dist/types/school-match-key.d.ts +5 -0
  36. package/dist/types/school-name.d.ts +82 -0
  37. package/dist/types/school-tokens.d.ts +20 -0
  38. package/dist/types/school.d.ts +11 -0
  39. package/dist/types/tune.d.ts +63 -0
  40. package/package.json +73 -5
package/dist/tune.js ADDED
@@ -0,0 +1,23 @@
1
+ import {
2
+ SET_MIN_SPEED2,
3
+ PLAUSIBLE_SET_TEMPO_MAX2,
4
+ TUNE_NODES2,
5
+ allTunes2,
6
+ tuneById2,
7
+ tempoLegal2,
8
+ settingAt2,
9
+ tune2,
10
+ tuneRelation2
11
+ } from "./chunks/place-kr42294h.js";
12
+ import"./chunks/place-g6yw4cq6.js";
13
+ export {
14
+ PLAUSIBLE_SET_TEMPO_MAX2 as PLAUSIBLE_SET_TEMPO_MAX,
15
+ SET_MIN_SPEED2 as SET_MIN_SPEED,
16
+ TUNE_NODES2 as TUNE_NODES,
17
+ allTunes2 as allTunes,
18
+ settingAt2 as settingAt,
19
+ tempoLegal2 as tempoLegal,
20
+ tune2 as tune,
21
+ tuneById2 as tuneById,
22
+ tuneRelation2 as tuneRelation
23
+ };
@@ -0,0 +1,31 @@
1
+ export interface AgeInterval {
2
+ readonly lo: number;
3
+ readonly hi: number;
4
+ }
5
+ export interface BirthYears {
6
+ readonly from: number | null;
7
+ readonly to: number | null;
8
+ }
9
+ export interface AgeLadder {
10
+ readonly caps: readonly number[];
11
+ readonly overs: readonly number[];
12
+ readonly ranges: readonly number[];
13
+ }
14
+ export interface AgeContext {
15
+ readonly ladder?: AgeLadder;
16
+ readonly year?: number | null;
17
+ readonly top?: boolean;
18
+ }
19
+ export type AgeArm = "band" | "yob" | "open" | "empty";
20
+ export type AgeKind = "under" | "over" | "range" | "adult" | "senior" | "yob";
21
+ export type AgeRefusal = "not-a-band" | "backwards-range" | "senior-without-ladder";
22
+ export type AgeSource = "sibling-narrowed" | "printed-band" | "printed-range" | "printed-yob" | "open";
23
+ export type AgeClause = "under-floored-on-rung" | "youngest-absorbs" | "over-ceiling-from-next-over" | "over-ceiling-refused-gap" | "and-over-no-ceiling" | "range-overlapping" | "range-inclusive" | "range-floor-on-rung" | "range-floor-widened" | "range-adult-floor";
24
+ export type AgeRelation = "same" | "contains" | "overlaps" | "disjoint" | "silent";
25
+ export type AgeRelationReason = "equal" | "a-contains-b" | "b-contains-a" | "partial" | "a-older" | "a-younger" | "a-not-a-band" | "b-not-a-band";
26
+ export interface AgeComparison {
27
+ readonly relation: AgeRelation;
28
+ readonly reason: AgeRelationReason;
29
+ }
30
+ export type AgeMisuse = "not-exact" | "empty-average" | "average-of-averages" | "average-as-container" | "average-birth-years" | "average-container-no-year" | "average-in-relation";
31
+ export type YoungFloorVerdict = "clear" | "same-school-only" | "too-young";
@@ -0,0 +1,84 @@
1
+ import type { AgeArm, AgeClause, AgeComparison, AgeContext, AgeInterval, AgeKind, AgeLadder, AgeMisuse, AgeRefusal, AgeRelation, AgeRelationReason, AgeSource, BirthYears, YoungFloorVerdict } from "./age-types.ts";
2
+ export type { AgeArm, AgeClause, AgeComparison, AgeContext, AgeInterval, AgeKind, AgeLadder, AgeMisuse, AgeRefusal, AgeRelation, AgeRelationReason, AgeSource, BirthYears, YoungFloorVerdict, };
3
+ export declare const YOUNGEST_FLOOR = 0;
4
+ export declare const ADULT_FLOOR = 18;
5
+ export declare const MAJORS_FLOOR_YEARS = 3;
6
+ export declare const UNDER_CAP: Readonly<{
7
+ readonly plain: 2;
8
+ readonly exceptional: 4;
9
+ }>;
10
+ export declare const UNDER_CAP_MAX_TOP = 21;
11
+ export declare const YOUNG_FLOOR: Readonly<{
12
+ readonly hard: 2;
13
+ readonly soft: 4;
14
+ }>;
15
+ export declare const MIN_MAJOR_AGE = 4;
16
+ export declare const MIN_FEIS_AGE = 3;
17
+ export declare const DANCE_UP_YEARS = 1;
18
+ export declare const ageOnJanuary1: (year: number, born: number) => number;
19
+ export declare const yearsSinceBirth: (year: number, born: number) => number;
20
+ export interface Age {
21
+ readonly [Symbol.toStringTag]: "Age";
22
+ toString(): string;
23
+ readonly arm: AgeArm;
24
+ readonly kind: AgeKind | null;
25
+ readonly ag0: string;
26
+ readonly ag1: string;
27
+ readonly ag2: string;
28
+ readonly parts: readonly number[];
29
+ readonly length: number;
30
+ readonly refusal: AgeRefusal | null;
31
+ readonly source: AgeSource;
32
+ readonly clauses: readonly AgeClause[];
33
+ readonly ladder: AgeLadder;
34
+ readonly year: number | null;
35
+ isEmpty(): boolean;
36
+ isAge(): boolean;
37
+ isExact(): boolean;
38
+ isAndOver(): boolean;
39
+ isAdult(): boolean;
40
+ interval(): AgeInterval | null;
41
+ birthYears(year?: number): BirthYears;
42
+ floorObserved(): boolean | null;
43
+ fitsIn(container: Age): boolean;
44
+ overlaps(other: Age): boolean;
45
+ }
46
+ export declare class AgeMisuseError extends Error {
47
+ readonly misuse: AgeMisuse;
48
+ constructor(misuse: AgeMisuse, detail: string);
49
+ }
50
+ declare function fromPrint(print: string, context?: AgeContext): Age;
51
+ declare function fromYOB(from: number | null, to?: number | null): Age;
52
+ export declare const Age: Readonly<{
53
+ from: typeof fromPrint;
54
+ fromYOB: typeof fromYOB;
55
+ }>;
56
+ export declare function birthYearsOfInterval(iv: AgeInterval | null, year: number): BirthYears;
57
+ export declare function ageRelation(a: Age, b: Age): AgeComparison;
58
+ export declare function canOverlap(...ages: readonly Age[]): boolean;
59
+ export declare const AVERAGE_AGE_DECIMALS = 2;
60
+ export declare function roundedMeanHundredths(k: number, n: number): number;
61
+ export interface AverageAge {
62
+ readonly [Symbol.toStringTag]: "AverageAge";
63
+ readonly provenance: string;
64
+ readonly members: readonly Age[];
65
+ readonly n: number;
66
+ readonly birthYearSum: number;
67
+ readonly meanBirthYear: number;
68
+ toString(): string;
69
+ isExact(): false;
70
+ meanAgeHundredths(year: number): number;
71
+ meanAge(year: number): number;
72
+ fitsIn(container: Age): boolean;
73
+ birthYears(): never;
74
+ }
75
+ export declare function isAveraged(a: Age | AverageAge): a is AverageAge;
76
+ export declare function averageAge(ages: readonly Age[]): AverageAge;
77
+ export declare function birthYearsDisjoint(a: BirthYears, b: BirthYears): boolean;
78
+ export declare function birthYearsMeet(card: BirthYears, other: BirthYears, slack?: number): boolean;
79
+ export declare function underCapApplies(bandFrom: number | null, year: number): boolean;
80
+ export declare function underCappedYears(b: BirthYears, year: number, n?: number): BirthYears;
81
+ export declare function underCapRefuses(bandFrom: number, identityFrom: number, n: number): boolean;
82
+ export declare function youngFloor(year: number, oldest: number): YoungFloorVerdict;
83
+ export declare const tooYoungForMajor: (year: number, oldest: number) => boolean;
84
+ export declare const tooYoungForFeis: (year: number, oldest: number) => boolean;
@@ -0,0 +1,53 @@
1
+ import { type DanceMatch, type DanceRelation } from "./dance-match.ts";
2
+ export type CeiliFamily = "eight-hand" | "four-hand" | "handbook";
3
+ export type CeiliFormation = "set" | "long" | "round";
4
+ export interface CeiliNode {
5
+ readonly id: string;
6
+ readonly name: string;
7
+ readonly irish: string | null;
8
+ readonly prints: readonly string[];
9
+ readonly irishPrints: readonly string[];
10
+ readonly formation: CeiliFormation;
11
+ readonly hands: number | null;
12
+ readonly setHands: number | null;
13
+ readonly family: CeiliFamily;
14
+ }
15
+ export declare const CEILI_NODES: readonly CeiliNode[];
16
+ export interface Ceili {
17
+ readonly [Symbol.toStringTag]: "Ceili";
18
+ readonly id: string;
19
+ readonly name: string;
20
+ readonly irish: string | null;
21
+ readonly node: CeiliNode;
22
+ toString(): string;
23
+ hands(): number | "long" | "round";
24
+ setHands(): number | null;
25
+ isLong(): boolean;
26
+ family(): CeiliFamily;
27
+ inHandbook(): boolean;
28
+ }
29
+ export declare function allCeilis(): readonly Ceili[];
30
+ export declare function ceiliById(id: string): Ceili | undefined;
31
+ export interface CeiliContext {
32
+ readonly list?: "eight-hand" | "four-hand";
33
+ readonly hands?: number;
34
+ }
35
+ export type CeiliRefusal = "empty" | "dance-type" | "unmatched";
36
+ export interface CeiliReading {
37
+ readonly [Symbol.toStringTag]: "CeiliReading";
38
+ readonly print: string;
39
+ readonly folded: string;
40
+ readonly candidates: readonly Ceili[];
41
+ readonly score: number;
42
+ readonly match: DanceMatch | null;
43
+ readonly refusal: CeiliRefusal | null;
44
+ readonly misses: readonly string[];
45
+ readonly ceili: Ceili | undefined;
46
+ isCeili(): boolean;
47
+ isSingular(): boolean;
48
+ isAmbiguous(): boolean;
49
+ refine(ctx: CeiliContext): CeiliReading;
50
+ toString(): string;
51
+ }
52
+ export declare function ceili(print: string, ctx?: CeiliContext): CeiliReading;
53
+ export declare function ceiliRelation(a: CeiliReading, b: CeiliReading): DanceRelation;
@@ -0,0 +1,31 @@
1
+ export declare const REGIONS: {
2
+ readonly SRO: "Southern Region USA";
3
+ readonly WUSRO: "Western Region USA";
4
+ readonly NERO: "New England Region USA";
5
+ readonly MARO: "Mid-Atlantic Region USA";
6
+ readonly MAO: "Mid-America Region USA";
7
+ readonly WCRO: "Western Canada";
8
+ readonly ECRO: "Eastern Canada";
9
+ readonly ULSTER: "Cúige Uladh / Ulster";
10
+ readonly MUNSTER: "Cúige Mumhan / Munster";
11
+ readonly LEINSTER: "Cúige Laighean / Leinster";
12
+ readonly CONNACHT: "Cúige Chonnacht / Connacht";
13
+ readonly SCOTLAND: "Albain / Scotland";
14
+ readonly ENG_MIDLANDS: "England — Midlands";
15
+ readonly ENG_NW: "England — North-West";
16
+ readonly ENG_NE: "England — North-East";
17
+ readonly ENG_SOUTH: "England — South (SERC)";
18
+ readonly RCCEA: "Continental Europe & Asia (RCCEA)";
19
+ readonly NZ: "New Zealand";
20
+ readonly AUSTRALIA: "Australia";
21
+ readonly SOUTH_AFRICA: "South Africa";
22
+ readonly SOUTH_AMERICA: "South America";
23
+ };
24
+ export type RegionCode = keyof typeof REGIONS;
25
+ export declare const AMBIGUOUS_REGION: ReadonlySet<string>;
26
+ export declare const regionOf: (location: string) => RegionCode | undefined;
27
+ export declare const regionOfPlace: (location: string) => RegionCode | undefined;
28
+ export declare const isStateCode: (token: string) => boolean;
29
+ export declare function isPlaceName(phrase: string): boolean;
30
+ export declare const AMBIGUOUS_PLACES: ReadonlySet<string>;
31
+ export declare function resolvePhrase(phrase: string): RegionCode[];
@@ -0,0 +1,28 @@
1
+ export type DanceMatch = "exact" | "within" | "around" | "fuzzy";
2
+ export declare const FUZZY_FLOOR = 0.75;
3
+ export declare const WITHIN_SCORE = 0.9;
4
+ export declare const AROUND_SCORE = 0.85;
5
+ export declare function foldDancePrint(print: string): string;
6
+ export declare function splitTempo(print: string, range?: {
7
+ readonly min: number;
8
+ readonly max: number;
9
+ }): {
10
+ rest: string;
11
+ bpm: number | null;
12
+ };
13
+ export declare function matchFolded(q: string, c: string): {
14
+ kind: DanceMatch;
15
+ score: number;
16
+ } | null;
17
+ export declare function scoreFolded(q: string, c: string): number;
18
+ export interface Matchable {
19
+ readonly id: string;
20
+ readonly aliases: readonly string[];
21
+ }
22
+ export declare function matchNodes<T extends Matchable>(folded: string, nodes: readonly T[]): {
23
+ nodes: T[];
24
+ score: number;
25
+ kind: DanceMatch | null;
26
+ };
27
+ export type DanceRelation = "same" | "overlaps" | "conflict" | "silent";
28
+ export declare function candidateRelation(a: readonly string[], b: readonly string[]): DanceRelation;
@@ -0,0 +1,9 @@
1
+ export type { DanceMatch, DanceRelation } from "./dance-match.ts";
2
+ export type DanceType = "reel" | "light-jig" | "single-jig" | "slip-jig" | "treble-jig" | "hornpipe" | "traditional-set" | "set-dance";
3
+ export declare const DANCE_TYPES: readonly DanceType[];
4
+ export type TimeSignature = "2/4" | "4/4" | "6/8" | "9/8" | "6/8+9/8";
5
+ export type SetRhythm = "jig" | "hornpipe";
6
+ export declare function rhythmOfTime(time: TimeSignature): SetRhythm;
7
+ export declare function danceTypes(print: string): readonly DanceType[];
8
+ export declare function danceTypePrints(): ReadonlyMap<string, readonly DanceType[]>;
9
+ export declare function isDanceTypePrint(print: string): boolean;
@@ -0,0 +1,14 @@
1
+ import { type Ceili, type CeiliReading } from "./ceili.ts";
2
+ import { type Tune, type TuneReading } from "./tune.ts";
3
+ export type DanceRound = "set" | "traditional-set" | "ceili" | "eight-hand" | "four-hand";
4
+ export interface DanceReading {
5
+ readonly print: string;
6
+ readonly tunes: TuneReading;
7
+ readonly ceilis: CeiliReading;
8
+ readonly misses: readonly string[];
9
+ readonly candidates: readonly (Tune | Ceili)[];
10
+ roundHeld(): boolean;
11
+ isAmbiguousKind(): boolean;
12
+ isSingular(): boolean;
13
+ }
14
+ export declare function dance(print: string, round?: DanceRound): DanceReading;
@@ -0,0 +1,67 @@
1
+ import { type PersonName, type ResolvedNameOrder, type TransitiveLevel } from "@finbheara/names/normalize";
2
+ export type SqlValue = string | number | bigint | null;
3
+ export interface SqlStatement {
4
+ run(...params: SqlValue[]): unknown;
5
+ all(...params: SqlValue[]): unknown[];
6
+ }
7
+ export interface SqlHandle {
8
+ prepare(sql: string): SqlStatement;
9
+ }
10
+ export type EncodedRow = Readonly<Record<string, string | null>>;
11
+ export interface NounEncoder<X, L extends string = string> {
12
+ readonly columns: readonly string[];
13
+ readonly levels: readonly L[];
14
+ readonly indexed: readonly string[];
15
+ encode(x: X): EncodedRow;
16
+ key?(x: X, level: L): string | null;
17
+ decode(row: EncodedRow): X;
18
+ }
19
+ export interface IndexOptions {
20
+ readonly table?: string;
21
+ readonly value?: string;
22
+ readonly valueType?: string;
23
+ }
24
+ export interface IndexRow<V> {
25
+ readonly value: V;
26
+ readonly row: EncodedRow;
27
+ }
28
+ export interface IndexMap<X, V, L extends string> {
29
+ readonly dop: L;
30
+ readonly size: number;
31
+ get(x: X): V | undefined;
32
+ has(x: X): boolean;
33
+ set(x: X, value: V): this;
34
+ delete(x: X): boolean;
35
+ clear(): void;
36
+ keys(): IterableIterator<X>;
37
+ values(): IterableIterator<V>;
38
+ entries(): IterableIterator<[X, V]>;
39
+ [Symbol.iterator](): IterableIterator<[X, V]>;
40
+ }
41
+ export interface NounIndex<X, L extends string, V extends SqlValue> {
42
+ readonly table: string;
43
+ readonly encoder: NounEncoder<X, L>;
44
+ add(x: X, value: V): void;
45
+ addAll(entries: Iterable<readonly [X, V]>): void;
46
+ get(x: X, level: L): V[];
47
+ has(x: X, level: L): boolean;
48
+ find(column: string, key: string): V[];
49
+ rows(where: Readonly<Record<string, readonly string[]>>, columns?: readonly string[]): IndexRow<V>[];
50
+ glob(column: string, pattern: string, columns?: readonly string[]): IndexRow<V>[];
51
+ nouns(value: V): X[];
52
+ remove(value: V): number;
53
+ size(): number;
54
+ map(level: L): IndexMap<X, V, L>;
55
+ }
56
+ export declare function indexSchema(encoder: NounEncoder<unknown>, options?: IndexOptions): {
57
+ table: string;
58
+ indexes: string[];
59
+ };
60
+ export declare function createIndex<X, L extends string, V extends SqlValue = SqlValue>(handle: SqlHandle, encoder: NounEncoder<X, L>, options?: IndexOptions): NounIndex<X, L, V>;
61
+ export type PersonReader = (print: string, order: ResolvedNameOrder) => PersonName;
62
+ export interface PersonEncoderOptions {
63
+ readonly read?: PersonReader;
64
+ readonly print?: string;
65
+ readonly reading?: string;
66
+ }
67
+ export declare function personEncoder(options?: PersonEncoderOptions): NounEncoder<PersonName, TransitiveLevel>;
@@ -0,0 +1,4 @@
1
+ import type { PlaceNode } from "./place-types.ts";
2
+ export declare const AMBIGUOUS_PRINTS: readonly string[];
3
+ export declare const CROSS_BORDER_REGIONS: readonly string[];
4
+ export declare const PLACE_NODES: readonly PlaceNode[];
@@ -0,0 +1,24 @@
1
+ export type PlaceKind = "world" | "continent" | "country" | "subdivision" | "city" | "body" | "region";
2
+ export interface PlaceNode {
3
+ readonly id: string;
4
+ readonly kind: PlaceKind;
5
+ readonly name: string;
6
+ readonly geo: string | null;
7
+ readonly admin: string | null;
8
+ readonly prints: readonly string[];
9
+ readonly codes: readonly string[];
10
+ readonly truncations?: readonly string[];
11
+ readonly iso2?: string;
12
+ readonly iso3?: string;
13
+ readonly isoNumeric?: string;
14
+ readonly oireachtas?: string;
15
+ }
16
+ export type PlaceMatch = "id" | "code" | "print" | "phrase" | "iso" | "county" | "truncation";
17
+ export type PlaceRefusal = "school" | "organization" | "placeholder" | "damaged";
18
+ export type PlaceRelation = "same" | "contains" | "overlaps" | "conflict" | "silent";
19
+ export interface PlaceContext {
20
+ readonly region?: string;
21
+ readonly country?: string;
22
+ readonly near?: string;
23
+ readonly declared?: boolean;
24
+ }
@@ -0,0 +1,98 @@
1
+ import type { PlaceContext, PlaceKind, PlaceMatch, PlaceNode, PlaceRefusal, PlaceRelation } from "./place-types.ts";
2
+ export type { PlaceContext, PlaceKind, PlaceMatch, PlaceNode, PlaceRefusal, PlaceRelation };
3
+ export type PlaceArm = "resolved" | "plural" | "ambiguous" | "unread";
4
+ export interface AbstractPlace {
5
+ readonly [Symbol.toStringTag]: "Place";
6
+ toString(): string;
7
+ readonly arm: PlaceArm;
8
+ readonly pl0: string;
9
+ readonly pl1: string;
10
+ readonly pl2: string;
11
+ readonly pl3: string;
12
+ readonly nodes: readonly PlaceNode[];
13
+ readonly parts: readonly PlaceNode[];
14
+ readonly ambiguous: boolean;
15
+ readonly level: PlaceKind | null;
16
+ readonly match: PlaceMatch | null;
17
+ readonly truncated: boolean;
18
+ readonly refusal: PlaceRefusal | null;
19
+ readonly misses: readonly string[];
20
+ readonly length: number;
21
+ isEmpty(): boolean;
22
+ isPlace(): boolean;
23
+ isSingular(): this is ResolvedPlace;
24
+ isPlural(): this is PluralPlaces;
25
+ isAmbiguous(): boolean;
26
+ refine(ctx: string | PlaceContext): Place;
27
+ contains(x: string): boolean;
28
+ overlaps(x: string): boolean;
29
+ readonly country: string | undefined;
30
+ readonly body: string | undefined;
31
+ readonly region: string | undefined;
32
+ }
33
+ export interface ResolvedPlace extends AbstractPlace {
34
+ readonly arm: "resolved";
35
+ readonly administrativeAreaLevel1: string | undefined;
36
+ readonly admin1: string | undefined;
37
+ readonly administrativeAreaLevel2: string | undefined;
38
+ readonly admin2: string | undefined;
39
+ readonly locality: string | undefined;
40
+ readonly types: readonly string[];
41
+ }
42
+ export interface PluralPlaces extends AbstractPlace {
43
+ readonly arm: "plural";
44
+ readonly members: readonly ResolvedPlace[];
45
+ }
46
+ export interface AmbiguousPlace extends AbstractPlace {
47
+ readonly arm: "ambiguous";
48
+ readonly candidates: readonly ResolvedPlace[];
49
+ }
50
+ export interface UnreadPlace extends AbstractPlace {
51
+ readonly arm: "unread";
52
+ }
53
+ export type Place = ResolvedPlace | PluralPlaces | AmbiguousPlace | UnreadPlace;
54
+ export type PlaceRefusals = (print: string) => PlaceRefusal | undefined;
55
+ export interface PlaceReaderOptions {
56
+ readonly tree?: readonly PlaceNode[];
57
+ readonly refusals?: PlaceRefusals | ReadonlyMap<string, PlaceRefusal>;
58
+ readonly capacity?: number;
59
+ }
60
+ export declare const DEFAULT_PLACE_CAPACITY = 8192;
61
+ export declare function createPlaceReader(options?: PlaceReaderOptions): {
62
+ place: (print: string, ctx?: string | PlaceContext) => Place;
63
+ isPlaceToken: (token: string, cut?: boolean, declared?: boolean) => boolean;
64
+ countryCodeOf: (token: string) => string | undefined;
65
+ areAllPlaceTokens: (tokens: readonly string[], off?: number, declared?: boolean) => boolean;
66
+ placeFromId: (id: string) => Place;
67
+ oireachtasOfRegion: (regionId: string | undefined) => string | undefined;
68
+ regionOfOireachtas: (code: string) => Place;
69
+ placeStats: () => {
70
+ hits: number;
71
+ misses: number;
72
+ evictions: number;
73
+ };
74
+ resetPlaceCache: (next?: number) => void;
75
+ placeRelation: (a: Place, b: Place) => PlaceRelation;
76
+ placesRelation: (a: readonly Place[], b: readonly Place[]) => PlaceRelation;
77
+ probablySamePlace: (a: Place, b: Place) => boolean;
78
+ sameReading: (a: Place, b: Place) => boolean;
79
+ };
80
+ export type PlaceReader = ReturnType<typeof createPlaceReader>;
81
+ export declare const DEFAULT_PLACE_READER: PlaceReader;
82
+ export declare function place(print: string, ctx?: string | PlaceContext): Place;
83
+ export declare function isPlaceToken(token: string, cut?: boolean, declared?: boolean): boolean;
84
+ export declare function countryCodeOf(token: string): string | undefined;
85
+ export declare function areAllPlaceTokens(tokens: readonly string[], off?: number, declared?: boolean): boolean;
86
+ export declare function placeFromId(id: string): Place;
87
+ export declare function oireachtasOfRegion(regionId: string | undefined): string | undefined;
88
+ export declare function regionOfOireachtas(code: string): Place;
89
+ export declare function placeStats(): {
90
+ hits: number;
91
+ misses: number;
92
+ evictions: number;
93
+ };
94
+ export declare function resetPlaceCache(next?: number): void;
95
+ export declare function placeRelation(a: Place, b: Place): PlaceRelation;
96
+ export declare function placesRelation(a: readonly Place[], b: readonly Place[]): PlaceRelation;
97
+ export declare function probablySamePlace(a: Place, b: Place): boolean;
98
+ export declare function sameReading(a: Place, b: Place): boolean;
@@ -0,0 +1,39 @@
1
+ import { type SchoolName } from "./school-name.ts";
2
+ export type SchoolDop = "sn0" | "sn1" | "sn2" | "sn3" | "sn4" | "realWords" | "surnames";
3
+ export declare function schoolTokensAt(name: SchoolName, dop: SchoolDop): readonly string[];
4
+ export declare function probablySameSchool(a: SchoolName, b: SchoolName, dop: SchoolDop): boolean;
5
+ export declare function differOnlyByDamagedGenerics(a: SchoolName, b: SchoolName): boolean;
6
+ export declare function isColumnCutOf(a: SchoolName, b: SchoolName): boolean;
7
+ export declare function isInitialismOf(a: SchoolName, b: SchoolName, which: "declared" | "derived"): boolean;
8
+ export declare function sameInEveryPart(a: SchoolName, b: SchoolName): boolean;
9
+ export declare function schoolCompare(a: SchoolName, b: SchoolName, dop: SchoolDop): -1 | 0 | 1;
10
+ export interface SchoolSet {
11
+ readonly dop: SchoolDop;
12
+ readonly size: number;
13
+ get(name: SchoolName): SchoolName | undefined;
14
+ has(name: SchoolName): boolean;
15
+ add(name: SchoolName): this;
16
+ delete(name: SchoolName): boolean;
17
+ clear(): void;
18
+ values(): IterableIterator<SchoolName>;
19
+ [Symbol.iterator](): IterableIterator<SchoolName>;
20
+ }
21
+ export interface SchoolMap<V> {
22
+ readonly dop: SchoolDop;
23
+ readonly size: number;
24
+ get(name: SchoolName): V | undefined;
25
+ has(name: SchoolName): boolean;
26
+ set(name: SchoolName, value: V): this;
27
+ delete(name: SchoolName): boolean;
28
+ clear(): void;
29
+ keys(): IterableIterator<SchoolName>;
30
+ values(): IterableIterator<V>;
31
+ entries(): IterableIterator<[SchoolName, V]>;
32
+ [Symbol.iterator](): IterableIterator<[SchoolName, V]>;
33
+ }
34
+ export declare function setOfSchools(dop: SchoolDop): SchoolSet;
35
+ export declare function mapOfSchools<V>(dop: SchoolDop, entries?: Iterable<readonly [SchoolName, V]>): SchoolMap<V>;
36
+ export declare const SCHOOL_LEVEL_COLUMNS: readonly ["sn0", "sn1", "sn2", "sn3", "sn4", "realWords"];
37
+ export type SchoolLevelColumn = (typeof SCHOOL_LEVEL_COLUMNS)[number];
38
+ export declare function schoolColumns(name: SchoolName): Readonly<Record<SchoolLevelColumn, string | null>>;
39
+ export declare function isLadderLevel(dop: SchoolDop): boolean;
@@ -0,0 +1,8 @@
1
+ import type { NounEncoder } from "./noun-index.ts";
2
+ import { type SchoolLevelColumn } from "./school-compare.ts";
3
+ import { type SchoolName, type SchoolNameParser } from "./school-name.ts";
4
+ export interface SchoolEncoderOptions {
5
+ readonly reader?: SchoolNameParser;
6
+ readonly print?: string;
7
+ }
8
+ export declare function schoolEncoder(options?: SchoolEncoderOptions): NounEncoder<SchoolName, SchoolLevelColumn>;
@@ -0,0 +1,23 @@
1
+ import type { SchoolTokenClass } from "./school-tokens.ts";
2
+ export interface SchoolNameException {
3
+ phrase: string;
4
+ scope: "label" | "phrase";
5
+ as: SchoolTokenClass;
6
+ token: string;
7
+ }
8
+ export declare const SCHOOL_NAME_EXCEPTIONS: readonly SchoolNameException[];
9
+ export declare const EXCEPTIONS_BY_LENGTH: readonly SchoolNameException[];
10
+ export type RefusalReason = "organization" | "placeholder" | "damaged" | "not-a-name";
11
+ export declare const REFUSAL_REASONS: readonly ["organization", "placeholder", "damaged", "not-a-name"];
12
+ type AssertTrue<T extends true> = T;
13
+ export type EveryDeclaredReasonIsARefusalReason = AssertTrue<(typeof REFUSAL_REASONS)[number] extends RefusalReason ? true : false>;
14
+ export type EveryRefusalReasonIsDeclared = AssertTrue<RefusalReason extends (typeof REFUSAL_REASONS)[number] ? true : false>;
15
+ export interface NotASchool {
16
+ pattern: string;
17
+ kind: "exact" | "prefix" | "regex";
18
+ reason: RefusalReason;
19
+ }
20
+ export declare const NOT_A_SCHOOL: readonly NotASchool[];
21
+ export declare function notASchoolIn(rows: readonly NotASchool[]): (print: string) => NotASchool | undefined;
22
+ export declare function exceptionsByLength(rows: readonly SchoolNameException[]): readonly SchoolNameException[];
23
+ export {};
@@ -0,0 +1,16 @@
1
+ export type SchoolFluffKind = "word" | "phrase";
2
+ export interface SchoolFluff {
3
+ canonical: string;
4
+ kind: SchoolFluffKind;
5
+ lowerInside: boolean;
6
+ descriptor: boolean;
7
+ truncatable: boolean;
8
+ tokenFluff: boolean;
9
+ }
10
+ export declare const SCHOOL_FLUFF_VOCABULARY: ReadonlyMap<string, SchoolFluff>;
11
+ export declare function schoolFluff(text: string): SchoolFluff | undefined;
12
+ export declare function isFluffWord(token: string): boolean;
13
+ export declare function isTruncatedFluff(token: string): boolean;
14
+ export declare const FLUFF_PHRASES: readonly string[];
15
+ export declare function isFluffPhrasePrefix(text: string): boolean;
16
+ export declare function trailingFluffRun(tokens: readonly string[], distinctive: (token: string) => boolean): number;
@@ -0,0 +1 @@
1
+ export declare function joinedPrefix(printed: string, next: string): string | undefined;
@@ -0,0 +1,9 @@
1
+ import { type SchoolName, type SchoolNameParser } from "./school-name.ts";
2
+ export type IdentityVerdict = "CANDIDATE" | "BLOCKED" | "AMBIGUOUS" | "DIFFERENT";
3
+ export interface IdentityResult {
4
+ verdict: IdentityVerdict;
5
+ reason: "name-parts-differ" | "no-name-part" | "no-school" | "institution-type-conflict" | "location-conflict" | "unqualified-vs-qualified" | "same-name-and-type" | "damaged-generic-word" | "truncated-print" | "declared-initialism" | "derived-initialism" | "promoted-token-identity" | "context-place-conflict";
6
+ sharesNameParts: boolean;
7
+ }
8
+ export declare function compareSchoolNames(a: string, b: string, reader: SchoolNameParser): IdentityResult;
9
+ export declare function compareSchools(a: SchoolName, b: SchoolName): IdentityResult;
@@ -0,0 +1,20 @@
1
+ export type InstitutionType = "academy" | "school" | "scoilrince" | "institute" | "company" | "studio" | "center" | "club";
2
+ export type InstitutionPosition = "prefix" | "suffix";
3
+ export type InstitutionKind = "word" | "phrase";
4
+ export interface SchoolInstitution {
5
+ canonical: InstitutionType;
6
+ label: string;
7
+ kind: InstitutionKind;
8
+ position: InstitutionPosition;
9
+ truncatable: boolean;
10
+ glued: boolean;
11
+ }
12
+ export declare const SCHOOL_INSTITUTION_VOCABULARY: ReadonlyMap<string, SchoolInstitution>;
13
+ export declare function schoolInstitution(text: string): SchoolInstitution | undefined;
14
+ export declare function isInstitutionWord(text: string): boolean;
15
+ export declare function institutionCanonical(text: string): InstitutionType | undefined;
16
+ export declare function institutionLabel(type: InstitutionType): string;
17
+ export declare const INSTITUTION_TYPES: readonly InstitutionType[];
18
+ export declare const INSTITUTION_PHRASES: readonly string[];
19
+ export declare const GLUED_INSTITUTION_SUFFIXES: readonly string[];
20
+ export declare function truncatedInstitution(tail: string): SchoolInstitution | undefined;
@@ -0,0 +1,16 @@
1
+ export declare const NEVER_PLACE: ReadonlyMap<string, string>;
2
+ export declare const NEVER_NAME: ReadonlyMap<string, string>;
3
+ export interface PrintZones {
4
+ qualifier: ReadonlySet<string>;
5
+ bracketed: ReadonlySet<string>;
6
+ qualifierAny: ReadonlySet<string>;
7
+ web: readonly (readonly [number, number])[];
8
+ webOnly: ReadonlySet<string>;
9
+ tailCode: {
10
+ readonly folded: string;
11
+ readonly at: number;
12
+ readonly only: boolean;
13
+ } | null;
14
+ }
15
+ export declare function printZones(raw: string): PrintZones;
16
+ export declare function opensLocation(folded: string, at: PrintZones, index?: number): boolean;
@@ -0,0 +1,5 @@
1
+ export declare const SCHOOL_FLUFF_WORDS: ReadonlySet<string>;
2
+ export declare const SCHOOL_GENERIC_NAME_PARTS: ReadonlySet<string>;
3
+ export declare function hasSpecificToken(tokens: Iterable<string>): boolean;
4
+ export declare function foldSchoolName(raw: string): string;
5
+ export declare function schoolKeyTokens(raw: string): string[];