8000 Feature/ngram similarity function by Dronplane · Pull Request #11276 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Feature/ngram similarity function #11276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added constants container
  • Loading branch information
Dronplane committed Mar 16, 2020
commit 905951350f09a1faaadb953c93047f040f6008a6
3 changes: 2 additions & 1 deletion arangod/Aql/Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "IResearch/VelocyPackHelper.h"
#include "IResearch/IResearchPDP.h"
#include "IResearch/IResearchAnalyzerFeature.h"
#include "IResearch/IResearchFilterFactory.h"
#include "Random/UniformCharacter.h"
#include "Rest/Version.h"
#include "RestServer/SystemDatabaseFeature.h"
Expand Down Expand Up @@ -1681,7 +1682,7 @@ AqlValue Functions::NgramMatch(ExpressionContext* ctx, transaction::Methods* trx
}
auto const targetValue = iresearch::getStringRef(target.slice());

double_t threshold = 0.7;//!!!! to constants!
auto threshold = arangodb::iresearch::FilterConstants::DefaultNgramMatchThreshold;
size_t analyzerPosition = 2;
if (argc > 3) {// 4 args given. 3rd is threshold
auto const& thresholdArg = extractFunctionParameterValue(args, 2);
Expand Down
8 changes: 4 additions & 4 deletions arangod/IResearch/IResearchFilterFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@ arangodb::Result getLevenshteinArguments(char const* funcName, bool isFilter,
};
}

scoringLimit = 128; // FIXME make configurable
scoringLimit = FilterConstants::DefaultScoringTermsLimit;

return {};
}
Expand Down Expand Up @@ -2623,7 +2623,7 @@ arangodb::Result fromFuncNgramMatch(
}
}

double_t threshold = 0.7;
auto threshold = FilterConstants::DefaultNgramMatchThreshold;
TRI_ASSERT(filterCtx.analyzer);
auto analyzerPool = filterCtx.analyzer;

Expand Down Expand Up @@ -2769,7 +2769,7 @@ arangodb::Result fromFuncStartsWith(
return rv;
}

size_t scoringLimit = 128; // FIXME make configurable
size_t scoringLimit = FilterConstants::DefaultScoringTermsLimit;

if (argc > 2) {
// 3rd (optional) argument defines a number of scored terms
Expand Down Expand Up @@ -2915,7 +2915,7 @@ arangodb::Result fromFuncLike(
return res;
}

const size_t scoringLimit = 128; // FIXME make configurable
const auto scoringLimit = FilterConstants::DefaultScoringTermsLimit;

if (filter) {
std::string name;
Expand Down
9 changes: 9 additions & 0 deletions arangod/IResearch/IResearchFilterFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ struct FilterFactory {
arangodb::aql::AstNode const& node);
}; // FilterFactory


class FilterConstants {
FilterConstants() = delete;
public:
// Defaults
static constexpr size_t DefaultScoringTermsLimit { 128 };
static constexpr double_t DefaultNgramMatchThreshold { 0.7 };
};

} // namespace iresearch
} // namespace arangodb

Expand Down
0