data_workshop/building_test.go

44 lines
762 B
Go
Raw Permalink Normal View History

2020-05-22 07:39:43 +00:00
package main
import (
"io/ioutil"
"os"
"regexp"
"testing"
)
func estMakeBuildingGob(t *testing.T) {
2020-05-22 07:39:43 +00:00
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)
}