Ah, now I see. Results are always sorted first by the edit distance, then
by the popularity. What I think would work even better than allowing a
custom compareTo function would be to incorporate the frequency directly
into the distance function. This would allow for greater control over the
trade-off between frequency and edit distance. I'll file a jira and look at
submitting a patch.
Cheers,
Jason
On Thu, Oct 9, 2008 at 9:22 AM, Grant Ingersoll <[EMAIL PROTECTED]> wrote:
> Sorting in the SpellChecker is handled by the SuggestWord.compareTo()
> method in Lucene. It looks like:
> public final int compareTo(SuggestWord a) {
> // first criteria: the edit distance
> if (score > a.score) {
> return 1;
> }
> if (score < a.score) {
> return -1;
> }
>
> // second criteria (if first criteria is equal): the popularity
> if (freq > a.freq) {
> return 1;
> }
>
> if (freq < a.freq) {
> return -1;
> }
> return 0;
> }
>
> I could see you opening a JIRA issue in Lucene against the SC to make it so
> that the sorting could be overridden/pluggable. A patch to do so would be
> even better ;-)
>
> Cheers,
> Grant
>
--
Jason Rennie
Head of Machine Learning Technologies, StyleFeeder
http://www.stylefeeder.com/