This commit is contained in:
@@ -157,9 +157,14 @@ class PDFParserService {
|
||||
let guestFromColumns = null;
|
||||
let codeFromColumns = null;
|
||||
|
||||
if (columnSegments && columnSegments.length >= 3) {
|
||||
homeFromColumns = columnSegments[1]?.trim() || null;
|
||||
guestFromColumns = columnSegments[2]?.trim() || null;
|
||||
if (columnSegments && columnSegments.length >= 4) {
|
||||
// In the nuLiga code table the two team columns follow the time.
|
||||
// Do not rely on fixed offsets: the weekday is a separate PDF item.
|
||||
const timeColumnIndex = columnSegments.findIndex((segment) => /\b\d{1,2}:\d{2}\b/.test(segment));
|
||||
if (timeColumnIndex >= 0) {
|
||||
homeFromColumns = columnSegments[timeColumnIndex + 1]?.trim() || null;
|
||||
guestFromColumns = columnSegments[timeColumnIndex + 2]?.trim() || null;
|
||||
}
|
||||
const lastSegment = columnSegments[columnSegments.length - 1];
|
||||
if (lastSegment) {
|
||||
const candidateCode = lastSegment.replace(/\s+/g, '').trim();
|
||||
@@ -255,6 +260,25 @@ class PDFParserService {
|
||||
teamsPart = teamsPart.replace(new RegExp(`${code}$`), '').trim();
|
||||
}
|
||||
|
||||
// A layout-aware extraction has already identified the team
|
||||
// columns unambiguously. Use them directly instead of trying
|
||||
// to reconstruct column boundaries from the flattened text.
|
||||
// This also preserves names with characters such as "ä".
|
||||
if (code && homeFromColumns && guestFromColumns) {
|
||||
matches.push({
|
||||
date: date,
|
||||
time: time,
|
||||
homeTeamName: homeFromColumns,
|
||||
guestTeamName: guestFromColumns,
|
||||
code: code,
|
||||
homePin: null,
|
||||
guestPin: null,
|
||||
clubId: clubId,
|
||||
rawLine: line
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code || pinMatch) {
|
||||
|
||||
|
||||
@@ -831,8 +855,10 @@ class PDFParserService {
|
||||
return;
|
||||
}
|
||||
|
||||
const [scaleX, , , , x, y] = item.transform;
|
||||
const width = (item.width || 0) * (scaleX || 1);
|
||||
const [, , , , x, y] = item.transform;
|
||||
// PDF.js already reports item.width in page coordinates. Applying
|
||||
// the text scale again turns separate table columns into one line.
|
||||
const width = item.width || 0;
|
||||
|
||||
let targetLine = pageLines.find((line) => Math.abs(line.y - y) < lineTolerance);
|
||||
if (!targetLine) {
|
||||
|
||||
Reference in New Issue
Block a user