def string_to_rank(text, maxint=sys.maxint):
 rs = CleanText(text, banned=CleanText.NONALNUM).clean.lower()
 rank = 0.0
 frac = 1.0
 for pos in range(0, min(15, len(rs))):
  rank += (frac * (int(rs[pos], 36) / (36.0 + (0.09 * pos))))
  frac *= (1.0 / (36 - pos))
 return (long((rank * (maxint - 100))) + min(100, len(text)))

def string_to_rank ( text , maxint = sys . maxint ) : rs = CleanText ( text , banned = CleanText . NONALNUM ) . clean . lower ( ) rank = 0.0 frac = 1.0 for pos in range ( 0 , min ( 15 , len ( rs ) ) ) : rank += ( frac * ( int ( rs [ pos ] , 36 ) / ( 36.0 + ( 0.09 * pos ) ) ) ) frac *= ( 1.0 / ( 36 - pos ) ) return ( long ( ( rank * ( maxint - 100 ) ) ) + min ( 100 , len ( text ) ) )
approximate lexographical order with an int .