From 24f373d20f8252508748c11eb0384ef1af1e3913 Mon Sep 17 00:00:00 2001 From: skkiesel Date: Wed, 10 May 2017 09:50:37 -0400 Subject: [PATCH] when read through the whole set of quote rows before beginning adding back into the babbler --- plugins/babbler/babbler.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/babbler/babbler.go b/plugins/babbler/babbler.go index 49c2aed..b6e1598 100644 --- a/plugins/babbler/babbler.go +++ b/plugins/babbler/babbler.go @@ -141,13 +141,19 @@ func (p *BabblerPlugin) getOrCreateBabbler(babbler string) (int64, error) { //we'll just ignore this but the actual creation succeeded previously return id, nil } + defer rows.Close() + tidbits := []string{} for rows.Next() { var tidbit string err := rows.Scan(&tidbit) if err != nil { return id, err } + tidbits = append(tidbits, tidbit) + } + + for _, tidbit := range tidbits { p.addToMarkovChain(id, tidbit) }