Omega: Missing support for newer weighting schemes
Olly Betts
olly at survex.com
Mon Apr 10 00:55:45 BST 2017
On Sun, Apr 09, 2017 at 11:34:07PM +0530, Vivek Pal wrote:
> > Each scheme already has a human-readable name, and Xapian::Registry
> > can map that to an "examplar" object of the right type, so we
> > could take a string like "bm25 1 0.8", see the first word is "bm25"
> > and get a BM25Weight object, then call parse_params("1 0.8") on it to
> > create the correct Weight object (broadly similar to how unserialise()
> > is handled).
>
> If I followed correctly, since the set_weighting_scheme method in
> omega/weight.cc already does exactly that, do you suggest adding a
> parse_params method in each weighting scheme class to create the specific
> object? -- in which case the set_weighting_scheme method in omega/weight.cc
> would then use parse_params method to create the specific object with params
> in the "scheme" string. E.g. -
>
> if (startswith(scheme, "bm25")) {
> const char *p = scheme.c_str() + 4;
> if (*p == '\0') {
> enq.set_weighting_scheme(Xapian::BM25Weight());
> return;
> }
> if (C_isspace(*p)) {
> Xapian::BM25Weight wt = Xapian::BM25Weight::parse_params(p);
> enq.set_weighting_scheme(wt);
> return;
> }
> }
No, use Xapian::Registry to find the weighting scheme from the name
like how Weight::unserialise() does (otherwise every caller would need
code similar to that above).
The code in omega would just be:
enq.set_weighting_scheme(Xapian::Weight::parse_params(scheme));
There's probably a much better name than parse_params() though.
Cheers,
Olly
More information about the Xapian-devel
mailing list