data_workshop/building_test.go
2020-06-02 15:26:53 +08:00

44 lines
762 B
Go

package main
import (
"io/ioutil"
"os"
"regexp"
"testing"
)
func estMakeBuildingGob(t *testing.T) {
f, err := os.Open("/home/eson/test/spider_xingming/building_simple.txt")
if err != nil {
panic(err)
}
// reader := bufio.NewReader(f)
var alldict map[string]bool = make(map[string]bool)
all, _ := ioutil.ReadAll(f)
kl := &KeyList{}
for _, line := range regexp.MustCompile(`[^\s]+`).FindAll(all, -1) {
// kl.AppendKey(line)
alldict[string(line)] = true
}
for k := range alldict {
kl.AppendKey([]byte(k))
}
// i := 0
// for ; ; i++ {
// if err != nil {
// break
// }
// if len(line) <= 2 {
// continue
// }
// //t.Error(string(line))
// kl.AppendKey(line)
// }
// t.Error(i)
SaveData("./data/building.gob", kl)
}