| 34 | } |
| 35 | |
| 36 | search::Sample Context::MakeSample(search::FeatureLoader & loader) const |
| 37 | { |
| 38 | search::Sample outSample = m_sample; |
| 39 | |
| 40 | if (!m_initialized) |
| 41 | return outSample; |
| 42 | |
| 43 | auto const & foundEntries = m_foundResultsEdits.GetEntries(); |
| 44 | auto const & nonFoundEntries = m_nonFoundResultsEdits.GetEntries(); |
| 45 | |
| 46 | auto & outResults = outSample.m_results; |
| 47 | outResults.clear(); |
| 48 | |
| 49 | CHECK_EQUAL(m_goldenMatching.size(), m_sample.m_results.size(), ()); |
| 50 | CHECK_EQUAL(m_actualMatching.size(), foundEntries.size(), ()); |
| 51 | CHECK_EQUAL(m_actualMatching.size(), m_foundResults.GetCount(), ()); |
| 52 | |
| 53 | // Iterates over original (loaded from the file with search samples) |
| 54 | // results first. |
| 55 | size_t k = 0; |
| 56 | for (size_t i = 0; i < m_sample.m_results.size(); ++i) |
| 57 | { |
| 58 | auto const j = m_goldenMatching[i]; |
| 59 | |
| 60 | if (j == search::Matcher::kInvalidId) |
| 61 | { |
| 62 | auto const & entry = nonFoundEntries[k++]; |
| 63 | auto const deleted = entry.m_deleted; |
| 64 | auto const & curr = entry.m_currRelevance; |
| 65 | if (!deleted && curr) |
| 66 | { |
| 67 | auto result = m_sample.m_results[i]; |
| 68 | result.m_relevance = *curr; |
| 69 | outResults.push_back(result); |
| 70 | } |
| 71 | continue; |
| 72 | } |
| 73 | |
| 74 | if (!foundEntries[j].m_currRelevance) |
| 75 | continue; |
| 76 | |
| 77 | auto result = m_sample.m_results[i]; |
| 78 | result.m_relevance = *foundEntries[j].m_currRelevance; |
| 79 | outResults.push_back(std::move(result)); |
| 80 | } |
| 81 | |
| 82 | // Iterates over results retrieved during assessment. |
| 83 | for (size_t i = 0; i < m_foundResults.GetCount(); ++i) |
| 84 | { |
| 85 | auto const j = m_actualMatching[i]; |
| 86 | if (j != search::Matcher::kInvalidId) |
| 87 | { |
| 88 | // This result was processed by the loop above. |
| 89 | continue; |
| 90 | } |
| 91 | |
| 92 | if (!foundEntries[i].m_currRelevance) |
| 93 | continue; |
no test coverage detected