Skip to content

Commit

Permalink
Use a boolean here.
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Treat <[email protected]>
  • Loading branch information
manyoso committed Sep 24, 2024
1 parent fea544d commit 3c7d7f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions gpt4all-chat/src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ QList<Database::BM25Query> Database::queriesForFTS5(const QString &input)

// Start by trying to match the entire input
BM25Query e;
e.type = 0; // exact
e.isExact = true;
e.input = oWords.join(" ");
e.query = "\"" + oWords.join(" ") + "\"";
e.qlength = oWords.size();
Expand All @@ -2142,7 +2142,6 @@ QList<Database::BM25Query> Database::queriesForFTS5(const QString &input)
quotedWords << "\"" + w + "\"";

BM25Query b;
b.type = 1; // broad search
b.input = oWords.join(" ");
b.query = "(" + quotedWords.join(" OR ") + ")";
b.qlength = 1; // length of phrase
Expand Down Expand Up @@ -2198,7 +2197,7 @@ QList<int> Database::searchBM25(const QString &query, const QList<QString> &coll
float Database::computeBM25Weight(const Database::BM25Query &bm25q)
{
float bmWeight = 0.0f;
if (bm25q.type == 0 /*exact*/) {
if (bm25q.isExact) {
bmWeight = 0.9f; // the highest we give
} else {
// qlength is the length of the phrases in the query by number of distinct words
Expand Down
2 changes: 1 addition & 1 deletion gpt4all-chat/src/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private Q_SLOTS:
struct BM25Query {
QString input;
QString query;
int type = 0;
bool isExact = false;
int qlength = 0;
int ilength = 0;
int rlength = 0;
Expand Down

0 comments on commit 3c7d7f7

Please sign in to comment.