Commit 79304ec4 by lichenggang

增加未识别到参数或数量的情况

parent adb6842f
......@@ -21,6 +21,13 @@ class Classify(classify_pb2_grpc.classifyServicer):
dic_data = json.loads(request.keyword)
res = self.predictorfac.predict(dic_data)
res['status'] = 1
for i in ['参数', '数量']:
if i not in str(res):
res = {
'status': 0,
'err_msg': f'未识别到{i}列'
}
except json.decoder.JSONDecodeError:
res = self.predictorfac.predict(request.keyword)
res['status'] = 1
......
......@@ -41,6 +41,14 @@ class DictHandler(BaseHandler):
dic_data = json.loads(self.request.body)
res = self.predictorfac.predict(dic_data)
res['status'] = 1
for i in ['参数', '数量']:
if i not in str(res):
res = {
'status': 0,
'err_msg': f'未识别到{i}列'
}
except json.decoder.JSONDecodeError:
res = self.predictorfac.predict(self.request.body)
res['status'] = 1
......
......@@ -165,4 +165,4 @@ class BasePredictor:
if __name__ == "__main__":
pass
print(BasePredictor.is_num([100,200]))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment