KItinerary
extractorpostprocessor.cpp
205 // standardize on the BCBP booking reference, not some secondary one we might have in structured data for example
225TrainReservation ExtractorPostprocessorPrivate::processTrainReservation(TrainReservation res) const
239 trip.setDepartureTime(processTrainTripTime(trip.departureTime(), trip.departureDay(), trip.departureStation()));
240 trip.setArrivalTime(processTrainTripTime(trip.arrivalTime(), trip.departureDay(), trip.arrivalStation()));
244 // arrival less than a day before departure is an indication of the extractor failing to detect day rollover
246 if (duration < 0 && duration > -3600*24 && trip.departureTime().timeSpec() == trip.arrivalTime().timeSpec()) {
283 const auto record = KnowledgeDb::stationForSncfStationId(KnowledgeDb::SncfStationId{id.mid(5)});
289 const auto country = KnowledgeDb::countryIdForUicCode(QStringView(id).mid(5, 2).toUShort()) .toString();
294 const auto country = KnowledgeDb::countryIdForUicCode(QStringView(id).mid(4, 2).toUShort()) .toString();
300 const auto record = KnowledgeDb::stationForBenerailId(KnowledgeDb::BenerailStationId(id.mid(9)));
304 const auto record = KnowledgeDb::stationForVRStationCode(KnowledgeDb::VRStationCode(id.mid(5)));
315 const auto record = KnowledgeDb::stationForAmtrakStationCode(KnowledgeDb::AmtrakStationCode(QStringView(id).mid(7)));
318 const auto record = KnowledgeDb::stationForViaRailStationCode(KnowledgeDb::ViaRailStationCode(QStringView(id).mid(4)));
321 const auto record = KnowledgeDb::stationForUkRailwayStationCode(KnowledgeDb::UKRailwayStationCode(QStringView(id).mid(3)));
328QDateTime ExtractorPostprocessorPrivate::processTrainTripTime(QDateTime dt, QDate departureDay, const TrainStation& station) const
334 if (dt.date().year() <= 1970 && departureDay.isValid()) { // we just have the time, but not the day
371 trip.setDepartureTime(processTimeForLocation(trip.departureTime(), trip.departureBoatTerminal()));
374 // arrival less than a day before departure is an indication of the extractor failing to detect day rollover
383LodgingReservation ExtractorPostprocessorPrivate::processLodgingReservation(LodgingReservation res) const
387 res.setCheckinTime(processTimeForLocation(res.checkinTime(), res.reservationFor().value<LodgingBusiness>()));
388 res.setCheckoutTime(processTimeForLocation(res.checkoutTime(), res.reservationFor().value<LodgingBusiness>()));
400RentalCarReservation ExtractorPostprocessorPrivate::processRentalCarReservation(RentalCarReservation res) const
418FoodEstablishmentReservation ExtractorPostprocessorPrivate::processFoodEstablishmentReservation(FoodEstablishmentReservation res) const
422 res.setStartTime(processTimeForLocation(res.startTime(), res.reservationFor().value<FoodEstablishment>()));
423 res.setEndTime(processTimeForLocation(res.endTime(), res.reservationFor().value<FoodEstablishment>()));
428TouristAttractionVisit ExtractorPostprocessorPrivate::processTouristAttractionVisit(TouristAttractionVisit visit) const
432 visit.setDepartureTime(processTimeForLocation(visit.departureTime(), visit.touristAttraction()));
436EventReservation ExtractorPostprocessorPrivate::processEventReservation(EventReservation res) const
469 if (currency.size() != 3 || !std::all_of(currency.begin(), currency.end(), [](QChar c) { return c.isUpper(); })) {
485ProgramMembership ExtractorPostprocessorPrivate::processProgramMembership(ProgramMembership program) const
488 if (const auto name = program.programName(); std::none_of(name.begin(), name.end(), [](QChar c) { return c.isLetter(); })) {
493 // avoid emitting spurious empty ProgramMembership objects caused by empty elements in JSON-LD/Microdata input
564 if ((person.name().isEmpty() || person.name() == person.familyName() || person.name() == person.givenName())
573PostalAddress ExtractorPostprocessorPrivate::processAddress(PostalAddress addr, const QString &phoneNumber, const GeoCoordinates &geo)
610 if (util->ParseAndKeepRawInput(phoneStr, "ZZ", &number) == i18n::phonenumbers::PhoneNumberUtil::NO_PARSING_ERROR) {
634QString ExtractorPostprocessorPrivate::processPhoneNumber(const QString &phoneNumber, const PostalAddress &addr)
643 if (util->ParseAndKeepRawInput(phoneStr, isoCode, &number) == i18n::phonenumbers::PhoneNumberUtil::NO_PARSING_ERROR) {
644 if (number.country_code_source() == i18n::phonenumbers::PhoneNumber_CountryCodeSource_FROM_DEFAULT_COUNTRY) {
688 const auto isDuplicate = action.target() == prevUrl && (prevType ? strcmp(prevType, (*it).typeName()) == 0 : false);
702QDateTime ExtractorPostprocessorPrivate::processTimeForLocation(QDateTime dt, const T &place) const
708 if (KnowledgeDb::isPlausibleTimeZone(dt.timeZone(), place.geo().latitude(), place.geo().longitude(), place.address().addressCountry(), place.address().addressRegion())) {
715 const auto tz = KnowledgeDb::timezoneForLocation(place.geo().latitude(), place.geo().longitude(), place.address().addressCountry(), place.address().addressRegion());
722 qCDebug(Log) << "UTC offset clashes with expected timezone!" << dt << dt.offsetFromUtc() << tz.id() << tz.offsetFromUtc(dt);
728 } else if (dt.timeSpec() == Qt::UTC || (dt.timeSpec() == Qt::TimeZone && dt.timeZone() == QTimeZone::utc())) {
static KCountry fromLocation(float latitude, float longitude)
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:175
QList< QVariant > result() const
This returns the final result of all previously executed processing steps followed by sorting and fil...
Definition extractorpostprocessor.cpp:116
void setValidationEnabled(bool validate)
Enable or disable validation.
Definition extractorpostprocessor.cpp:180
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:67
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
QStringView country(QStringView ifopt)
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
iterator begin()
iterator end()
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 Jan 24 2025 11:52:35 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:52:35 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.