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

	keys := article.Keys()
	for _, key := range keys {
		score, _ := article.GetScore(key)
		fmt.Println(key, "is:", score)
	}
}
Example #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
}
func (a addAnalyzer) Analyze(
	_ pipeline.Article, related *pipeline.Article) (bool, error) {
	score := TestStandardScore{score: float32(a.howmuch)}
	related.AddScore("add", score)
	return true, nil
}