forked from organicmaps/organicmaps-tmp
Review fixes.
This commit is contained in:
parent
d3c949065a
commit
2d95661832
8 changed files with 38 additions and 30 deletions
|
@ -20,6 +20,8 @@
|
|||
#include <fstream>
|
||||
#include <iterator>
|
||||
|
||||
using Relevance = search::Sample::Result::Relevance;
|
||||
|
||||
MainModel::MainModel(Framework & framework)
|
||||
: m_framework(framework), m_index(m_framework.GetIndex())
|
||||
{
|
||||
|
@ -45,7 +47,7 @@ void MainModel::Open(std::string const & path)
|
|||
return;
|
||||
}
|
||||
|
||||
InvalidateSearch();
|
||||
ResetSearch();
|
||||
|
||||
m_samples.swap(samples);
|
||||
m_view->SetSamples(m_samples);
|
||||
|
@ -60,7 +62,7 @@ void MainModel::OnSampleSelected(int index)
|
|||
auto const & sample = m_samples[index];
|
||||
m_view->ShowSample(m_samples[index]);
|
||||
|
||||
InvalidateSearch();
|
||||
ResetSearch();
|
||||
|
||||
auto & engine = m_framework.GetSearchEngine();
|
||||
{
|
||||
|
@ -76,20 +78,21 @@ void MainModel::OnSampleSelected(int index)
|
|||
m_numShownResults = 0;
|
||||
|
||||
params.m_onResults = [this, sample, timestamp](search::Results const & results) {
|
||||
vector<search::Sample::Result::Relevance> relevances;
|
||||
std::vector<Relevance> relevances;
|
||||
if (results.IsEndedNormal())
|
||||
{
|
||||
search::Matcher matcher(m_index);
|
||||
|
||||
vector<search::Result> const actual(results.begin(), results.end());
|
||||
std::vector<search::Result> const actual(results.begin(), results.end());
|
||||
std::vector<size_t> goldenMatching;
|
||||
{
|
||||
std::vector<size_t> actualMatching;
|
||||
matcher.Match(sample.m_results, actual, goldenMatching, actualMatching);
|
||||
}
|
||||
|
||||
relevances.assign(actual.size(), search::Sample::Result::RELEVANCE_IRRELEVANT);
|
||||
for (size_t i = 0; i < goldenMatching.size(); ++i) {
|
||||
relevances.assign(actual.size(), Relevance::Irrelevant);
|
||||
for (size_t i = 0; i < goldenMatching.size(); ++i)
|
||||
{
|
||||
if (goldenMatching[i] != search::Matcher::kInvalidId)
|
||||
relevances[goldenMatching[i]] = sample.m_results[i].m_relevance;
|
||||
}
|
||||
|
@ -104,7 +107,7 @@ void MainModel::OnSampleSelected(int index)
|
|||
}
|
||||
|
||||
void MainModel::OnResults(uint64_t timestamp, search::Results const & results,
|
||||
vector<search::Sample::Result::Relevance> const & relevances)
|
||||
std::vector<Relevance> const & relevances)
|
||||
{
|
||||
if (timestamp != m_queryTimestamp)
|
||||
return;
|
||||
|
@ -116,7 +119,7 @@ void MainModel::OnResults(uint64_t timestamp, search::Results const & results,
|
|||
m_view->SetResultRelevances(relevances);
|
||||
}
|
||||
|
||||
void MainModel::InvalidateSearch()
|
||||
void MainModel::ResetSearch()
|
||||
{
|
||||
++m_queryTimestamp;
|
||||
if (auto handle = m_queryHandle.lock())
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <memory>
|
||||
|
||||
class Framework;
|
||||
class Index;
|
||||
|
||||
namespace search
|
||||
{
|
||||
|
@ -28,7 +29,7 @@ private:
|
|||
void OnResults(uint64_t timestamp, search::Results const & results,
|
||||
std::vector<search::Sample::Result::Relevance> const & relevances);
|
||||
|
||||
void InvalidateSearch();
|
||||
void ResetSearch();
|
||||
|
||||
Framework & m_framework;
|
||||
Index const & m_index;
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QToolBar>
|
||||
|
||||
using Relevance = search::Sample::Result::Relevance;
|
||||
|
||||
MainView::MainView(Framework & framework) : m_framework(framework)
|
||||
{
|
||||
setWindowTitle(tr("Assessment tool"));
|
||||
|
@ -56,8 +58,7 @@ void MainView::ShowResults(search::Results::Iter begin, search::Results::Iter en
|
|||
m_sampleView->ShowResults(begin, end);
|
||||
}
|
||||
|
||||
void MainView::SetResultRelevances(
|
||||
std::vector<search::Sample::Result::Relevance> const & relevances)
|
||||
void MainView::SetResultRelevances(std::vector<Relevance> const & relevances)
|
||||
{
|
||||
m_sampleView->SetResultRelevances(relevances);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <QtWidgets/QRadioButton>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
using Relevance = search::Sample::Result::Relevance;
|
||||
|
||||
namespace
|
||||
{
|
||||
QLabel * CreateLabel(QWidget & parent)
|
||||
|
@ -38,16 +40,16 @@ ResultView::ResultView(search::Result const & result, QWidget & parent) : QWidge
|
|||
SetContents(result);
|
||||
}
|
||||
|
||||
void ResultView::SetRelevance(search::Sample::Result::Relevance relevance)
|
||||
void ResultView::SetRelevance(Relevance relevance)
|
||||
{
|
||||
m_irrelevant->setChecked(false);
|
||||
m_relevant->setChecked(false);
|
||||
m_vital->setChecked(false);
|
||||
switch (relevance)
|
||||
{
|
||||
case search::Sample::Result::RELEVANCE_IRRELEVANT: m_irrelevant->setChecked(true); break;
|
||||
case search::Sample::Result::RELEVANCE_RELEVANT: m_relevant->setChecked(true); break;
|
||||
case search::Sample::Result::RELEVANCE_VITAL: m_vital->setChecked(true); break;
|
||||
case Relevance::Irrelevant: m_irrelevant->setChecked(true); break;
|
||||
case Relevance::Relevant: m_relevant->setChecked(true); break;
|
||||
case Relevance::Vital: m_vital->setChecked(true); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
using Relevance = search::Sample::Result::Relevance;
|
||||
|
||||
SampleView::SampleView(QWidget * parent) : QWidget(parent)
|
||||
{
|
||||
auto * mainLayout = BuildLayoutWithoutMargins<QVBoxLayout>(this /* parent */);
|
||||
|
@ -70,8 +72,7 @@ void SampleView::ShowResults(search::Results::Iter begin, search::Results::Iter
|
|||
m_results->Add(*it /* result */);
|
||||
}
|
||||
|
||||
void SampleView::SetResultRelevances(
|
||||
std::vector<search::Sample::Result::Relevance> const & relevances)
|
||||
void SampleView::SetResultRelevances(std::vector<Relevance> const & relevances)
|
||||
{
|
||||
CHECK_EQUAL(relevances.size(), m_results->Size(), ());
|
||||
for (size_t i = 0; i < relevances.size(); ++i)
|
||||
|
|
|
@ -199,7 +199,7 @@ int main(int argc, char * argv[])
|
|||
cout << i << ",";
|
||||
info.ToCSV(cout);
|
||||
|
||||
auto relevance = Sample::Result::RELEVANCE_IRRELEVANT;
|
||||
auto relevance = Sample::Result::Relevance::Irrelevant;
|
||||
if (actualMatching[j] != Matcher::kInvalidId)
|
||||
relevance = sample.m_results[actualMatching[j]].m_relevance;
|
||||
cout << "," << DebugPrint(relevance) << endl;
|
||||
|
@ -209,7 +209,7 @@ int main(int argc, char * argv[])
|
|||
for (size_t j = 0; j < goldenMatching.size(); ++j)
|
||||
{
|
||||
if (goldenMatching[j] == Matcher::kInvalidId &&
|
||||
sample.m_results[j].m_relevance != Sample::Result::RELEVANCE_IRRELEVANT)
|
||||
sample.m_results[j].m_relevance != Sample::Result::Relevance::Irrelevant)
|
||||
{
|
||||
s.m_notFound.push_back(j);
|
||||
}
|
||||
|
|
|
@ -75,11 +75,11 @@ void FromJSONObject(json_t * root, string const & field, search::Sample::Result:
|
|||
string relevance;
|
||||
FromJSONObject(root, field, relevance);
|
||||
if (relevance == "vital")
|
||||
r = search::Sample::Result::Relevance::RELEVANCE_VITAL;
|
||||
r = search::Sample::Result::Relevance::Vital;
|
||||
else if (relevance == "relevant")
|
||||
r = search::Sample::Result::Relevance::RELEVANCE_RELEVANT;
|
||||
r = search::Sample::Result::Relevance::Relevant;
|
||||
else
|
||||
r = search::Sample::Result::Relevance::RELEVANCE_IRRELEVANT;
|
||||
r = search::Sample::Result::Relevance::Irrelevant;
|
||||
}
|
||||
|
||||
void FromJSON(json_t * root, search::Sample::Result & result)
|
||||
|
@ -181,9 +181,9 @@ string DebugPrint(Sample::Result::Relevance r)
|
|||
{
|
||||
switch (r)
|
||||
{
|
||||
case Sample::Result::RELEVANCE_IRRELEVANT: return "Irrelevant";
|
||||
case Sample::Result::RELEVANCE_RELEVANT: return "Relevant";
|
||||
case Sample::Result::RELEVANCE_VITAL: return "Vital";
|
||||
case Sample::Result::Relevance::Irrelevant: return "Irrelevant";
|
||||
case Sample::Result::Relevance::Relevant: return "Relevant";
|
||||
case Sample::Result::Relevance::Vital: return "Vital";
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ struct Sample
|
|||
{
|
||||
struct Result
|
||||
{
|
||||
enum Relevance
|
||||
enum class Relevance
|
||||
{
|
||||
RELEVANCE_IRRELEVANT,
|
||||
RELEVANCE_RELEVANT,
|
||||
RELEVANCE_VITAL
|
||||
Irrelevant,
|
||||
Relevant,
|
||||
Vital
|
||||
};
|
||||
|
||||
bool operator<(Result const & rhs) const;
|
||||
|
@ -30,7 +30,7 @@ struct Sample
|
|||
strings::UniString m_name;
|
||||
string m_houseNumber;
|
||||
vector<string> m_types; // MAPS.ME types, not OSM types.
|
||||
Relevance m_relevance = RELEVANCE_IRRELEVANT;
|
||||
Relevance m_relevance = Relevance::Irrelevant;
|
||||
};
|
||||
|
||||
bool DeserializeFromJSON(string const & jsonStr);
|
||||
|
|
Loading…
Add table
Reference in a new issue