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