Browse Source

fieldscore.json错误,强退程序

maxiaoshan 5 years ago
parent
commit
f96ba1ca25
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/jy/extract/score.go

+ 6 - 2
src/jy/extract/score.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	ju "jy/util"
 	"log"
+	"os"
 	qu "qfw/util"
 	"regexp"
 	"strconv"
@@ -28,6 +29,9 @@ func init() {
 	qu.ReadConfig("./res/tagscoredesc.json", &TagConfigDesc)
 	qu.ReadConfig("./res/tagscore.json", &TagConfig)
 	qu.ReadConfig("./res/fieldscore.json", &SoreConfig)
+	if SoreConfig == nil { //配置出错,强退
+		os.Exit(0)
+	}
 	if repeat, ok := SoreConfig["other"]["repeat"].(map[string]interface{}); ok {
 		RepeatScore = qu.Float64All(repeat["score"])
 	}
@@ -117,12 +121,12 @@ func ScoreFields(j *ju.Job, ftag map[string][]*Tag) map[string][]*ju.ExtField {
 				if field == "budget" || field == "bidamount" {
 					if tmpsvalue.IsTrue {
 						//continue
-					}else {
+					} else {
 						tmps[tmpsindex].Score = -10
 						tmps[tmpsindex].ScoreItem = append(tmps[tmpsindex].ScoreItem, &ju.ScoreItem{Des: `value结果为空直接-10分`, Code: field, Value: tmpsvalue.Value, Score: -10})
 						continue
 					}
-				}else {
+				} else {
 					tmps[tmpsindex].Score = -10
 					tmps[tmpsindex].ScoreItem = append(tmps[tmpsindex].ScoreItem, &ju.ScoreItem{Des: `value结果为空直接-10分`, Code: field, Value: tmpsvalue.Value, Score: -10})
 					continue