瀏覽代碼

产品数量规范化(文本内容预测)

znj 1 年之前
父節點
當前提交
ca93bd93ba
共有 1 個文件被更改,包括 7 次插入9 次删除
  1. 7 9
      BiddingKG/dl/interface/predictor.py

+ 7 - 9
BiddingKG/dl/interface/predictor.py

@@ -3436,8 +3436,7 @@ class ProductAttributesPredictor():
                                         parameter = ""
                                 if quantity != "" or unitPrice != "" or brand != "" or specs != "" or total_price:
                                     if id2 != "" and id3 != "" and len(re.split('[;;、,\n]', deal_list[id2])) > 1 and len(
-                                            re.split('[;;、,\n]', deal_list[id1])) == len(re.split('[;;、,\n]', deal_list[
-                                        id2])):  # 处理一个空格包含多个产品,逗号或空格分割情况 例子 292846806 292650743
+                                            re.split('[;;、,\n]', deal_list[id1])) == len(re.split('[;;、,\n]', deal_list[id2])):  # 处理一个空格包含多个产品,逗号或空格分割情况 例子 292846806 292650743
                                         products = re.split('[;;、,\n]', deal_list[id1])
                                         quantitys = re.split('[;;、,\n]', deal_list[id2])
                                         unitPrices = re.split('[;;、,\n]', deal_list[id3])
@@ -3455,10 +3454,9 @@ class ProductAttributesPredictor():
                                             for product, quantity, unitPrice, brand, specs, total_price, parameter in zip(
                                                     products, quantitys, unitPrices, brands, specses, total_prices,
                                                     parameters):
-                                                # if quantity != "":
-                                                #     quantity, quantity_unit_ = self.fix_quantity(quantity,
-                                                #                                                  header_quan_unit)
-                                                #     quantity_unit = quantity_unit_ if quantity_unit_ != "" else quantity_unit
+                                                if quantity != "":
+                                                    quantity, quantity_unit_ = self.fix_quantity(quantity,quantity_unit)
+                                                    quantity_unit = quantity_unit_ if quantity_unit_ != "" else quantity_unit
                                                 if unitPrice != "":
                                                     unitPrice, _money_unit = money_process(unitPrice, header_list[3])
                                                     unitPrice = str(unitPrice) if unitPrice != 0 else ""
@@ -3490,9 +3488,9 @@ class ProductAttributesPredictor():
                                         # i += 1
                                         continue
                                     else:
-                                        # if quantity != "":
-                                        #     quantity, quantity_unit_ = self.fix_quantity(quantity, header_quan_unit)
-                                        #     quantity_unit = quantity_unit_ if quantity_unit_ != "" else quantity_unit
+                                        if quantity != "":
+                                            quantity, quantity_unit_ = self.fix_quantity(quantity, quantity_unit)
+                                            quantity_unit = quantity_unit_ if quantity_unit_ != "" else quantity_unit
                                         if unitPrice != "":
                                             unitPrice, _money_unit = money_process(unitPrice, header_list[3])
                                             unitPrice = str(unitPrice) if unitPrice != 0 else ""