Subversion Repositories wimsdev

Rev

Rev 2725 | Rev 6516 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33 reyssat 1
# This is the search kernel routine. To be replaced by a c program,
2
# when the intermediate output risks to overflow.
3
#
4
# Input parameters:
2725 bpr 5
# srch, search_category, gotlim, gotlim2
33 reyssat 6
#
7
# Output variables:
8
# gotm, gotw, gotcnt
9
# gotw is only for debugging uses.
10
!nocache
2725 bpr 11
!default search_lang=$lang
6470 bpr 12
 
33 reyssat 13
!if $srch!=$empty
14
 suffix_dictionary=
2670 bpr 15
 dictionary=$search_package2/$search_category.$search_lang
33 reyssat 16
 translator_unknown=
6470 bpr 17
 !if $search_and=yes
18
   srch=!items2lines $srch
19
 !endif
33 reyssat 20
 sout=!exec translator $srch
6470 bpr 21
 !if $search_and=yes
22
   scnt=!linecnt $srch
23
   Sout=!words2items $(sout[1;])
24
   !for s=2 to $scnt
25
     S=!words2items $(sout[$s;])
26
     Sout=!listintersection $Sout and $S
27
   !next
28
    sout=$Sout
29
 !endif
33 reyssat 30
 sout=!items2words $sout
31
 sout=!words2lines $sout
32
 sout=!translate ? to $ $ in $sout
33
 sout=!sort lines $sout
34
 sout=!nonempty lines $sout
35
 scnt=!linecnt $sout
6470 bpr 36
 
33 reyssat 37
!else
38
 scnt=0
39
!endif
40
 
41
!distribute item 0,0,, into weight,gotcnt,gotm,gotw,lastmod
42
 
43
!for i=1 to $scnt
44
 l_=!line $i of $sout
45
 t_=!wordcnt $l_
46
 !if $t_=2
47
  !distribute word $l_ into m_,w_
48
  !if $m_=$lastmod
49
   weight=$[$weight+$w_]
50
  !else
51
   !if $lastmod!=$empty
52
    gotm=$gotm $lastmod
53
    gotw=$gotw $weight
54
    !advance gotcnt
55
    !if $gotcnt>=$gotlim
56
     !goto bailout
57
    !endif
58
   !endif
59
   lastmod=$m_
60
   weight=$w_
61
  !endif
62
 !endif
63
!next i
64
:bailout
65
!if $lastmod!=$empty and $gotcnt<$gotlim
66
 gotm=$gotm $lastmod
67
 gotw=$gotw $weight
68
 !advance gotcnt
69
!endif
70
 
71
!if $gotcnt>0
72
 translator_switch=leavelines
73
 translator_unknown=200
74
 gotw=!words2lines $gotw
75
 gotm=!words2lines $gotm
2670 bpr 76
 dictionary=$search_package2/weight.$search_lang
33 reyssat 77
 gotW=!exec translator $gotm
78
 dictionary=$search_package2/popular.1
79
 gotp=!exec translator $gotm
80
 w_=
81
 !for i=1 to $gotcnt
82
  u_=!line $i of $gotw
83
  v_=!line $i of $gotW
84
  p_=!line $i of $gotp
85
  !bound p_ between integer 0 and 1000000 default 0
86
  w_=!append line $[round(100*($u_+1)*($p_+10)^0.4/($v_+1)^0.7)] to $w_
87
 !next i
88
 gotw=!sort reverse numeric lines $w_
89
 gotm=!line $wims_sort_order of $gotm
90
 gotm=!line 1 to $gotlim2 of $gotm
91
 gotcnt=!linecnt $gotm
92
!endif