Saturates the relevance boost given to already run matches;
this avoids very commonly selected matches (e.g. konsole) to beat any other match even if the latter is in principle more relevant svn path=/trunk/KDE/kdelibs/; revision=1128445
This commit is contained in:
parent
e3eda3ab65
commit
14ebf05e43
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "runnercontext.h"
|
#include "runnercontext.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -375,8 +377,9 @@ bool RunnerContext::addMatches(const QString &term, const QList<QueryMatch> &mat
|
|||||||
LOCK_FOR_WRITE(d)
|
LOCK_FOR_WRITE(d)
|
||||||
foreach (QueryMatch match, matches) {
|
foreach (QueryMatch match, matches) {
|
||||||
// Give previously launched matches a slight boost in relevance
|
// Give previously launched matches a slight boost in relevance
|
||||||
|
// The boost smoothly saturates to 0.5;
|
||||||
if (int count = d->launchCounts.value(match.id())) {
|
if (int count = d->launchCounts.value(match.id())) {
|
||||||
match.setRelevance(match.relevance() + 0.05 * count);
|
match.setRelevance(match.relevance() + 0.5 * (1-exp(-count*0.3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
d->matches.append(match);
|
d->matches.append(match);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user