func printArticle(article pipeline.Article) { keys := article.Keys() for _, key := range keys { score, _ := article.GetScore(key) fmt.Println(key, "is:", score) } }
func scoreArticle(article *pipeline.Article, funcs map[string]func(pipeline.Score) float32, weights map[string]float32) float32 { keys := article.Keys() var articleScore float32 for _, key := range keys { scoreFunc, fok := funcs[key] weight, wok := weights[key] if !fok || !wok { panic("key " + key + "is not in funcs") } score, _ := article.GetScore(key) articleScore += scoreFunc(score) * weight } return articleScore }