diff --git a/data/fallrate_v1.csv b/data/error-rate_v1.csv similarity index 100% rename from data/fallrate_v1.csv rename to data/error-rate_v1.csv diff --git a/vna/define.go b/vna/define.go index 25ace7f..1a25c1c 100644 --- a/vna/define.go +++ b/vna/define.go @@ -32,7 +32,7 @@ type DetectedResult struct { ProvinceKey string // 所属省份查询Key CityName string // 所属城市全称 CityKey string // 所属城市查询Key - FallRate float32 // 车牌易错字符统计 + ErrorRate float32 // 车牌易错字符统计 } func (dr DetectedResult) String() string { @@ -41,6 +41,6 @@ func (dr DetectedResult) String() string { dr.ProvinceKey, dr.ProvinceName, dr.CityKey, dr.CityName) } -func (dr DetectedResult) FallRateEqualTo(fallRate float32) bool { - return math.Abs(float64(fallRate-dr.FallRate)) < 0.0000000001 +func (dr DetectedResult) ErrorRateEqualTo(fallRate float32) bool { + return math.Abs(float64(fallRate-dr.ErrorRate)) < 0.0000000001 } diff --git a/vna/detector.go b/vna/detector.go index c274902..40b0095 100644 --- a/vna/detector.go +++ b/vna/detector.go @@ -22,9 +22,9 @@ func DetectNumber(number string) (DetectedResult, error) { provinceShort, provinceName, cityShort, cityName := detectSpecChars(numType, numberRune) // 统计易错字符 - var fallRate float32 + var errorRate float32 for _, c := range numberRune { - fallRate += gFallRateNames[string(c)] + errorRate += gErrorRateNames[string(c)] } return DetectedResult{ @@ -35,7 +35,7 @@ func DetectNumber(number string) (DetectedResult, error) { ProvinceKey: provinceShort, CityName: cityName, CityKey: cityShort, - FallRate: fallRate, + ErrorRate: errorRate, }, nil } diff --git a/vna/detector_test.go b/vna/detector_test.go index d36b75c..f3fefc0 100644 --- a/vna/detector_test.go +++ b/vna/detector_test.go @@ -72,8 +72,8 @@ func TestDetectNumberEmbassy(t *testing.T) { func TestDetectNumberFallRate(t *testing.T) { InitDetectorEnv("../" + DataDirName) dr, _ := DetectNumber("粤BF49883") - if dr.FallRateEqualTo(0.9) { - t.Error("fall rate not match, was:", dr.FallRate) + if dr.ErrorRateEqualTo(0.9) { + t.Error("fall rate not match, was:", dr.ErrorRate) } } diff --git a/vna/env.go b/vna/env.go index f21dead..a7fcefc 100644 --- a/vna/env.go +++ b/vna/env.go @@ -18,9 +18,9 @@ import ( const DataDirName = "data" var ( - gProvinceNames = make(map[string]string) - gCitiesNames = make(map[string]string) - gFallRateNames = make(map[string]float32) + gProvinceNames = make(map[string]string) + gCitiesNames = make(map[string]string) + gErrorRateNames = make(map[string]float32) ) var ( @@ -50,7 +50,7 @@ func InitDetectorEnv(base string) { "city-wj_v1.csv") // 加载易错统计数据 - initFallRate(base, "fallrate_v1.csv") + initFallRate(base, "error-rate_v1.csv") } func initProvinces(base string, names ...string) { @@ -87,7 +87,7 @@ func initFallRate(base string, name string) { if nil != err { panic(err) } - gFallRateNames[kv.Key] = float32(val) + gErrorRateNames[kv.Key] = float32(val) } }