Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
KItinerary
Commits
e67baf90
Commit
e67baf90
authored
Oct 26, 2020
by
Volker Krause
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract English SNCF tickets
parent
06d1c155
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
src/extractors/sncf.js
src/extractors/sncf.js
+8
-8
No files found.
src/extractors/sncf.js
View file @
e67baf90
...
...
@@ -19,11 +19,11 @@
function
parseText
(
text
)
{
var
reservations
=
new
Array
();
var
bookingRef
=
text
.
match
(
/DOSSIER VOYAGE : +
([
A-Z0-9
]{6})
/
);
var
bookingRef
=
text
.
match
(
/
(?:
DOSSIER VOYAGE
|BOOKING FILE REFERENCE
)
: +
([
A-Z0-9
]{6})
/
);
var
pos
=
0
;
while
(
true
)
{
var
header
=
text
.
substr
(
pos
).
match
(
/ +Départ
\/
Arrivée.*
\n
/
);
var
header
=
text
.
substr
(
pos
).
match
(
/ +
(?:
Départ
\/
Arrivée
|Departure
\/
Arrival
)
.*
\n
/
);
if
(
!
header
)
break
;
var
index
=
header
.
index
+
header
[
0
].
length
;
...
...
@@ -31,14 +31,14 @@ function parseText(text) {
var
res
=
JsonLd
.
newTrainReservation
();
res
.
reservationNumber
=
bookingRef
[
1
];
var
depLine
=
text
.
substr
(
pos
+
index
).
match
(
/
\n
{2,3}([\w
-
]
+
?)
+
(\d{2}\/\d{2})
à
(\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
"
);
var
arrLine
=
text
.
substr
(
pos
+
index
).
match
(
/
\n
{2,3}([\w
-
]
+
?)
+
(\d{2}\/\d{2})
à
(\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
;
...
...
@@ -49,13 +49,13 @@ function parseText(text) {
// since the stations are vertically centered, the stuff we are looking for might be at different
// positions relative to them
var
legText
=
text
.
substring
(
pos
+
header
.
index
+
header
[
0
].
length
,
pos
+
index
);
var
trainNumber
=
legText
.
match
(
/TRAIN
N°
?(\d{3,
4
})
/
);
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
(\d
+
)
/
);
if
(
seatRes
)
{
res
.
reservedTicket
.
ticketedSeat
.
seatSection
=
seatRes
[
2
];
res
.
reservedTicket
.
ticketedSeat
.
seatNumber
=
seatRes
[
3
];
res
.
reservedTicket
.
ticketedSeat
.
seatSection
=
seatRes
[
1
];
res
.
reservedTicket
.
ticketedSeat
.
seatNumber
=
seatRes
[
2
];
}
reservations
.
push
(
res
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment