菜鸟提问,关于字符匹配和提取数值
请教 如何提取数值,查找相同的intersection_sum?
Suppose Bugs (p1) and Elmer (p2) have rated the following flavours:
“Bugs” : {“lemon”:6, “maple walnut”:2, “chocolate”: 5, “bubble gum”: 4}
“Elmer” : {“mocha”: 4, “lemon”: 5, “bubble gum”: 7}
程序框架:
p1_sum = 6+2+5+4 = 17 (the sum of Bugs's ratings)
p2_sum = 4+5+7 = 16 (the sum of Elmer's ratings)
intersection_sum = min(6,5) + min(4,7) = 5+4 = 9(since they both rated lemon and bubble
gum)
similarity = min (9/17, 9/16)= 9/17 (remembering to make sure these are not both
evaluated to 0 due to integer division)