@finbheara/domain 0.25.0 → 0.26.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/school.js +31 -0
- package/package.json +1 -1
package/dist/school.js
CHANGED
|
@@ -1530,6 +1530,36 @@ function createSchoolNameReader(options = {}) {
|
|
|
1530
1530
|
token.cls = "NAME_PART";
|
|
1531
1531
|
}
|
|
1532
1532
|
}
|
|
1533
|
+
function guardShortSuffixInstitutions(tokens) {
|
|
1534
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
1535
|
+
const token = tokens[i];
|
|
1536
|
+
if (token === undefined || token.cls !== "INSTITUTION_TYPE")
|
|
1537
|
+
continue;
|
|
1538
|
+
if (schoolInstitution(token.text)?.position !== "suffix")
|
|
1539
|
+
continue;
|
|
1540
|
+
if (token.text.replaceAll(" ", "").length > 2)
|
|
1541
|
+
continue;
|
|
1542
|
+
const named = (t) => t.cls === "NAME_PART";
|
|
1543
|
+
if (tokens.slice(0, i).some(named) && !tokens.slice(i + 1).some(named))
|
|
1544
|
+
continue;
|
|
1545
|
+
const back = token.words.map((w) => ({
|
|
1546
|
+
text: token.words.length === 1 ? token.text : foldSchoolName(w.printed),
|
|
1547
|
+
words: [w],
|
|
1548
|
+
cls: null
|
|
1549
|
+
}));
|
|
1550
|
+
for (const t of back) {
|
|
1551
|
+
if (isFluffWord(t.text))
|
|
1552
|
+
t.cls = "FLUFF";
|
|
1553
|
+
else if (t.text.length <= 2) {
|
|
1554
|
+
t.cls = "FLUFF";
|
|
1555
|
+
t.short = true;
|
|
1556
|
+
} else
|
|
1557
|
+
t.cls = "NAME_PART";
|
|
1558
|
+
}
|
|
1559
|
+
tokens.splice(i, 1, ...back);
|
|
1560
|
+
i += back.length - 1;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1533
1563
|
function eatTruncatedTail(tokens) {
|
|
1534
1564
|
let ate = false;
|
|
1535
1565
|
const names = new Set(tokens.filter((t) => t.cls === "NAME_PART").map((t) => t.text));
|
|
@@ -1862,6 +1892,7 @@ function createSchoolNameReader(options = {}) {
|
|
|
1862
1892
|
applyLabelExceptions(tokens);
|
|
1863
1893
|
classifyWords(tokens);
|
|
1864
1894
|
guardPrefixInstitutions(tokens);
|
|
1895
|
+
guardShortSuffixInstitutions(tokens);
|
|
1865
1896
|
const declared = applyDeclaredInitialism(tokens);
|
|
1866
1897
|
const truncated = eatTruncatedTail(tokens);
|
|
1867
1898
|
const promoted = promote(tokens);
|
package/package.json
CHANGED