|
Revision 389, 0.8 kB
(checked in by heitor.barbieri, 3 weeks ago)
|
|
essage first commit
|
| Line | |
|---|
| 1 | somaprod=0; /* init sum of products of corresponding terms */ |
|---|
| 2 | somaq=0; /* init sum of squares for collection doc terms */ |
|---|
| 3 | for (; cnt--; v++) { |
|---|
| 4 | float W; |
|---|
| 5 | if (v->hidx < 0 || v-> hidx >= readnterms) fatal("wtrig2/VW/hidx"); |
|---|
| 6 | |
|---|
| 7 | somaq += v->weight * v->weight; /* sum of squares for collection doc terms */ |
|---|
| 8 | |
|---|
| 9 | W=WEIGHT[v->hidx]; |
|---|
| 10 | if (!W) continue; |
|---|
| 11 | |
|---|
| 12 | somaprod += W * v->weight; /* sum of products of corresponding terms */ |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | simil=0; |
|---|
| 16 | if (somaprod) { |
|---|
| 17 | |
|---|
| 18 | float denom = sqrt( Wsomaq * somaq); /* compute */ |
|---|
| 19 | |
|---|
| 20 | if (denom > 0) simil=somaprod/denom; /* compute */ |
|---|
| 21 | |
|---|
| 22 | if (simil > 1.0) simil=1.0; /* esteban, 09/12/2003 */ |
|---|
| 23 | |
|---|
| 24 | } /* end if somaprod */ |
|---|