Пример #1
0
func TestGetContent(t *testing.T) {
	revision.SetDir("../pan-wvc-2010/revisions")

	exp := "#REDIRECT [[Cyclops (Clive Cussler novel)]]\r\n\r\n"
	got, e := revision.GetContent("98619235")

	if e != nil {
		t.Fatal(e)
	}

	assert(t, exp, got, true)
}
Пример #2
0
/*
Compute character distribution of inserted text.
*/
func (ftr *CharDistributionInsert) Compute(dataset tabula.DatasetInterface) {
	oldrevid := dataset.GetColumnByName("oldrevisionid")
	adds := dataset.GetColumnByName("additions")

	for x, rold := range oldrevid.Records {
		r := tabula.NewRecordReal(0.0)
		// count distribution of old revision
		oldText, e := revision.GetContent(rold.String())

		if e != nil {
			ftr.PushBack(r)
			continue
		}

		// count distribution of inserted text
		inText := adds.Records[x].String()

		divergence := KullbackLeiblerDivergence(oldText, inText)

		r.SetFloat(Round(divergence))

		ftr.PushBack(r)
	}
}