@finbheara/domain 0.60.1 → 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.
- package/README.md +51 -2
- package/dist/chunks/place-1mpcshk8.js +1105 -0
- package/dist/chunks/{place-yvcn0ngm.js → place-c5g25pym.js} +217 -54
- package/dist/clrg-regions.js +52 -15
- package/dist/geocode.js +11 -11
- package/dist/internals.js +170 -0
- package/dist/place.js +3 -1
- package/dist/school.js +86 -1133
- package/dist/types/internals.d.ts +7 -0
- package/dist/types/place-towns.d.ts +1 -1
- package/dist/types/place-within.d.ts +1 -1
- package/dist/types/place.d.ts +2 -0
- package/dist/types/school-fluff-vocabulary.d.ts +1 -0
- package/dist/types/school-institution-vocabulary.d.ts +1 -0
- package/dist/types/school-match-key.d.ts +1 -0
- package/dist/types/school-vocabulary-word.d.ts +1 -0
- package/dist/types/school.d.ts +5 -2
- package/package.json +7 -6
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EXCEPTIONS_BY_LENGTH,
|
|
3
|
+
SCHOOL_FLUFF_VOCABULARY,
|
|
4
|
+
isFluffWord2,
|
|
5
|
+
trailingFluffRun2,
|
|
6
|
+
joinedPrefix2,
|
|
7
|
+
isInstitutionWord2,
|
|
8
|
+
INSTITUTION_PHRASES2,
|
|
9
|
+
GLUED_INSTITUTION_SUFFIXES2,
|
|
10
|
+
truncatedInstitution2,
|
|
11
|
+
foldSchoolName2
|
|
12
|
+
} from "./chunks/place-1mpcshk8.js";
|
|
13
|
+
import"./chunks/place-tcgfvemw.js";
|
|
14
|
+
import {
|
|
15
|
+
AMBIGUOUS_PRINTS2,
|
|
16
|
+
PLACE_NODES2,
|
|
17
|
+
NEVER_NAME,
|
|
18
|
+
printZones2,
|
|
19
|
+
opensLocation2,
|
|
20
|
+
place2
|
|
21
|
+
} from "./chunks/place-c5g25pym.js";
|
|
22
|
+
var INSTITUTION_TOKENS = new Map([
|
|
23
|
+
["academy", "academy"],
|
|
24
|
+
["school", "school"],
|
|
25
|
+
["scoil", "scoilrince"],
|
|
26
|
+
["rince", "scoilrince"],
|
|
27
|
+
["institute", "institute"],
|
|
28
|
+
["company", "company"],
|
|
29
|
+
["studio", "studio"],
|
|
30
|
+
["center", "center"],
|
|
31
|
+
["centre", "center"]
|
|
32
|
+
]);
|
|
33
|
+
var SCHOOL_FLUFF_TOKENS = new Set([...SCHOOL_FLUFF_VOCABULARY.values()].filter((entry) => entry.tokenFluff).map((entry) => entry.canonical));
|
|
34
|
+
function canonicalPlace(token) {
|
|
35
|
+
const read = place2(token, { declared: true });
|
|
36
|
+
if (read.pl3 !== "")
|
|
37
|
+
return read.pl3;
|
|
38
|
+
if (!read.isAmbiguous())
|
|
39
|
+
return;
|
|
40
|
+
const ids = read.arm === "ambiguous" ? read.candidates.map((c) => c.pl3).filter((id) => id !== "") : [];
|
|
41
|
+
return ids.length === 0 ? undefined : `${[...ids].sort().join("|")}?`;
|
|
42
|
+
}
|
|
43
|
+
function canonicalRun(words) {
|
|
44
|
+
return words.length === 1 ? canonicalPlace(words[0]) : canonicalPlace(words.join(" "));
|
|
45
|
+
}
|
|
46
|
+
var SR_PHRASE = "s r";
|
|
47
|
+
function schoolTokens(raw) {
|
|
48
|
+
const folded = foldSchoolName2(raw);
|
|
49
|
+
if (folded === "")
|
|
50
|
+
return [];
|
|
51
|
+
const phrased = applyPhraseExceptions(folded.split(" "));
|
|
52
|
+
const marked = markPlaces(phrased, printZones2(raw));
|
|
53
|
+
const core = marked.filter((t) => typeof t === "string").join(" ");
|
|
54
|
+
const resolved = applyLabelExceptions(marked, core);
|
|
55
|
+
const tokens = resolved.map((t) => {
|
|
56
|
+
if (typeof t !== "string")
|
|
57
|
+
return t;
|
|
58
|
+
const institution = INSTITUTION_TOKENS.get(t);
|
|
59
|
+
if (institution)
|
|
60
|
+
return { text: t, class: "INSTITUTION_TYPE", institution };
|
|
61
|
+
if (SCHOOL_FLUFF_TOKENS.has(t))
|
|
62
|
+
return { text: t, class: "FLUFF" };
|
|
63
|
+
if (t.length <= 2)
|
|
64
|
+
return { text: t, class: "FLUFF", short: true };
|
|
65
|
+
return { text: t, class: "NAME_PART" };
|
|
66
|
+
});
|
|
67
|
+
promoteScoilRince(tokens);
|
|
68
|
+
if (!tokens.some((t) => t.class === "NAME_PART")) {
|
|
69
|
+
const isInitials = (t) => t.short === true && !NEVER_NAME.has(t.text);
|
|
70
|
+
const initials = tokens.some(isInitials);
|
|
71
|
+
for (const t of tokens)
|
|
72
|
+
if (initials ? isInitials(t) : t.class === "LOCATION_HINT") {
|
|
73
|
+
t.class = "NAME_PART";
|
|
74
|
+
t.promoted = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return tokens;
|
|
78
|
+
}
|
|
79
|
+
function markPlaces(input, at) {
|
|
80
|
+
const out = [...input];
|
|
81
|
+
for (let width = out.length;width >= 1; width--)
|
|
82
|
+
for (let i = 0;i + width <= out.length; i++) {
|
|
83
|
+
const slice = out.slice(i, i + width);
|
|
84
|
+
if (slice.some((t) => typeof t !== "string"))
|
|
85
|
+
continue;
|
|
86
|
+
const words = slice;
|
|
87
|
+
if (!at.qualifierAny.has(words[words.length - 1]))
|
|
88
|
+
continue;
|
|
89
|
+
if (!words.every((w) => opensLocation2(w, at)))
|
|
90
|
+
continue;
|
|
91
|
+
const canonical = canonicalRun(words);
|
|
92
|
+
if (canonical === undefined)
|
|
93
|
+
continue;
|
|
94
|
+
out.splice(i, width, { text: words.join(" "), class: "LOCATION_HINT", place: canonical });
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
function applyPhraseExceptions(words) {
|
|
99
|
+
let out = [...words];
|
|
100
|
+
for (;; ) {
|
|
101
|
+
let hitAt = -1;
|
|
102
|
+
let hitEx;
|
|
103
|
+
for (const ex of EXCEPTIONS_BY_LENGTH) {
|
|
104
|
+
if (ex.scope !== "phrase")
|
|
105
|
+
continue;
|
|
106
|
+
const at = indexOfRun(out, ex.phrase.split(" "));
|
|
107
|
+
if (at < 0)
|
|
108
|
+
continue;
|
|
109
|
+
hitAt = at;
|
|
110
|
+
hitEx = ex;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
if (!hitEx || hitAt < 0)
|
|
114
|
+
return out;
|
|
115
|
+
const token = { text: hitEx.token, class: hitEx.as, exception: hitEx.phrase };
|
|
116
|
+
out = [...out.slice(0, hitAt), token, ...out.slice(hitAt + hitEx.phrase.split(" ").length)];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function applyLabelExceptions(marked, core) {
|
|
120
|
+
if (marked.some((t) => typeof t !== "string" && t.class === "NAME_PART"))
|
|
121
|
+
return [...marked];
|
|
122
|
+
for (const ex of EXCEPTIONS_BY_LENGTH) {
|
|
123
|
+
if (ex.scope !== "label" || core !== ex.phrase)
|
|
124
|
+
continue;
|
|
125
|
+
const hit = { text: ex.token, class: ex.as, exception: ex.phrase };
|
|
126
|
+
return [hit, ...marked.filter((t) => typeof t !== "string")];
|
|
127
|
+
}
|
|
128
|
+
return [...marked];
|
|
129
|
+
}
|
|
130
|
+
function indexOfRun(marked, words) {
|
|
131
|
+
outer:
|
|
132
|
+
for (let i = 0;i + words.length <= marked.length; i++) {
|
|
133
|
+
for (let j = 0;j < words.length; j++)
|
|
134
|
+
if (marked[i + j] !== words[j])
|
|
135
|
+
continue outer;
|
|
136
|
+
return i;
|
|
137
|
+
}
|
|
138
|
+
return -1;
|
|
139
|
+
}
|
|
140
|
+
function promoteScoilRince(tokens) {
|
|
141
|
+
for (let i = 0;i + 1 < tokens.length; i++) {
|
|
142
|
+
const a = tokens[i];
|
|
143
|
+
const b = tokens[i + 1];
|
|
144
|
+
if (!a || !b)
|
|
145
|
+
continue;
|
|
146
|
+
if (`${a.text} ${b.text}` !== SR_PHRASE)
|
|
147
|
+
continue;
|
|
148
|
+
tokens.splice(i, 2, { text: "sr", class: "INSTITUTION_TYPE", institution: "scoilrince" });
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function promotedKey(raw) {
|
|
153
|
+
const parts = schoolTokens(raw).filter((t) => t.class === "NAME_PART");
|
|
154
|
+
return parts.length > 0 && parts.every((t) => t.promoted === true);
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
AMBIGUOUS_PRINTS2 as AMBIGUOUS_PRINTS,
|
|
158
|
+
GLUED_INSTITUTION_SUFFIXES2 as GLUED_INSTITUTION_SUFFIXES,
|
|
159
|
+
INSTITUTION_PHRASES2 as INSTITUTION_PHRASES,
|
|
160
|
+
PLACE_NODES2 as PLACE_NODES,
|
|
161
|
+
isFluffWord2 as isFluffWord,
|
|
162
|
+
isInstitutionWord2 as isInstitutionWord,
|
|
163
|
+
joinedPrefix2 as joinedPrefix,
|
|
164
|
+
opensLocation2 as opensLocation,
|
|
165
|
+
printZones2 as printZones,
|
|
166
|
+
promotedKey,
|
|
167
|
+
schoolTokens,
|
|
168
|
+
trailingFluffRun2 as trailingFluffRun,
|
|
169
|
+
truncatedInstitution2 as truncatedInstitution
|
|
170
|
+
};
|
package/dist/place.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
placeFromId2,
|
|
12
12
|
placeWindows2,
|
|
13
13
|
placeParts2,
|
|
14
|
+
ownRegionCountries2,
|
|
14
15
|
oireachtasOfRegion2,
|
|
15
16
|
regionOfOireachtas2,
|
|
16
17
|
placeStats2,
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
placesRelation2,
|
|
20
21
|
probablySamePlace2,
|
|
21
22
|
sameReading2
|
|
22
|
-
} from "./chunks/place-
|
|
23
|
+
} from "./chunks/place-c5g25pym.js";
|
|
23
24
|
import"./chunks/place-tcgfvemw.js";
|
|
24
25
|
export {
|
|
25
26
|
DEFAULT_PLACE_CAPACITY2 as DEFAULT_PLACE_CAPACITY,
|
|
@@ -31,6 +32,7 @@ export {
|
|
|
31
32
|
genericKey2 as genericKey,
|
|
32
33
|
isPlaceToken2 as isPlaceToken,
|
|
33
34
|
oireachtasOfRegion2 as oireachtasOfRegion,
|
|
35
|
+
ownRegionCountries2 as ownRegionCountries,
|
|
34
36
|
place2 as place,
|
|
35
37
|
placeFromId2 as placeFromId,
|
|
36
38
|
placeParts2 as placeParts,
|