1
0
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:
源文雨
2023-03-22 20:54:54 +08:00
parent 5aeca6d5fa
commit 0756b36633
3 changed files with 91 additions and 1 deletions

View 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()
}
}