Re: Omega: Missing support for newer weighting schemes

Vivek Pal <[email protected]> Sun, 9 Apr 2017 23:34:07 +0530
Newsgroups gmane.comp.search.xapian.devel
Message-ID <CAGxcUfz7ED2f-GJANMR3Z1cZrGXi=Gby1FoYU7VqfCq6xBJpJg@mail.gmail.com>
> 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;
   }
}

I didn't test the code above so there could be small errors, but
hopefully it gets
across the general idea.

Thanks,
Vivek