Exemplo n.º 1
0
func TestCountUniqChar(t *testing.T) {
	line := "// Copyright 2016 Mhd Sulhan <*****@*****.**>. All rights reserved."
	exp := 34

	n := tekstus.CountUniqChar(line)

	assert(t, exp, n, true)
}
Exemplo n.º 2
0
/*
Compute character diversity.
*/
func (ftr *CharDiversity) Compute(dataset tabula.DatasetInterface) {
	adds := dataset.GetColumnByName("additions")

	for _, rec := range adds.Records {
		intext := rec.String()
		textlen := float64(len(intext))
		nuniq := tekstus.CountUniqChar(intext)
		v := math.Pow(textlen, 1/float64(1+nuniq))

		ftr.PushBack(tabula.NewRecordReal(Round(v)))
	}
}