Skip to content

Commit

Permalink
Duplicate check in evaluator (#244)
Browse files Browse the repository at this point in the history
fixes #234
  • Loading branch information
nsmith- authored Jun 20, 2024
1 parent 7e5a6be commit fc2eca9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/correction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -832,12 +832,18 @@ CorrectionSet::CorrectionSet(const JSONObject& json) {
for (const auto& item : json.getRequired<rapidjson::Value::ConstArray>("corrections")) {
if ( ! item.IsObject() ) { throw std::runtime_error("Expected Correction object"); }
auto corr = std::make_shared<Correction>(item.GetObject());
if ( corrections_.find(corr->name()) != corrections_.end() ) {
throw std::runtime_error("Duplicate Correction name: " + corr->name());
}
corrections_[corr->name()] = corr;
}
if (auto items = json.getOptional<rapidjson::Value::ConstArray>("compound_corrections")) {
for (const auto& item : *items) {
if ( ! item.IsObject() ) { throw std::runtime_error("Expected CompoundCorrection object"); }
auto corr = std::make_shared<CompoundCorrection>(item.GetObject(), *this);
if ( compoundcorrections_.find(corr->name()) != compoundcorrections_.end() ) {
throw std::runtime_error("Duplicate CompoundCorrection name: " + corr->name());
}
compoundcorrections_[corr->name()] = corr;
}
}
Expand Down

0 comments on commit fc2eca9

Please sign in to comment.