We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd4539d commit 2e36c32Copy full SHA for 2e36c32
tfidf.go
@@ -67,17 +67,13 @@ func (tf *TFIDF) Score(doc Document) []float64 {
67
ids := doc.IDs()
68
69
retVal := make([]float64, len(ids))
70
- tf.Lock()
+ TF := make(map[int]float64)
71
for _, id := range ids {
72
- tf.TF[id]++
+ TF[id]++
73
}
74
for i, id := range ids {
75
- retVal[i] = tf.TF[id]
76
- }
77
- for _, id := range ids {
78
- tf.TF[id]--
+ retVal[i] = TF[id]
79
80
- tf.Unlock()
81
82
l := float64(len(ids))
83
for i, freq := range retVal {
tfidf_example_test.go
@@ -89,5 +89,5 @@ func Example() {
89
// "never": 2.4
90
// "mind": 2.4
91
// "how": 2.4
92
- // Scores: [1.2 1.3 1.2 0.9]
+ // Scores: [0.6 0.3 0.6 0.1]
93
0 commit comments