1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| package compare
|
| import (
| "basic.com/pubsub/protomsg.git"
| "sdkCompare/cache"
| "sort"
| )
|
| func realNamePersonsCompere(args protomsg.CompareArgs, fFeature []float32, baseScore float32) protomsg.SdkCompareResult {
| var scr protomsg.SdkCompareResult
| targets := cache.RealNameDbMap.Walk(DoSdkCompare, fFeature, baseScore)
| if len(targets) > 0 {
| sort.Slice(targets, func(i, j int) bool {
| return targets[i].CompareScore > targets[j].CompareScore
| })
|
| // 截取前5个元素
| topTargets := targets
| if len(targets) > 5 {
| topTargets = targets[:5] // 只取前5个元素
| }
|
| for idx, _ := range topTargets {
| scr.CompareResult = append(scr.CompareResult, topTargets[idx])
| }
| }
|
| return scr
| }
|
|