|
@@ -1,273 +1 @@
|
|
|
-def exec(obj):
|
|
|
- def data_pretreatment(map):
|
|
|
- def get_value(str):
|
|
|
- end = len(str)
|
|
|
- if '.' in str:
|
|
|
- end = str.index('.')
|
|
|
- return int(str[:end])
|
|
|
-
|
|
|
- parameters = {k: get_value(v) for k, v in map.items()}
|
|
|
- scores = []
|
|
|
-
|
|
|
- for k, v in parameters.items():
|
|
|
- result = 0
|
|
|
- if k == 'bh10006':
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif 0 < v <= 15:
|
|
|
- result = 80
|
|
|
- elif 15 < v <= 25:
|
|
|
- result = 60
|
|
|
- elif 25 < v <= 35:
|
|
|
- result = 40
|
|
|
- elif 35 < v <= 50:
|
|
|
- result = 20
|
|
|
- elif v > 50:
|
|
|
- result = 0
|
|
|
- scores.append((0.069857492, result))
|
|
|
-
|
|
|
- elif k == 'bh10018':
|
|
|
- if v == 0:
|
|
|
- result = 85
|
|
|
- elif v == 1:
|
|
|
- result = 100
|
|
|
- elif v == 2:
|
|
|
- result = 50
|
|
|
- elif v == 3:
|
|
|
- result = 10
|
|
|
- scores.append((0.048865349, result))
|
|
|
-
|
|
|
- elif k == 'bh10025':
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 90
|
|
|
- elif v == 2:
|
|
|
- result = 80
|
|
|
- elif v == 3:
|
|
|
- result = 50
|
|
|
- elif v == 4:
|
|
|
- result = 40
|
|
|
- elif v == 5:
|
|
|
- result = 30
|
|
|
- elif v == 6:
|
|
|
- result = 10
|
|
|
- elif v > 6:
|
|
|
- result = 0
|
|
|
- scores.append((0.0467602, result))
|
|
|
-
|
|
|
- elif k == "bh10022":
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 70
|
|
|
- elif v == 2:
|
|
|
- result = 35
|
|
|
- elif v == 3:
|
|
|
- result = 5
|
|
|
- scores.append((0.039446769, result))
|
|
|
- elif k == "bh10019":
|
|
|
- if v == 0:
|
|
|
- result = 80
|
|
|
- elif v == 1:
|
|
|
- result = 100
|
|
|
- elif v == 2:
|
|
|
- result = 40
|
|
|
- elif v == 3:
|
|
|
- result = 5
|
|
|
- scores.append((0.045120359, result))
|
|
|
- elif k == "bh10023":
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 70
|
|
|
- elif v == 2:
|
|
|
- result = 40
|
|
|
- elif v == 3:
|
|
|
- result = 10
|
|
|
- scores.append((0.043568957, result))
|
|
|
- elif k == "bh10009":
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif 0 < v <= 15:
|
|
|
- result = 80
|
|
|
- elif 15 < v <= 25:
|
|
|
- result = 60
|
|
|
- elif 25 < v <= 35:
|
|
|
- result = 40
|
|
|
- elif 35 < v <= 50:
|
|
|
- result = 20
|
|
|
- elif v > 50:
|
|
|
- result = 0
|
|
|
- scores.append((0.092601792, result))
|
|
|
- elif k == "bh10016":
|
|
|
- if v == 0:
|
|
|
- result = 85
|
|
|
- elif v == 1:
|
|
|
- result = 100
|
|
|
- elif v == 2:
|
|
|
- result = 50
|
|
|
- elif v == 3:
|
|
|
- result = 8
|
|
|
- scores.append((0.056671171, result))
|
|
|
- elif k == "bh10024":
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 70
|
|
|
- elif v == 2:
|
|
|
- result = 50
|
|
|
- elif v == 3:
|
|
|
- result = 25
|
|
|
- elif v == 4:
|
|
|
- result = 5
|
|
|
- scores.append((0.049505696, result))
|
|
|
- elif k == "bh10017":
|
|
|
- if v == 0:
|
|
|
- result = 75
|
|
|
- elif v == 1:
|
|
|
- result = 100
|
|
|
- elif v == 2:
|
|
|
- result = 40
|
|
|
- elif v == 3:
|
|
|
- result = 10
|
|
|
- scores.append((0.052926182, result))
|
|
|
- elif k == "bh10027":
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 60
|
|
|
- elif v > 1:
|
|
|
- result = 0
|
|
|
- scores.append((0.054838899, result))
|
|
|
- elif k == "cnName":
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 90
|
|
|
- elif v == 2:
|
|
|
- result = 85
|
|
|
- elif v == 3:
|
|
|
- result = 80
|
|
|
- elif 4 <= v <= 8:
|
|
|
- result = 70
|
|
|
- elif 8 < v <= 12:
|
|
|
- result = 50
|
|
|
- elif 12 < v <= 15:
|
|
|
- result = 30
|
|
|
- elif v > 15:
|
|
|
- result = 0
|
|
|
- scores.append((0.071630387, result))
|
|
|
- elif k == "cnNameLM":
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 90
|
|
|
- elif v == 2:
|
|
|
- result = 85
|
|
|
- elif v == 3:
|
|
|
- result = 80
|
|
|
- elif 4 <= v <= 8:
|
|
|
- result = 70
|
|
|
- elif 8 < v <= 12:
|
|
|
- result = 50
|
|
|
- elif 12 < v <= 15:
|
|
|
- result = 30
|
|
|
- elif v > 15:
|
|
|
- result = 0
|
|
|
- scores.append((0.066097986, result))
|
|
|
- elif k == "cnRuleType":
|
|
|
- if v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 90
|
|
|
- elif v == 2:
|
|
|
- result = 70
|
|
|
- elif v == 3:
|
|
|
- result = 40
|
|
|
- elif v == 4:
|
|
|
- result = 0
|
|
|
- scores.append((0.072776513, result))
|
|
|
- elif k == "personCheatIndices":
|
|
|
- if v == -1:
|
|
|
- result = -1
|
|
|
- elif v == 0:
|
|
|
- result = 100
|
|
|
- elif v == 1:
|
|
|
- result = 80
|
|
|
- elif v == 2:
|
|
|
- result = 60
|
|
|
- elif v == 3:
|
|
|
- result = 40
|
|
|
- elif v > 3:
|
|
|
- result = 0
|
|
|
- scores.append((0.0736, result))
|
|
|
-
|
|
|
- return scores
|
|
|
-
|
|
|
- def coalesce(scores):
|
|
|
- hb_score = 0
|
|
|
- flag = False
|
|
|
-
|
|
|
- for p in scores:
|
|
|
- coefficient = p[0]
|
|
|
- score = p[1]
|
|
|
- if score == -1:
|
|
|
- flag = True
|
|
|
- hb_score += coefficient * score / 0.884267752
|
|
|
- hb_score = round(hb_score, 10)
|
|
|
-
|
|
|
- if flag:
|
|
|
- return 70
|
|
|
- else:
|
|
|
- return hb_score
|
|
|
-
|
|
|
- def is_numeric(value):
|
|
|
- try:
|
|
|
- float(value)
|
|
|
- return True
|
|
|
- except ValueError:
|
|
|
- return False
|
|
|
-
|
|
|
- keys = ['bh10022', 'cnRuleType', 'bh10025', 'bh10024', 'bh10023', 'bh10019', 'personCheatIndices', 'bh10018', 'bh10006', 'cnNameLM', 'bh10017', 'bh10016', 'bh10027', 'huhhuhuhuhuResult', 'cnName', 'bh10009']
|
|
|
-
|
|
|
- obj = {key: obj[key] for key in keys if key in keys}
|
|
|
-
|
|
|
- for key in obj.keys():
|
|
|
- if not is_numeric(obj[key]):
|
|
|
- obj['abc'] = 70
|
|
|
- break
|
|
|
-
|
|
|
- if obj["personCheatIndices"] == "-1":
|
|
|
- obj['abc'] = 70
|
|
|
- else:
|
|
|
- result = coalesce(data_pretreatment(obj))
|
|
|
- obj['abc'] = result
|
|
|
- return obj
|
|
|
-
|
|
|
-
|
|
|
-print(exec({
|
|
|
- "bh10022": "1",
|
|
|
- "cnRuleType": "2",
|
|
|
- "child_flow_base_url": "http://rxdp-flow:8080",
|
|
|
- "bh10025": "1.38",
|
|
|
- "bh10024": "3",
|
|
|
- "bh10023": "2",
|
|
|
- "bh10019": "3",
|
|
|
- "personCheatIndices": "0",
|
|
|
- "bh10018": "2",
|
|
|
- "flow_reused_global_flag": "0.0",
|
|
|
- "bh10006": "14",
|
|
|
- "cnNameLM": "21",
|
|
|
- "bh10017": "3",
|
|
|
- "bh10016": "2",
|
|
|
- "bh10027": "0",
|
|
|
- "huhhuhuhuhuResult": "50.9627708497",
|
|
|
- "current_flow_ip_address": "172.16.45.34",
|
|
|
- "cnName": "21",
|
|
|
- "bh10009": "23",
|
|
|
- "flow_process_trace": {
|
|
|
- "20014": []
|
|
|
- },
|
|
|
- "abc": "70.0"
|
|
|
-}))
|
|
|
+123
|