mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-12 04:00:23 +08:00
add cosine similarity & 完善 PaperType
This commit is contained in:
19
backend/utils/cosimi_test.go
Normal file
19
backend/utils/cosimi_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSimilarity(t *testing.T) {
|
||||
r := Similarity([]uint8{1, 2, 3}, []uint8{1, 3, 4})
|
||||
t.Log(r)
|
||||
if math.Abs(r-0.9958705948858224) > 1e-6 {
|
||||
t.Fail()
|
||||
}
|
||||
r = Similarity([]uint8{3, 2, 1}, []uint8{1, 3, 4})
|
||||
t.Log(r)
|
||||
if math.Abs(r-0.6813851438692469) > 1e-6 {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user