Pārlūkot izejas kodu

处理预测模型文本为空异常

dongzhaorui 1 gadu atpakaļ
vecāks
revīzija
a705ab4496
1 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 5 0
      find_source/predict_bidding_model/__init__.py

+ 5 - 0
find_source/predict_bidding_model/__init__.py

@@ -49,6 +49,10 @@ def exists_ztb(contents: dict):
     # 切词
     for no_key, content in contents.items():
         source = replace_word(content)
+        if not source:
+            result[no_key] = 0
+            continue
+
         texts = deal_tag_a(source)
         space_contents = cut_data(texts)
         if not space_contents:
@@ -56,6 +60,7 @@ def exists_ztb(contents: dict):
             continue
         body.append(space_contents)
         id_list.append(no_key)
+
     # 生成预测结果
     predict_threshold = topic_model.predict(body, threshold=True)
     for no_key, pre_ret in zip(id_list, predict_threshold):