This commit is contained in:
Aaron Po
2026-04-07 17:55:15 -04:00
parent 54c403526b
commit 06d329cac5

View File

@@ -1,21 +1,24 @@
#include <functional>
#include <string> #include <string>
#include "data_generation/mock_generator.h" #include "data_generation/mock_generator.h"
BreweryResult MockGenerator::GenerateBrewery( auto MockGenerator::GenerateBrewery(const std::string& city_name,
const std::string& city_name, const std::string& country_name, const std::string& country_name,
const std::string& region_context) { const std::string& /*region_context*/)
const std::string location_key = -> BreweryResult {
country_name.empty() ? city_name : city_name + "," + country_name; const std::size_t hash = DeterministicHash(city_name, country_name);
const std::size_t hash =
region_context.empty() ? std::hash<std::string>{}(location_key)
: DeterministicHash(location_key, region_context);
BreweryResult result; const std::string& adjective =
result.name = kBreweryAdjectives[hash % kBreweryAdjectives.size()] + " " + kBreweryAdjectives.at(hash % kBreweryAdjectives.size());
kBreweryNouns[(hash / 7) % kBreweryNouns.size()]; const std::string& noun = kBreweryNouns.at((hash / 7) % kBreweryNouns.size());
result.description = const std::string& base_description =
kBreweryDescriptions[(hash / 13) % kBreweryDescriptions.size()]; kBreweryDescriptions.at((hash / 13) % kBreweryDescriptions.size());
return result;
const std::string name = city_name + " " + adjective + " " + noun;
const std::string description =
base_description + " Based in " + city_name +
(country_name.empty() ? std::string(".")
: std::string(", ") + country_name + ".");
return {name, description};
} }