Skip to content

Commit

Permalink
src/dict/dictionary: fix duplicates in search results
Browse files Browse the repository at this point in the history
Fix duplicates appearing in search results. This happened because terms
were sorted by their surface length, when they should have been sorted
by deconjugation length. This is because deconjugations will be used to
search for terms, so duplicate deconjugations means duplicate search
results. This fixes the issue by sorting by decending conjugation
length, breaking ties by prioritizing the longest surface.
  • Loading branch information
ripose-jp committed Apr 30, 2024
1 parent d269752 commit 923b7d2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/dict/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,11 @@ void Dictionary::sortQueries(std::vector<SearchQuery> &queries)
std::begin(queries), std::end(queries),
[] (const SearchQuery &rhs, const SearchQuery &lhs) -> bool
{
if (rhs.surface.size() > lhs.surface.size())
if (rhs.deconj == lhs.deconj)
{
return true;
return rhs.surface.size() > lhs.surface.size();
}
if (rhs.surface.size() == lhs.surface.size())
{
return rhs.deconj.size() > lhs.deconj.size();
}
return false;
return rhs.deconj > lhs.deconj;
}
);
}
Expand Down

0 comments on commit 923b7d2

Please sign in to comment.