Refactor text normalization in worshipController.js: Rename normalizeText to normalizeForMatch for clarity and update all references to ensure consistent text processing across various functions, enhancing code readability and maintainability.
All checks were successful
Deploy miriamgemeinde / deploy (push) Successful in 7s
All checks were successful
Deploy miriamgemeinde / deploy (push) Successful in 7s
This commit is contained in:
@@ -1825,7 +1825,7 @@ function getSection(lines, startPredicate, endPredicates = []) {
|
|||||||
return lines.slice(start, end);
|
return lines.slice(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeText(input) {
|
function normalizeForMatch(input) {
|
||||||
return String(input || '')
|
return String(input || '')
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/ä/g, 'ae')
|
.replace(/ä/g, 'ae')
|
||||||
@@ -1837,8 +1837,8 @@ function normalizeText(input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isHeading(line, heading) {
|
function isHeading(line, heading) {
|
||||||
const normalizedLine = normalizeText(line).replace(/[:\-–]\s*$/g, '');
|
const normalizedLine = normalizeForMatch(line).replace(/[:\-–]\s*$/g, '');
|
||||||
const normalizedHeading = normalizeText(heading).replace(/[:\-–]\s*$/g, '');
|
const normalizedHeading = normalizeForMatch(heading).replace(/[:\-–]\s*$/g, '');
|
||||||
return (
|
return (
|
||||||
normalizedLine === normalizedHeading ||
|
normalizedLine === normalizedHeading ||
|
||||||
normalizedLine.startsWith(`${normalizedHeading} `) ||
|
normalizedLine.startsWith(`${normalizedHeading} `) ||
|
||||||
@@ -1902,7 +1902,7 @@ function buildDetailedItems(lines) {
|
|||||||
};
|
};
|
||||||
const expandedLines = lines.flatMap(splitForYouthAnchors);
|
const expandedLines = lines.flatMap(splitForYouthAnchors);
|
||||||
const isHardSectionBoundary = (line) => {
|
const isHardSectionBoundary = (line) => {
|
||||||
const n = normalizeText(line);
|
const n = normalizeForMatch(line);
|
||||||
if (!n) return false;
|
if (!n) return false;
|
||||||
return (
|
return (
|
||||||
n.startsWith('besondere gottesdienste und veranstaltungen') ||
|
n.startsWith('besondere gottesdienste und veranstaltungen') ||
|
||||||
@@ -1987,7 +1987,7 @@ function buildDetailedItems(lines) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isNoiseLine(line) {
|
function isNoiseLine(line) {
|
||||||
const n = normalizeText(line);
|
const n = normalizeForMatch(line);
|
||||||
return (
|
return (
|
||||||
n.includes('impressum') ||
|
n.includes('impressum') ||
|
||||||
n.includes('redaktionsschluss') ||
|
n.includes('redaktionsschluss') ||
|
||||||
@@ -2064,7 +2064,7 @@ function extractRegularTermineDetails(lines) {
|
|||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
const isAnchorLine = (line) => anchors.some((r) => r.test(line));
|
const isAnchorLine = (line) => anchors.some((r) => r.test(line));
|
||||||
const isSubHeadingLike = (line) => {
|
const isSubHeadingLike = (line) => {
|
||||||
const t = normalizeText(line);
|
const t = normalizeForMatch(line);
|
||||||
return (
|
return (
|
||||||
/^kinder und jugendliche$/.test(t) ||
|
/^kinder und jugendliche$/.test(t) ||
|
||||||
/^kinder und jugend$/.test(t) ||
|
/^kinder und jugend$/.test(t) ||
|
||||||
@@ -2120,7 +2120,7 @@ function isLikelyDayNameLine(line) {
|
|||||||
if (!line) return false;
|
if (!line) return false;
|
||||||
if (hasDateOrTime(line)) return false;
|
if (hasDateOrTime(line)) return false;
|
||||||
if (looksLikeHeading(line)) return false;
|
if (looksLikeHeading(line)) return false;
|
||||||
const t = normalizeText(line);
|
const t = normalizeForMatch(line);
|
||||||
return (
|
return (
|
||||||
/advent|trinitatis|epiphanias|ostern|pfingsten|sonntag|montag|dienstag|mittwoch|donnerstag|freitag|samstag/.test(t) &&
|
/advent|trinitatis|epiphanias|ostern|pfingsten|sonntag|montag|dienstag|mittwoch|donnerstag|freitag|samstag/.test(t) &&
|
||||||
t.length < 80
|
t.length < 80
|
||||||
@@ -2229,7 +2229,7 @@ function extractWorshipBlocks(lines) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildEventSignature(line) {
|
function buildEventSignature(line) {
|
||||||
const text = normalizeText(line);
|
const text = normalizeForMatch(line);
|
||||||
const anchorPatterns = [
|
const anchorPatterns = [
|
||||||
/kinderkirche/,
|
/kinderkirche/,
|
||||||
/kigosabo|kindergottesdienst/,
|
/kigosabo|kindergottesdienst/,
|
||||||
|
|||||||
Reference in New Issue
Block a user