package main

import (
	"fmt"
	"github.com/cilin-main"
	log "github.com/donnie4w/go-logger/logger"
	"github.com/strsim"
	qu "qfw/util"
)

func testEmptyBasic() {
	sess := data_mgo.GetMgoConn()
	defer data_mgo.DestoryMongoConn(sess)
	q, total := map[string]interface{}{}, 0
	it := sess.DB(data_mgo.DbName).C("zktest_bidding_info_zb_empty").Find(&q).Sort("-total").Iter()
	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
		if total%10000 == 0 {
			log.Debug("cur index ", total)
		}
		name := qu.ObjToString(tmp["name"])
		basic := qu.ObjToString(tmp["basic"])
		testArr := BasicClassNameInfo[basic]
		if len(testArr) > 0 && name != "" {
			req := strsim.FindBestMatchOne(name, testArr, strsim.DiceCoefficient())
			data_mgo.Save("zktest_bidding_info_zb_empty_result", map[string]interface{}{
				"name":  name,
				"match": req.S,
				"score": req.Score,
			})
		}

		tmp = make(map[string]interface{})
	}
	log.Debug("is over ", total)
}

func testtest() {
	cs := cilin.NewSimilarity()
	w1 := "网吧"
	lst := []string{"党群", "良民", "同志", "成年人", "市民", "亲属", "志愿者", "先锋"}
	for _, w2 := range lst {
		sim := cs.Calculate(w1, w2)
		fmt.Printf("%s %s, 相似度:%f\n", w1, w2, sim)
	}

	//w1 = "土豆"
	//lst = []string{"马铃薯", "群众", "党群", "良民", "同志", "成年人", "市民", "亲属", "志愿者", "先锋"}
	//for _, w2 := range lst {
	//	sim := cs.Calculate(w1, w2)
	//	fmt.Printf("%s %s, 相似度:%f\n", w1, w2, sim)
	//}
}
