func (cl *cluster) Score() float32 {
	if cl.changed {
		var s float32 = 0.0
		var w float32 = 0.0
		for i := range cl.Chunks {
			s += cl.Weights[i] * cl.Scores[i]
			w += cl.Weights[i]
		}
		cl.average = s / w
		cl.changed = false
	}
	return cl.average
}
Score calculates the weighted average of all chunk scores in cluster.
package model
import (
	gonet "golang.org/x/net/html"
	"github.com/slyrz/newscat/html"
)
type clusterMap map[*gonet.Node]*cluster
type cluster struct {
	Chunks  []*html.Chunk
	Scores  []float32
	Weights []float32
	average float32  
	changed bool     
}
func newCluster() *cluster {
	result := new(cluster)
	result.Chunks = make([]*html.Chunk, 0)
	result.Scores = make([]float32, 0)
	result.Weights = make([]float32, 0)
	return result
}
func (cl *cluster) Add(chunk *html.Chunk, args ...float32) {
	var score float32 = 0.0
	var weight float32 = 0.0
	switch len(args) {
	case 2:
		score, weight = args[0], args[1]
	case 1:
		score, weight = args[0], 1.0
	default:
		panic("call Add(chunk, score) or Add(chunk, score, weight)")
	}
	cl.Chunks = append(cl.Chunks, chunk)
	cl.Scores = append(cl.Scores, score)
	cl.Weights = append(cl.Weights, weight)
	cl.changed = true
}