Commit 78923321 authored by Volker Krause's avatar Volker Krause
Browse files

Fix extracting English language SNCF tickets

parent 8e24da45
Pipeline #78245 passed with stage
in 10 minutes and 22 seconds
......@@ -6,7 +6,7 @@
function parseSncfPdfText(text) {
var reservations = new Array();
var bookingRef = text.match(/(?:DOSSIER VOYAGE|BOOKING FILE REFERENCE) : +([A-Z0-9]{6})/);
var bookingRef = text.match(/(?:DOSSIER VOYAGE|BOOKING FILE REFERENCE|REFERENCE NUMBER) ?: +([A-Z0-9]{6})/);
var pos = 0;
while (true) {
......@@ -18,19 +18,19 @@ function parseSncfPdfText(text) {
var res = JsonLd.newTrainReservation();
res.reservationNumber = bookingRef[1];
var depLine = text.substr(pos + index).match(/\n {2,3}([\w -]+?) +(\d{2}\/\d{2}) (?:à|at) (\d{2}h\d{2})/);
var depLine = text.substr(pos + index).match(/\n {2,3}([\w -]+?) +(\d{2}\/\d{2}) (?:à|at) (\d{2}[h:]\d{2})/);
if (!depLine)
break;
index += depLine.index + depLine[0].length;
res.reservationFor.departureStation.name = depLine[1];
res.reservationFor.departureTime = JsonLd.toDateTime(depLine[2] + " " + depLine[3], "dd/MM hh'h'mm", "fr");
res.reservationFor.departureTime = JsonLd.toDateTime(depLine[2] + " " + depLine[3], ["dd/MM hh'h'mm", "dd/MM hh:mm"], "fr");
var arrLine = text.substr(pos + index).match(/\n {2,3}([\w -]+?) +(\d{2}\/\d{2}) (?:à|at) (\d{2}h\d{2})/);
var arrLine = text.substr(pos + index).match(/\n {2,3}([\w -]+?) +(\d{2}\/\d{2}) (?:à|at) (\d{2}[h:]\d{2})/);
if (!arrLine)
break;
index += arrLine.index + arrLine[0].length;
res.reservationFor.arrivalStation.name = arrLine[1];
res.reservationFor.arrivalTime = JsonLd.toDateTime(arrLine[2] + " " + arrLine[3], "dd/MM hh'h'mm", "fr");
res.reservationFor.arrivalTime = JsonLd.toDateTime(arrLine[2] + " " + arrLine[3], ["dd/MM hh'h'mm", "dd/MM hh:mm"], "fr");
// parse seat, train number, etc from the text for one leg
// since the stations are vertically centered, the stuff we are looking for might be at different
......@@ -39,7 +39,7 @@ function parseSncfPdfText(text) {
var trainNumber = legText.match(/TRAIN (?:N°|NUMBER) ?(\d{3,5})/);
if (trainNumber)
res.reservationFor.trainNumber = trainNumber[1];
var seatRes = legText.match(/(?:VOITURE|COACH) (\d+) - PLACE (\d+)/);
var seatRes = legText.match(/(?:VOITURE|COACH) (\d+) - (?:PLACE|SEAT) (\d+)/);
if (seatRes) {
res.reservedTicket.ticketedSeat.seatSection = seatRes[1];
res.reservedTicket.ticketedSeat.seatNumber = seatRes[2];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment