Omega: Missing support for newer weighting schemes
Vivek Pal
vivekpal.dtu at gmail.com
Thu Apr 13 20:01:08 BST 2017
>> > The code in omega would just be:
>> >
>> > enq.set_weighting_scheme(Xapian::Weight::parse_params(scheme));
>>
>> I wonder if we could do something more like:
>>
>> enq.set_weighting_scheme(Xapian::Registry::get_weighting_scheme(name).parse_params(params));
>>
>> where, Xapian::Registry::get_weighting_scheme(name) returns a weighting scheme
>> object e.g. BM25Weight object and then calling parse_params method on that
>> to return a BM25Weight object now with parameters values as found in params
>> string.
>
> That doesn't work as written because you need a registry object to call
> get_weighting_scheme() on (it's not a static method).
Yes, right. That was just to convey the basic high level idea with something
crude, although later realized the mistake when dived into the details.
> But the idea is to have a static method of Xapian::Weight to do
> essentially that. It probably needs to take an optional Registry object
> like Query::unserialise() does so the user can add their own custom
> weighting schemes in:
>
> static const Query unserialise(const std::string & serialised,
> const Registry & reg = Registry());
>
>> It should work given that we first separate the "scheme" string into two
>> substrings namely "name" and "params" as used above.
>
> That ought to be handled by parse_params().
Thanks Olly for clarifying. So, we want to define a static parse_params
method needs to defined be in Xapian::Weight that would take "scheme" and
a Registry object to do the following set of things:
1. get an appropriate weighting scheme object by looking at the first
word in "scheme" string,
2. call parse_params method defined in that particular weighting scheme
subclass with just parameter string (e.g. parse_params("1.0 0.5")) which
creates and returns the weighting scheme object.
3. then ultimately return the weighting scheme object to the code in omega:
enq.set_weighting_scheme(Xapian::Weight::parse_params(scheme));
This is my current understanding of the main idea here but if you see
something odd then please let me know.
Thanks,
Vivek
More information about the Xapian-devel
mailing list