From 64aed4139a092c7a919af30b5c0b3227662bd6f5 Mon Sep 17 00:00:00 2001 From: Uppinder Chugh Date: Tue, 19 Jun 2018 23:01:24 +0530 Subject: [PATCH] Add parameter 'r' to Diversify ctor and internals --- xapian-core/diversify/diversify.cc | 5 +++-- xapian-core/diversify/diversifyinternal.h | 6 +++++- xapian-core/include/xapian/diversify.h | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xapian-core/diversify/diversify.cc b/xapian-core/diversify/diversify.cc index ae1fc52e3..7caa906b6 100644 --- a/xapian-core/diversify/diversify.cc +++ b/xapian-core/diversify/diversify.cc @@ -46,12 +46,13 @@ Diversify& Diversify::operator=(Diversify&&) = default; Diversify::Diversify(unsigned int k_, + double r_, double lambda_, double b_, double sigma_sqr_) - : internal(new Xapian::Diversify::Internal(k_, lambda_, b_, sigma_sqr_)) + : internal(new Xapian::Diversify::Internal(k_, r_, lambda_, b_, sigma_sqr_)) { - LOGCALL_CTOR(API, "Diversify", k_ | lambda_ | b_ | sigma_sqr_); + LOGCALL_CTOR(API, "Diversify", k_ | r_ | lambda_ | b_ | sigma_sqr_); } Diversify::~Diversify() diff --git a/xapian-core/diversify/diversifyinternal.h b/xapian-core/diversify/diversifyinternal.h index 70e20e274..e3488f705 100644 --- a/xapian-core/diversify/diversifyinternal.h +++ b/xapian-core/diversify/diversifyinternal.h @@ -38,6 +38,9 @@ class Xapian::Diversify::Internal : public Xapian::Internal::intrusive_base { /// Top-k documents of given mset are diversified unsigned int k; + /// Number of relevant documents from each cluster used for building topC + double r; + /// MPT parameters double lambda, b, sigma_sqr; @@ -56,10 +59,11 @@ class Xapian::Diversify::Internal : public Xapian::Internal::intrusive_base { public: /// Constructor for initialising diversification parameters explicit Internal(unsigned int k_, + double r_, double lambda_, double b_, double sigma_sqr_) - : k(k_), lambda(lambda_), b(b_), sigma_sqr(sigma_sqr_) {} + : k(k_), r(r_), lambda(lambda_), b(b_), sigma_sqr(sigma_sqr_) {} /** Initialise diversified document set * diff --git a/xapian-core/include/xapian/diversify.h b/xapian-core/include/xapian/diversify.h index 1df7af2ba..679d86155 100644 --- a/xapian-core/include/xapian/diversify.h +++ b/xapian-core/include/xapian/diversify.h @@ -78,6 +78,8 @@ class XAPIAN_VISIBILITY_DEFAULT Diversify { * * @param k_ Number of required diversified documents in the * diversified document set + * @param r_ Number of documents from each cluster used for + * building topC * @param lambda_ Trade-off between relevance of top-k diversified * document set and its similarity to the rest of the * documents in the document match set. Belongs to the @@ -90,6 +92,7 @@ class XAPIAN_VISIBILITY_DEFAULT Diversify { * [1e-6,1] */ explicit Diversify(unsigned int k_, + double r_, double lambda_ = 0.5, double b_ = 5.0, double sigma_sqr_ = 1e-3); -- 2.11.4.GIT