Subversion Repositories wimsdev

Rev

Rev 7043 | 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
6739 bpr 11
!distribute words $wims_read_parm into s_cat
2725 bpr 12
!default search_lang=$lang
6739 bpr 13
!default s_cat=$search_category
14
 
6692 bpr 15
srch=!singlespace $srch
16
srch=!replace internal ,$ $ by , in $srch
17
srch=!replace internal $ $, by , in $srch
6470 bpr 18
 
33 reyssat 19
!if $srch!=$empty
20
 suffix_dictionary=
6739 bpr 21
 dictionary=$search_package2/$s_cat.$search_lang
33 reyssat 22
 translator_unknown=
6516 bpr 23
 !read search.common
33 reyssat 24
!else
25
 scnt=0
26
!endif
27
 
28
!distribute item 0,0,, into weight,gotcnt,gotm,gotw,lastmod
29
 
30
!for i=1 to $scnt
31
 l_=!line $i of $sout
32
 t_=!wordcnt $l_
33
 !if $t_=2
34
  !distribute word $l_ into m_,w_
35
  !if $m_=$lastmod
36
   weight=$[$weight+$w_]
37
  !else
38
   !if $lastmod!=$empty
39
    gotm=$gotm $lastmod
40
    gotw=$gotw $weight
41
    !advance gotcnt
42
    !if $gotcnt>=$gotlim
43
     !goto bailout
44
    !endif
45
   !endif
46
   lastmod=$m_
47
   weight=$w_
48
  !endif
49
 !endif
50
!next i
51
:bailout
52
!if $lastmod!=$empty and $gotcnt<$gotlim
53
 gotm=$gotm $lastmod
54
 gotw=$gotw $weight
55
 !advance gotcnt
56
!endif
57
 
58
!if $gotcnt>0
59
 translator_switch=leavelines
60
 translator_unknown=200
61
 gotw=!words2lines $gotw
62
 gotm=!words2lines $gotm
2670 bpr 63
 dictionary=$search_package2/weight.$search_lang
33 reyssat 64
 gotW=!exec translator $gotm
65
 dictionary=$search_package2/popular.1
66
 gotp=!exec translator $gotm
67
 w_=
68
 !for i=1 to $gotcnt
69
  u_=!line $i of $gotw
70
  v_=!line $i of $gotW
71
  p_=!line $i of $gotp
72
  !bound p_ between integer 0 and 1000000 default 0
73
  w_=!append line $[round(100*($u_+1)*($p_+10)^0.4/($v_+1)^0.7)] to $w_
74
 !next i
75
 gotw=!sort reverse numeric lines $w_
76
 gotm=!line $wims_sort_order of $gotm
77
 gotm=!line 1 to $gotlim2 of $gotm
78
 gotcnt=!linecnt $gotm
79
!endif