예제 #1
0
func printArticle(article pipeline.Article) {

	keys := article.Keys()
	for _, key := range keys {
		score, _ := article.GetScore(key)
		fmt.Println(key, "is:", score)
	}
}
예제 #2
0
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
}