| | |
| | | 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 { |
| | | for idx, _ := range targets { |
| | | scr.CompareResult = append(scr.CompareResult, targets[idx]) |
| | | 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]) |
| | | } |
| | | } |
| | | |