Explorar o código

1. functions.py 增加标题分过滤逻辑
2. 修改召回,由ai标题改为原标题
3. videos_deal.py 增加过滤逻辑

罗俊辉 hai 11 meses
pai
achega
cb72fbc6a6

+ 21 - 0
applications/functions.py

@@ -137,3 +137,24 @@ def chunks(chunk_list, chunk_size):
     """
     """
     for i in range(0, len(chunk_list), chunk_size):
     for i in range(0, len(chunk_list), chunk_size):
         yield chunk_list[i: i + chunk_size]
         yield chunk_list[i: i + chunk_size]
+
+
+def title_filter(title_list):
+    """
+    标题过滤
+    :return:
+    """
+    url = "http://61.48.133.26:8179/score_list"
+    body = {
+        "account_nickname_list": ["指尖奇文"],
+        "text_list": title_list,
+        "max_time": None,
+        "min_time": None,
+        "interest_type": "by_avg",
+        "sim_type": "mean",
+        "rate": 0.1
+    }
+    response = requests.post(url=url, headers={}, json=body).json()
+    score_list = response['指尖奇文']['score_list']
+    # title_score_list = list(zip(title_list, score_list))
+    return score_list

+ 1 - 1
applications/migrate.py

@@ -26,7 +26,7 @@ def migrate_daily(dt):
     print("{} successfully insert {} rows, totally cost {} seconds".format(dt, len(data), b - a))
     print("{} successfully insert {} rows, totally cost {} seconds".format(dt, len(data), b - a))
 
 
 
 
-dt_list = generate_daily_strings("20240619", "20240627")
+dt_list = generate_daily_strings("20240627", "20240628")
 for dt in dt_list:
 for dt in dt_list:
     print(dt)
     print(dt)
     migrate_daily(dt)
     migrate_daily(dt)

+ 1 - 1
deal/matchArticle_deal.py

@@ -244,7 +244,7 @@ class MatchArticlesV2(object):
         :return:
         :return:
         """
         """
         select_sql = f"""
         select_sql = f"""
-        SELECT video_id, cover, img_list, ai_text, ai_title, status_code
+        SELECT video_id, cover, img_list, ai_text, video_title, status_code
         FROM {db_config}
         FROM {db_config}
         WHERE task_id = '{self.task_id}';
         WHERE task_id = '{self.task_id}';
         """
         """

+ 8 - 2
deal/videos_deal.py

@@ -1,7 +1,7 @@
 """
 """
 @author: luojunhui
 @author: luojunhui
 """
 """
-from applications.functions import chunks, get_info_lists
+from applications.functions import chunks, get_info_lists, title_filter
 from applications.config import minigram_info
 from applications.config import minigram_info
 
 
 
 
@@ -81,7 +81,13 @@ class VideoDeal(object):
         limit {self.topN};
         limit {self.topN};
         """
         """
         result_list = await self.mysql_client.select(sql)
         result_list = await self.mysql_client.select(sql)
-        return self.response_obj(result_list)
+        title_list = [i[1] for i in result_list]
+        socre_list = title_filter(title_list)
+        result_list_final = []
+        for index, item in enumerate(result_list):
+            if socre_list[index] > 0.4:
+                result_list_final.append(item)
+        return self.response_obj(result_list_final)
 
 
     async def deal_view(self):
     async def deal_view(self):
         """
         """

+ 2 - 2
test/videos_dev.py

@@ -14,8 +14,8 @@ url = "http://localhost:8888/videos"
 
 
 body = {
 body = {
     "cate": "video_return",
     "cate": "video_return",
-    "start_date": "2024-06-05",
-    "end_date": "2024-06-06",
+    "start_date": "2024-06-27",
+    "end_date": "2024-06-28",
     "topN": 50
     "topN": 50
 }
 }
 a = time.time()
 a = time.time()