Use id instead of article.Id.
This commit is contained in:
@@ -23,17 +23,18 @@ func main() {
|
|||||||
df := make(map[string]int)
|
df := make(map[string]int)
|
||||||
|
|
||||||
for _, article := range articles {
|
for _, article := range articles {
|
||||||
|
id := article.Id
|
||||||
str := strings.ToLower(article.Title + "\n" + article.Body)
|
str := strings.ToLower(article.Title + "\n" + article.Body)
|
||||||
|
|
||||||
bag := tokenizer.Tokenize(str)
|
bag := tokenizer.Tokenize(str)
|
||||||
tokens[article.Id] = bag
|
tokens[id] = bag
|
||||||
|
|
||||||
for _, w := range bag {
|
for _, w := range bag {
|
||||||
// Handle TF:
|
// Handle TF:
|
||||||
if _, ok := tf[w]; !ok {
|
if _, ok := tf[w]; !ok {
|
||||||
tf[w] = make(map[string]int)
|
tf[w] = make(map[string]int)
|
||||||
}
|
}
|
||||||
tf[w][article.Id] += strings.Count(str, w)
|
tf[w][id] += strings.Count(str, w)
|
||||||
|
|
||||||
// Handle DF:
|
// Handle DF:
|
||||||
df[w] += 1
|
df[w] += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user