alkis has asked for the wisdom of the Perl Monks concerning the following question:
the second one has to do with word distance (the closer the terms of a multiple query are to a doc the more relevant the doc is to that query)def locationscore(self,rows): locations=dict([(row[0],1000000) for row in rows]) for row in rows: loc=sum(row[1:]) if loc<locations[row[0]]: locations[row[0]]=loc return self.normalizescores(locations,smallIsBetter=1)
thats all, pls help me ....i know nothing in python and i am a newbie in perl!!! thanksdef distancescore(self,rows): # If there's only one word, everyone wins! if len(rows[0])<=2: return dict([(row[0],1.0) for row in rows]) # Initialize the dictionary with large values mindistance=dict([(row[0],1000000) for row in rows]) for row in rows: dist=sum([abs(row[i]-row[i-1]) for i in range(2,len(row))]) if dist<mindistance[row[0]]: mindistance[row[0]]=dist return self.normalizescores(mindistance,smallIsBetter=1)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: term weighting :convert python to perl
by pc88mxer (Vicar) on Apr 14, 2008 at 21:13 UTC | |
|
Re: term weighting :convert python to perl
by Anonymous Monk on Apr 15, 2008 at 08:33 UTC |