| 308 | } |
| 309 | |
| 310 | LabelSuggestionHelper::ConstLabelVectorType LabelSuggestionHelper::FilterSuggestions( |
| 311 | const ConstLabelVectorType &suggestions, |
| 312 | const MultiLabelSegmentation *segmentation, |
| 313 | const std::optional<std::string_view> labelName) |
| 314 | { |
| 315 | if (segmentation == nullptr) |
| 316 | return suggestions; |
| 317 | |
| 318 | LabelSuggestionHelper::ConstLabelVectorType filtered; |
| 319 | |
| 320 | for (const auto &suggestion : suggestions) |
| 321 | { |
| 322 | auto maxInstance = GetMaxInstanceOccurrenceOfLabel(suggestion, GetSuggestionPreferences().suggestionOnce); |
| 323 | |
| 324 | auto currentCount = segmentation->GetLabelValuesByName(suggestion->GetName()).size(); |
| 325 | |
| 326 | if ((labelName.has_value() && labelName.value() == suggestion->GetName()) || //label is excluded from filtering |
| 327 | !maxInstance.has_value() || //no limit is defined |
| 328 | maxInstance.value() > currentCount) //limit is not reached |
| 329 | filtered.push_back(suggestion); |
| 330 | } |
| 331 | |
| 332 | return filtered; |
| 333 | } |
| 334 | |
| 335 | LabelSuggestionHelper::Preferences LabelSuggestionHelper::GetSuggestionPreferences() |
| 336 | { |
nothing calls this directly
no test coverage detected