Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit84151d0

Browse files
committed
Avoid infinity calculations in rank_cd
1 parentba2edca commit84151d0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎contrib/tsearch2/rank.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ calc_rank_cd(float4 *arrdata, tsvector * txt, QUERYTYPE * query, int method)
667667
{
668668
doubleCpos=0.0;
669669
doubleInvSum=0.0;
670+
intnNoise;
670671
DocRepresentation*ptr=ext.begin;
671672

672673
while (ptr <=ext.end)
@@ -676,7 +677,16 @@ calc_rank_cd(float4 *arrdata, tsvector * txt, QUERYTYPE * query, int method)
676677
}
677678

678679
Cpos= ((double) (ext.end-ext.begin+1)) /InvSum;
679-
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));
680690

681691
CurExtPos= ((double) (ext.q+ext.p)) /2.0;
682692
if (NExtent>0&&CurExtPos>PrevExtPos/* prevent devision by

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp