Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Hey I was wondering about this function problem for a while

$
0
0
def compare_signatures(sig1, sig2, weight):
""" (list, list, list of float) -> float

Return a non-negative real number indicating the similarity of the two
linguistic signatures, sig1 and sig2. The smaller the number the more
similar the signatures. Zero indicates identical signatures.

sig1 and sig2 are 6-item lists with the following items:
0 : Author Name (a string)
1 : Average Word Length (float)
2 : Type Token Ratio (float)
3 : Hapax Legomena Ratio (float)
4 : Average Sentence Length (float)
5 : Average Sentence Complexity (float)

weight is a list of multiplicative weights to apply to each
linguistic feature. weight[0] is ignored.

>>> sig1 = ["a_string" , 4.4, 0.1, 0.05, 10.0, 2.0]
>>> sig2 = ["a_string2", 4.3, 0.1, 0.04, 16.0, 4.0]
>>> weight = [0, 11.0, 33.0, 50.0, 0.4, 4.0]
>>> compare_signatures(sig1, sig2, weight)
12.000000000000007
"""

Viewing all articles
Browse latest Browse all 2485

Trending Articles