Rev 7044 | Blame | Compare with Previous | Last modification | View Log | RSS feed
# This is the search kernel routine. To be replaced by a c program,
# when the intermediate output risks to overflow.
#
# Input parameters:
# srch, search_category, gotlim, gotlim2
#
# Output variables:
# gotm, gotw, gotcnt
# gotw is only for debugging uses.
!nocache
!distribute words $wims_read_parm into s_cat
!default search_lang=$lang
!default s_cat=$search_category
srch=!singlespace $srch
srch=!replace internal ,$ $ by , in $srch
srch=!replace internal $ $, by , in $srch
!if $srch!=$empty
suffix_dictionary=
dictionary=$search_package2/$s_cat.$search_lang
translator_unknown=
!read search.common
!else
scnt=0
!endif
!distribute item 0,0,, into weight,gotcnt,gotm,gotw,lastmod
!for i=1 to $scnt
l_=!line $i of $sout
t_=!wordcnt $l_
!if $t_=2
!distribute word $l_ into m_,w_
!if $m_=$lastmod
weight=$[$weight+$w_]
!else
!if $lastmod!=$empty
gotm=$gotm $lastmod
gotw=$gotw $weight
!advance gotcnt
!if $gotcnt>=$gotlim
!goto bailout
!endif
!endif
lastmod=$m_
weight=$w_
!endif
!endif
!next i
:bailout
!if $lastmod!=$empty and $gotcnt<$gotlim
gotm=$gotm $lastmod
gotw=$gotw $weight
!advance gotcnt
!endif
!if $gotcnt>0
translator_switch=leavelines
translator_unknown=200
gotw=!words2lines $gotw
gotm=!words2lines $gotm
dictionary=$search_package2/weight.$search_lang
gotW=!exec translator $gotm
dictionary=$search_package2/popular.1
gotp=!exec translator $gotm
w_=
!for i=1 to $gotcnt
u_=!line $i of $gotw
v_=!line $i of $gotW
p_=!line $i of $gotp
!bound p_ between integer 0 and 1000000 default 0
w_=!append line $[round(100*($u_+1)*($p_+10)^0.4/($v_+1)^0.7)] to $w_
!next i
gotw=!sort reverse numeric lines $w_
gotm=!line $wims_sort_order of $gotm
gotm=!line 1 to $gotlim2 of $gotm
gotcnt=!linecnt $gotm
!endif