Skip to content

Commit

Permalink
Rename fall-rate to error-rate
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoojia Chen committed May 10, 2018
1 parent 3f62513 commit e5c5f1e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions vna/define.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type DetectedResult struct {
ProvinceKey string // 所属省份查询Key
CityName string // 所属城市全称
CityKey string // 所属城市查询Key
FallRate float32 // 车牌易错字符统计
ErrorRate float32 // 车牌易错字符统计
}

func (dr DetectedResult) String() string {
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions vna/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -35,7 +35,7 @@ func DetectNumber(number string) (DetectedResult, error) {
ProvinceKey: provinceShort,
CityName: cityName,
CityKey: cityShort,
FallRate: fallRate,
ErrorRate: errorRate,
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions vna/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
10 changes: 5 additions & 5 deletions vna/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit e5c5f1e

Please sign in to comment.