KItinerary
extractorpostprocessor.cpp
216 // standardize on the BCBP booking reference, not some secondary one we might have in structured data for example
236TrainReservation ExtractorPostprocessorPrivate::processTrainReservation(TrainReservation res) const
250 trip.setDepartureTime(processTripTime(trip.departureTime(), trip.departureDay(), trip.departureStation()));
251 trip.setArrivalTime(processTripTime(trip.arrivalTime(), trip.departureDay(), trip.arrivalStation()));
255 // arrival less than a day before departure is an indication of the extractor failing to detect day rollover
257 if (duration < 0 && duration > -3600*24 && trip.departureTime().timeSpec() == trip.arrivalTime().timeSpec()) {
297 const auto record = KnowledgeDb::stationForSncfStationId(KnowledgeDb::SncfStationId{id.mid(5)});
303 const auto country = KnowledgeDb::countryIdForUicCode(QStringView(id).mid(5, 2).toUShort()) .toString();
308 const auto country = KnowledgeDb::countryIdForUicCode(QStringView(id).mid(4, 2).toUShort()) .toString();
314 const auto record = KnowledgeDb::stationForBenerailId(KnowledgeDb::BenerailStationId(id.mid(9)));
318 const auto record = KnowledgeDb::stationForVRStationCode(KnowledgeDb::VRStationCode(id.mid(5)));
329 const auto record = KnowledgeDb::stationForAmtrakStationCode(KnowledgeDb::AmtrakStationCode(QStringView(id).mid(7)));
332 const auto record = KnowledgeDb::stationForViaRailStationCode(KnowledgeDb::ViaRailStationCode(QStringView(id).mid(4)));
335 const auto record = KnowledgeDb::stationForUkRailwayStationCode(KnowledgeDb::UKRailwayStationCode(QStringView(id).mid(3)));
343QDateTime ExtractorPostprocessorPrivate::processTripTime(QDateTime dt, QDate departureDay, const T& place) const
349 if (dt.date().year() <= 1970 && departureDay.isValid()) { // we just have the time, but not the day
367 trip.setDepartureTime(processTripTime(trip.departureTime(), trip.departureDay(), trip.departureBusStop()));
368 trip.setArrivalTime(processTripTime(trip.arrivalTime(), trip.departureDay(), trip.arrivalBusStop()));
386 trip.setDepartureTime(processTimeForLocation(trip.departureTime(), trip.departureBoatTerminal()));
389 // arrival less than a day before departure is an indication of the extractor failing to detect day rollover
398LodgingReservation ExtractorPostprocessorPrivate::processLodgingReservation(LodgingReservation res) const
402 res.setCheckinTime(processTimeForLocation(res.checkinTime(), res.reservationFor().value<LodgingBusiness>()));
403 res.setCheckoutTime(processTimeForLocation(res.checkoutTime(), res.reservationFor().value<LodgingBusiness>()));
415RentalCarReservation ExtractorPostprocessorPrivate::processRentalCarReservation(RentalCarReservation res) const
433FoodEstablishmentReservation ExtractorPostprocessorPrivate::processFoodEstablishmentReservation(FoodEstablishmentReservation res) const
437 res.setStartTime(processTimeForLocation(res.startTime(), res.reservationFor().value<FoodEstablishment>()));
438 res.setEndTime(processTimeForLocation(res.endTime(), res.reservationFor().value<FoodEstablishment>()));
443TouristAttractionVisit ExtractorPostprocessorPrivate::processTouristAttractionVisit(TouristAttractionVisit visit) const
447 visit.setDepartureTime(processTimeForLocation(visit.departureTime(), visit.touristAttraction()));
451EventReservation ExtractorPostprocessorPrivate::processEventReservation(EventReservation res) const
484 if (currency.size() != 3 || !std::all_of(currency.begin(), currency.end(), [](QChar c) { return c.isUpper(); })) {
500ProgramMembership ExtractorPostprocessorPrivate::processProgramMembership(ProgramMembership program) const
503 if (const auto name = program.programName(); std::none_of(name.begin(), name.end(), [](QChar c) { return c.isLetter(); })) {
508 // avoid emitting spurious empty ProgramMembership objects caused by empty elements in JSON-LD/Microdata input
594 if ((person.name().isEmpty() || person.name() == person.familyName() || person.name() == person.givenName())
603PostalAddress ExtractorPostprocessorPrivate::processAddress(PostalAddress addr, const QString &phoneNumber, const GeoCoordinates &geo)
640 if (util->ParseAndKeepRawInput(phoneStr, "ZZ", &number) == i18n::phonenumbers::PhoneNumberUtil::NO_PARSING_ERROR) {
664QString ExtractorPostprocessorPrivate::processPhoneNumber(const QString &phoneNumber, const PostalAddress &addr)
673 if (util->ParseAndKeepRawInput(phoneStr, isoCode, &number) == i18n::phonenumbers::PhoneNumberUtil::NO_PARSING_ERROR) {
674 if (number.country_code_source() == i18n::phonenumbers::PhoneNumber_CountryCodeSource_FROM_DEFAULT_COUNTRY) {
718 const auto isDuplicate = action.target() == prevUrl && (prevType ? strcmp(prevType, (*it).typeName()) == 0 : false);
732QDateTime ExtractorPostprocessorPrivate::processTimeForLocation(QDateTime dt, const T &place) const
738 if (KnowledgeDb::isPlausibleTimeZone(dt.timeZone(), place.geo().latitude(), place.geo().longitude(), place.address().addressCountry(), place.address().addressRegion())) {
745 const auto tz = KnowledgeDb::timezoneForLocation(place.geo().latitude(), place.geo().longitude(), place.address().addressCountry(), place.address().addressRegion());
752 qCDebug(Log) << "UTC offset clashes with expected timezone!" << dt << dt.offsetFromUtc() << tz.id() << tz.offsetFromUtc(dt);
758 } else if (dt.timeSpec() == Qt::UTC || (dt.timeSpec() == Qt::TimeZone && dt.timeZone() == QTimeZone::utc())) {
static KCountry fromLocation(float latitude, float longitude)
bool isValid() const
static KCountry fromName(QStringView name)
static KCountry fromQLocale(QLocale::Country country)
QString alpha2() const
static KCountry fromAlpha3(const char *alpha3Code)
Post-process extracted data to filter out garbage and augment data from other sources.
Definition extractorpostprocessor.h:62
void setContextDate(const QDateTime &dt)
The date the reservation(s) processed here have been made, if known.
Definition extractorpostprocessor.cpp:186
QList< QVariant > result() const
This returns the final result of all previously executed processing steps followed by sorting and fil...
Definition extractorpostprocessor.cpp:125
void setValidationEnabled(bool validate)
Enable or disable validation.
Definition extractorpostprocessor.cpp:191
void process(const QList< QVariant > &data)
This will normalize and augment the given data elements and merge them with already added data elemen...
Definition extractorpostprocessor.cpp:68
Food-related business (such as a restaurant, or a bakery).
Definition organization.h:94
static void writeProperty(QVariant &obj, const char *name, const QVariant &value)
Set property name on object obj to value value.
Definition jsonlddocument.cpp:538
static QVariant apply(const QVariant &lhs, const QVariant &rhs)
Apply all properties of rhs on to lhs.
Definition jsonlddocument.cpp:564
static QVariant readProperty(const QVariant &obj, const char *name)
Read property name on object obj.
Definition jsonlddocument.cpp:522
static QVariant merge(const QVariant &lhs, const QVariant &rhs)
Merge the two given objects.
Definition mergeutil.cpp:764
static bool hasSameArrival(const QVariant &lhs, const QVariant &rhs)
Checks whether two transport reservation elements refer to the same arrival.
Definition mergeutil.cpp:875
static bool isSame(const QVariant &lhs, const QVariant &rhs)
Checks if two Reservation or Trip values refer to the same booking element.
Definition mergeutil.cpp:155
static bool hasSameDeparture(const QVariant &lhs, const QVariant &rhs)
Checks whether two transport reservation elements refer to the same departure.
Definition mergeutil.cpp:848
QString addressCountry
The country this address is in, as ISO 3166-1 alpha 2 code.
Definition place.h:53
A frequent traveler, bonus points or discount scheme program membership.
Definition programmembership.h:22
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
char * toString(const EngineQuery &query)
KIOCORE_EXPORT QString number(KIO::filesize_t size)
QList< QVariant > parse(const QString &message, const QDateTime &externalIssueDateTime=QDateTime())
Parses the bar coded boarding pass message message into a list of FlightReservation instances.
Definition iatabcbpparser.cpp:38
bool canConvert(const QVariant &value)
Checks if the given value can be up-cast to T.
Definition datatypes.h:31
AlphaId< UnalignedNumber< 3 >, 4 > ViaRailStationCode
Via Rail station code.
Definition stationidentifier.h:132
TrainStation stationForViaRailStationCode(ViaRailStationCode code)
Lookup train station data by Via Rail station code.
Definition trainstationdb.cpp:86
CountryId countryIdForUicCode(uint16_t uicCountryCode)
Look up country ISO code from a UIC country code.
Definition countrydb.cpp:82
TrainStation stationForUkRailwayStationCode(UKRailwayStationCode code)
Lookup train station data by UK railway station code.
Definition trainstationdb.cpp:91
TrainStation stationForIbnr(IBNR ibnr)
Lookup train station data by IBNR.
Definition trainstationdb.cpp:38
TrainStation stationForAmtrakStationCode(AmtrakStationCode code)
Lookup train station data by Amtrak station code.
Definition trainstationdb.cpp:81
AlphaId< uint16_t, 3 > UKRailwayStationCode
UK railway station code.
Definition stationidentifier.h:134
TrainStation stationForUic(UICStation uic)
Lookup train station data by UIC station id.
Definition trainstationdb.cpp:43
TrainStation stationForIndianRailwaysStationCode(const QString &code)
Lookup train station data by Indian Railways station code.
Definition trainstationdb.cpp:53
TrainStation stationForSncfStationId(SncfStationId sncfId)
Lookup train station data by SNCF station id.
Definition trainstationdb.cpp:48
KnowledgeDb::CountryId countryForAirport(IataCode iataCode)
Returns the country the airport with IATA code iataCode is in.
Definition airportdb.cpp:50
TrainStation stationForVRStationCode(VRStationCode vrStation)
Lookup train station data by VR (Finland) station code.
Definition trainstationdb.cpp:66
TrainStation stationForIataCode(IataCode iataCode)
Lookup train station data by IATA location code.
Definition trainstationdb.cpp:76
TrainStation stationForBenerailId(BenerailStationId id)
Lookup train station data by Benerail station identifier.
Definition trainstationdb.cpp:71
GeoCoordinates geo(const QVariant &location)
Returns the geo coordinates of a given location.
Definition locationutil.cpp:119
bool isBefore(const QVariant &lhs, const QVariant &rhs)
Sorting function for top-level reservation/visit/event elements.
Definition sortutil.cpp:169
QString clean(const QString &s)
Cleans up extra white spaces and XML entities from s.
Definition stringutil.cpp:154
QString simplifiedNoPlaceholder(const QString &s)
Same as QString::simplified() and dropping everything that just contains punctuation or dash characer...
Definition stringutil.cpp:209
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
KI18NLOCALEDATA_EXPORT KCountry country(const char *ianaId)
bool isValid(int year, int month, int day)
int year() const const
QDateTime addDays(qint64 ndays) const const
QDate date() const const
bool isValid() const const
int offsetFromUtc() const const
qint64 secsTo(const QDateTime &other) const const
void setDate(QDate date)
void setTimeZone(const QTimeZone &toZone)
Qt::TimeSpec timeSpec() const const
QTimeZone timeZone() const const
QDateTime toTimeZone(const QTimeZone &timeZone) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
QString fromStdString(const std::string &str)
bool isEmpty() const const
bool isNull() const const
QString left(qsizetype n) const const
QString mid(qsizetype position, qsizetype n) const const
QString simplified() const const
qsizetype size() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
std::string toStdString() const const
QString toUpper() const const
QString trimmed() const const
CaseInsensitive
TimeZone
LocalTime
QTimeZone utc()
bool isValid() const const
T value() const const
Train station entry in the station table.
Definition trainstationdb.h:48
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Mar 28 2025 11:59:49 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Mar 28 2025 11:59:49 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.