We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentba2edca commit84151d0Copy full SHA for 84151d0
contrib/tsearch2/rank.c
@@ -667,6 +667,7 @@ calc_rank_cd(float4 *arrdata, tsvector * txt, QUERYTYPE * query, int method)
667
{
668
doubleCpos=0.0;
669
doubleInvSum=0.0;
670
+intnNoise;
671
DocRepresentation*ptr=ext.begin;
672
673
while (ptr <=ext.end)
@@ -676,7 +677,16 @@ calc_rank_cd(float4 *arrdata, tsvector * txt, QUERYTYPE * query, int method)
676
677
}
678
679
Cpos= ((double) (ext.end-ext.begin+1)) /InvSum;
-Wdoc+=Cpos / ((double) ((1+ (ext.q-ext.p)- (ext.end-ext.begin))));
680
+/*
681
+ * if doc are big enough then ext.q may be equal to ext.p
682
+ * due to limit of posional information. In this case we
683
+ * approximate number of noise word as half cover's
684
+ * length
685
+ */
686
+nNoise= (ext.q-ext.p)- (ext.end-ext.begin);
687
+if (nNoise<0 )
688
+nNoise= (ext.end-ext.begin) /2;
689
+Wdoc+=Cpos / ((double) (1+nNoise));
690
691
CurExtPos= ((double) (ext.q+ext.p)) /2.0;
692
if (NExtent>0&&CurExtPos>PrevExtPos/* prevent devision by