diff --git a/scrape/utils/parseAbsence.js b/scrape/utils/parseAbsence.js index f4f7529..0bf037e 100644 --- a/scrape/utils/parseAbsence.js +++ b/scrape/utils/parseAbsence.js @@ -116,6 +116,28 @@ export default function parseAbsence(input, teacherMap = {}) { markConsumed(matchStart, matchEnd); } + // 1a. Teachers with "-startHour-exk" suffix (e.g. "Sv-5-exk") + const teacherStartExkRe = /([A-Za-z]+)-(\d+)-exk/gi; + while ((m = teacherStartExkRe.exec(s)) !== null) { + const matchStart = m.index; + const matchEnd = teacherStartExkRe.lastIndex; + if (isConsumed(matchStart)) continue; + + const teacherCode = m[1]; + const from = Number(m[2]); + const { name } = resolveTeacher(teacherCode, teacherMap); + + if (from >= 1 && from <= LAST_HOUR) { + results.push({ + teacher: name, + teacherCode: teacherCode.toLowerCase(), + type: "exkurze", + hours: { from, to: LAST_HOUR }, + }); + markConsumed(matchStart, matchEnd); + } + } + // 2. Teachers with "-exk" suffix const teacherExkRe = /([A-Za-z]+)-exk/gi; while ((m = teacherExkRe.exec(s)) !== null) { diff --git a/tests/test.js b/tests/test.js index ac0e3cb..d42e557 100644 --- a/tests/test.js +++ b/tests/test.js @@ -248,6 +248,15 @@ test("Vc 1. h", [ }, ]); +test("Sv-5-exk", [ + { + teacher: "Ing. Jan Šváb", + teacherCode: "sv", + type: "exkurze", + hours: { from: 5, to: 10 }, + }, +]); + function test(input, expectedOutput) { const res = parseAbsence(input, teachermap);