#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_WIKIPEDIA_SERVICE_H_ #define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_WIKIPEDIA_SERVICE_H_ /** * @file services/wikipedia_service.h * @brief Wikipedia summary retrieval service with in-memory caching. */ #include #include #include #include #include "services/enrichment/enrichment_service.h" #include "services/logging/logger.h" #include "web_client/web_client.h" /** * @brief Provides Wikipedia summary lookups backed by cached raw extracts. */ class WikipediaEnrichmentService final : public IEnrichmentService { public: /** * @brief Creates a new Wikipedia service with the provided web client. */ explicit WikipediaEnrichmentService(std::unique_ptr client, std::shared_ptr logger); /** * @brief Returns the Wikipedia-derived context for a location. */ [[nodiscard]] std::string GetLocationContext(const City& loc) override; private: std::string FetchExtract(std::string_view query); std::unique_ptr client_; std::shared_ptr logger_; /** * @brief Cache for raw Wikipedia query extracts, keyed by query string. * * GetLocationContext() always queries "brewing" and reuses "beer in * {country}" for every city in that country, so caching avoids refetching * the same extract across locations in a run. */ std::unordered_map extract_cache_; }; #endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_WIKIPEDIA_SERVICE_H_