> > > I'd prefer to avoid adding things to the public API that don't get > used by end users. However because LTR is outside the Xapian build > tree, we can't easily give it privileged access to Xapian internals. >Sorry for a delayed response. The way I was thinking of performing reranking with updated weights was to add a class MSetRanker (basically containing a copy of MSet to be re-ranked) to Xapian public API, which would be a friend of MSet::Internal class so that it could access/update the weights and sort MSetItems accordingly, returning an updated MSet. As you pointed out, two obvious issues with this are: 1) Unnecessary addition to Xapian public API since this class is not useful beyond letor. 2) It gives access to MSet internals to end users What would you suggest should be the way out to access MSet internals from -letor, if we can't add things to -core's public API? Regards, Ayush -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20160731/c5f23648/attachment.html>
On Sun, Jul 31, 2016 at 03:49:05AM +0530, Ayush Tomar wrote:> What would you suggest should be the way out to access MSet internals from > -letor, if we can't add things to -core's public API?I wouldn't say we can't add things to the core API, but it's much better if additions are clean, somewhat minimal (adding a lot of new methods and/or classes makes the API harder to learn and to work with, though being overly minimal has its downsides too so there can be a balance to strike on this), consistent with the existing API, and if possible have more than a single use. Would a method which swapped two elements of an MSet provide what you need? That would provide a more generic way to adjust the ranking of an MSet which for example could be used to implement a diversification feature or something like SQL "GROUP BY". For example: void MSet::exchange(Xapian::doccount a, Xapian::doccount b); Perhaps with an overloaded form which takes two MSetIterator objects for convenience. Cheers, Olly
On Sun, Jul 31, 2016 at 12:44:16AM +0100, Olly Betts wrote:> Would a method which swapped two elements of an MSet provide what you > need? That would provide a more generic way to adjust the ranking of > an MSet which for example could be used to implement a diversification > feature or something like SQL "GROUP BY".Isn't the most common use going to be that the client (letor or whatever) knows what documents are in what order, possibly with what new weights? I'd have thought people will end up writing the same boilerplate code if they have only swap / set weight options, but maybe I'm not seeing something. J -- James Aylett, occasional trouble-maker xapian.org