feat: Update parser to handle lesson type after teacher's name and add corresponding tests
This commit is contained in:
@@ -10,7 +10,7 @@ import { parseWeekRanges, parseTextDates, DATE_LIST, weekday } from "../shared/w
|
||||
import { roomMoves, onlyPlace, weekPlan, partsByWeek } from "./rooms.js";
|
||||
import { placeNote, lessonPlace, placeOf } from "./places.js";
|
||||
const run = promisify(execFile);
|
||||
export const PARSER_VERSION = 17;
|
||||
export const PARSER_VERSION = 18;
|
||||
const days = [
|
||||
"понедельник",
|
||||
"вторник",
|
||||
@@ -98,8 +98,11 @@ export function details(text) {
|
||||
rest.match(/\b(\d{2,3}\s*[А-Яа-я]?)\s*$/u) ||
|
||||
// A room with a name instead of a number: "ауд.Медиа".
|
||||
rest.match(/(?:ауд\.\s*)([А-ЯЁ][а-яё]{2,})(?![а-яё])/u);
|
||||
// "Русский язык как иностранный Козыренко А.Н.(п.з.) ауд.100": the kind may follow the
|
||||
// teacher, and the name ends where the first of them begins.
|
||||
const end = [kind?.index, person?.index].filter((i) => i != null);
|
||||
let subject = (named ? named[1].trim() : rest
|
||||
.slice(0, kind?.index ?? person?.index ?? room?.index ?? rest.length))
|
||||
.slice(0, end.length ? Math.min(...end) : room?.index ?? rest.length))
|
||||
.trim()
|
||||
.replace(/[–—,\-]+$/, "")
|
||||
.trim();
|
||||
|
||||
Reference in New Issue
Block a user