| 6 | namespace Star { |
| 7 | |
| 8 | PatternedNameGenerator::PatternedNameGenerator() { |
| 9 | auto assets = Root::singleton().assets(); |
| 10 | auto &files = assets->scanExtension("namesource"); |
| 11 | assets->queueJsons(files); |
| 12 | for (auto& file : files) { |
| 13 | try { |
| 14 | auto sourceConfig = assets->json(file); |
| 15 | |
| 16 | if (m_markovSources.contains(sourceConfig.getString("name"))) |
| 17 | throw NameGeneratorException::format("Duplicate name source '{}', config file '{}'", sourceConfig.getString("name"), file); |
| 18 | |
| 19 | m_markovSources.insert(sourceConfig.getString("name"), makeMarkovSource(sourceConfig.getUInt("prefixSize", 1), |
| 20 | sourceConfig.getUInt("endSize", 1), jsonToStringList(sourceConfig.get("sourceNames")))); |
| 21 | } catch (std::exception const& e) { |
| 22 | throw NameGeneratorException(strf("Error reading name source config {}", file), e); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | auto profanityFilter = assets->json("/names/profanityfilter.config").toArray(); |
| 27 | for (auto& naughtyWord : profanityFilter) |
| 28 | m_profanityFilter.add(naughtyWord.toString().toLower()); |
| 29 | } |
| 30 | |
| 31 | String PatternedNameGenerator::generateName(String const& rulesAsset) const { |
| 32 | RandomSource random; |
nothing calls this directly
no test coverage detected