|
@@ -12,6 +12,7 @@ import asyncio
|
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
|
from typing import Dict, List
|
|
from typing import Dict, List
|
|
|
import sys
|
|
import sys
|
|
|
|
|
+from datetime import datetime
|
|
|
|
|
|
|
|
# 添加项目根目录到路径
|
|
# 添加项目根目录到路径
|
|
|
project_root = Path(__file__).parent.parent.parent
|
|
project_root = Path(__file__).parent.parent.parent
|
|
@@ -20,9 +21,62 @@ sys.path.insert(0, str(project_root))
|
|
|
from lib.semantic_similarity import compare_phrases
|
|
from lib.semantic_similarity import compare_phrases
|
|
|
|
|
|
|
|
# 全局并发限制
|
|
# 全局并发限制
|
|
|
-MAX_CONCURRENT_REQUESTS = 20
|
|
|
|
|
|
|
+MAX_CONCURRENT_REQUESTS = 100
|
|
|
semaphore = None
|
|
semaphore = None
|
|
|
|
|
|
|
|
|
|
+# 进度跟踪
|
|
|
|
|
+class ProgressTracker:
|
|
|
|
|
+ """进度跟踪器"""
|
|
|
|
|
+ def __init__(self, total: int):
|
|
|
|
|
+ self.total = total
|
|
|
|
|
+ self.completed = 0
|
|
|
|
|
+ self.start_time = datetime.now()
|
|
|
|
|
+ self.last_update_time = datetime.now()
|
|
|
|
|
+ self.last_completed = 0
|
|
|
|
|
+
|
|
|
|
|
+ def update(self, count: int = 1):
|
|
|
|
|
+ """更新进度"""
|
|
|
|
|
+ self.completed += count
|
|
|
|
|
+ current_time = datetime.now()
|
|
|
|
|
+
|
|
|
|
|
+ # 每秒最多更新一次,或者达到总数时更新
|
|
|
|
|
+ if (current_time - self.last_update_time).total_seconds() >= 1.0 or self.completed >= self.total:
|
|
|
|
|
+ self.display()
|
|
|
|
|
+ self.last_update_time = current_time
|
|
|
|
|
+ self.last_completed = self.completed
|
|
|
|
|
+
|
|
|
|
|
+ def display(self):
|
|
|
|
|
+ """显示进度"""
|
|
|
|
|
+ if self.total == 0:
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ percentage = (self.completed / self.total) * 100
|
|
|
|
|
+ elapsed = (datetime.now() - self.start_time).total_seconds()
|
|
|
|
|
+
|
|
|
|
|
+ # 计算速度和预估剩余时间
|
|
|
|
|
+ if elapsed > 0:
|
|
|
|
|
+ speed = self.completed / elapsed
|
|
|
|
|
+ if speed > 0:
|
|
|
|
|
+ remaining = (self.total - self.completed) / speed
|
|
|
|
|
+ eta_str = f", 预计剩余: {int(remaining)}秒"
|
|
|
|
|
+ else:
|
|
|
|
|
+ eta_str = ""
|
|
|
|
|
+ else:
|
|
|
|
|
+ eta_str = ""
|
|
|
|
|
+
|
|
|
|
|
+ bar_length = 40
|
|
|
|
|
+ filled_length = int(bar_length * self.completed / self.total)
|
|
|
|
|
+ bar = '█' * filled_length + '░' * (bar_length - filled_length)
|
|
|
|
|
+
|
|
|
|
|
+ print(f"\r 进度: [{bar}] {self.completed}/{self.total} ({percentage:.1f}%){eta_str}", end='', flush=True)
|
|
|
|
|
+
|
|
|
|
|
+ # 完成时换行
|
|
|
|
|
+ if self.completed >= self.total:
|
|
|
|
|
+ print()
|
|
|
|
|
+
|
|
|
|
|
+# 全局进度跟踪器
|
|
|
|
|
+progress_tracker = None
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def get_semaphore():
|
|
def get_semaphore():
|
|
|
"""获取全局信号量"""
|
|
"""获取全局信号量"""
|
|
@@ -35,6 +89,7 @@ def get_semaphore():
|
|
|
async def match_single_pair(
|
|
async def match_single_pair(
|
|
|
feature_name: str,
|
|
feature_name: str,
|
|
|
persona_name: str,
|
|
persona_name: str,
|
|
|
|
|
+ persona_feature_level: str,
|
|
|
category_mapping: Dict = None,
|
|
category_mapping: Dict = None,
|
|
|
model_name: str = None
|
|
model_name: str = None
|
|
|
) -> Dict:
|
|
) -> Dict:
|
|
@@ -44,6 +99,7 @@ async def match_single_pair(
|
|
|
Args:
|
|
Args:
|
|
|
feature_name: 要匹配的特征名称
|
|
feature_name: 要匹配的特征名称
|
|
|
persona_name: 人设特征名称
|
|
persona_name: 人设特征名称
|
|
|
|
|
+ persona_feature_level: 人设特征层级(灵感点/关键点/目的点)
|
|
|
category_mapping: 特征分类映射字典
|
|
category_mapping: 特征分类映射字典
|
|
|
model_name: 使用的模型名称
|
|
model_name: 使用的模型名称
|
|
|
|
|
|
|
@@ -51,6 +107,7 @@ async def match_single_pair(
|
|
|
单个匹配结果,格式:
|
|
单个匹配结果,格式:
|
|
|
{
|
|
{
|
|
|
"人设特征名称": "xxx",
|
|
"人设特征名称": "xxx",
|
|
|
|
|
+ "人设特征层级": "灵感点",
|
|
|
"特征类型": "标签",
|
|
"特征类型": "标签",
|
|
|
"特征分类": ["分类1", "分类2"],
|
|
"特征分类": ["分类1", "分类2"],
|
|
|
"匹配结果": {
|
|
"匹配结果": {
|
|
@@ -59,14 +116,18 @@ async def match_single_pair(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
"""
|
|
"""
|
|
|
|
|
+ global progress_tracker
|
|
|
sem = get_semaphore()
|
|
sem = get_semaphore()
|
|
|
async with sem:
|
|
async with sem:
|
|
|
- print(f" 匹配: {feature_name} <-> {persona_name}")
|
|
|
|
|
similarity_result = await compare_phrases(
|
|
similarity_result = await compare_phrases(
|
|
|
phrase_a=feature_name,
|
|
phrase_a=feature_name,
|
|
|
phrase_b=persona_name,
|
|
phrase_b=persona_name,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ # 更新进度
|
|
|
|
|
+ if progress_tracker:
|
|
|
|
|
+ progress_tracker.update(1)
|
|
|
|
|
+
|
|
|
# 判断该特征是标签还是分类
|
|
# 判断该特征是标签还是分类
|
|
|
feature_type = "分类" # 默认为分类
|
|
feature_type = "分类" # 默认为分类
|
|
|
categories = []
|
|
categories = []
|
|
@@ -104,6 +165,7 @@ async def match_single_pair(
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
"人设特征名称": persona_name,
|
|
"人设特征名称": persona_name,
|
|
|
|
|
+ "人设特征层级": persona_feature_level,
|
|
|
"特征类型": feature_type,
|
|
"特征类型": feature_type,
|
|
|
"特征分类": unique_categories,
|
|
"特征分类": unique_categories,
|
|
|
"匹配结果": similarity_result
|
|
"匹配结果": similarity_result
|
|
@@ -121,7 +183,7 @@ async def match_feature_with_persona(
|
|
|
|
|
|
|
|
Args:
|
|
Args:
|
|
|
feature_name: 要匹配的特征名称
|
|
feature_name: 要匹配的特征名称
|
|
|
- persona_features: 人设特征列表
|
|
|
|
|
|
|
+ persona_features: 人设特征列表(包含"特征名称"和"人设特征层级")
|
|
|
category_mapping: 特征分类映射字典
|
|
category_mapping: 特征分类映射字典
|
|
|
model_name: 使用的模型名称
|
|
model_name: 使用的模型名称
|
|
|
|
|
|
|
@@ -130,7 +192,13 @@ async def match_feature_with_persona(
|
|
|
"""
|
|
"""
|
|
|
# 创建所有匹配任务
|
|
# 创建所有匹配任务
|
|
|
tasks = [
|
|
tasks = [
|
|
|
- match_single_pair(feature_name, persona_feature["特征名称"], category_mapping, model_name)
|
|
|
|
|
|
|
+ match_single_pair(
|
|
|
|
|
+ feature_name,
|
|
|
|
|
+ persona_feature["特征名称"],
|
|
|
|
|
+ persona_feature["人设特征层级"],
|
|
|
|
|
+ category_mapping,
|
|
|
|
|
+ model_name
|
|
|
|
|
+ )
|
|
|
for persona_feature in persona_features
|
|
for persona_feature in persona_features
|
|
|
]
|
|
]
|
|
|
|
|
|
|
@@ -161,7 +229,6 @@ async def match_single_feature(
|
|
|
feature_name = feature_item.get("特征名称", "")
|
|
feature_name = feature_item.get("特征名称", "")
|
|
|
feature_weight = feature_item.get("权重", 1.0)
|
|
feature_weight = feature_item.get("权重", 1.0)
|
|
|
|
|
|
|
|
- print(f" 特征: {feature_name} (权重: {feature_weight})")
|
|
|
|
|
match_results = await match_feature_with_persona(
|
|
match_results = await match_feature_with_persona(
|
|
|
feature_name=feature_name,
|
|
feature_name=feature_name,
|
|
|
persona_features=persona_features,
|
|
persona_features=persona_features,
|
|
@@ -176,29 +243,28 @@ async def match_single_feature(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-async def process_single_inspiration_point(
|
|
|
|
|
- inspiration_point: Dict,
|
|
|
|
|
|
|
+async def process_single_point(
|
|
|
|
|
+ point: Dict,
|
|
|
|
|
+ point_type: str,
|
|
|
persona_features: List[Dict],
|
|
persona_features: List[Dict],
|
|
|
category_mapping: Dict = None,
|
|
category_mapping: Dict = None,
|
|
|
model_name: str = None
|
|
model_name: str = None
|
|
|
) -> Dict:
|
|
) -> Dict:
|
|
|
"""
|
|
"""
|
|
|
- 处理单个灵感点的特征匹配(并发执行)
|
|
|
|
|
|
|
+ 处理单个点(灵感点/关键点/目的点)的特征匹配(并发执行)
|
|
|
|
|
|
|
|
Args:
|
|
Args:
|
|
|
- inspiration_point: 灵感点数据
|
|
|
|
|
- persona_features: 人设灵感特征列表
|
|
|
|
|
|
|
+ point: 点数据(灵感点/关键点/目的点)
|
|
|
|
|
+ point_type: 点类型("灵感点"/"关键点"/"目的点")
|
|
|
|
|
+ persona_features: 人设特征列表
|
|
|
category_mapping: 特征分类映射字典
|
|
category_mapping: 特征分类映射字典
|
|
|
model_name: 使用的模型名称
|
|
model_name: 使用的模型名称
|
|
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
|
- 包含 how 步骤列表的灵感点数据
|
|
|
|
|
|
|
+ 包含 how 步骤列表的点数据
|
|
|
"""
|
|
"""
|
|
|
- point_name = inspiration_point.get("名称", "")
|
|
|
|
|
- feature_list = inspiration_point.get("特征列表", [])
|
|
|
|
|
-
|
|
|
|
|
- print(f" 处理灵感点: {point_name}")
|
|
|
|
|
- print(f" 特征数量: {len(feature_list)}")
|
|
|
|
|
|
|
+ point_name = point.get("名称", "")
|
|
|
|
|
+ feature_list = point.get("特征列表", [])
|
|
|
|
|
|
|
|
# 并发匹配所有特征
|
|
# 并发匹配所有特征
|
|
|
tasks = [
|
|
tasks = [
|
|
@@ -207,14 +273,20 @@ async def process_single_inspiration_point(
|
|
|
]
|
|
]
|
|
|
feature_match_results = await asyncio.gather(*tasks)
|
|
feature_match_results = await asyncio.gather(*tasks)
|
|
|
|
|
|
|
|
- # 构建 how 步骤
|
|
|
|
|
|
|
+ # 构建 how 步骤(根据点类型生成步骤名称)
|
|
|
|
|
+ step_name_mapping = {
|
|
|
|
|
+ "灵感点": "灵感特征分别匹配人设特征",
|
|
|
|
|
+ "关键点": "关键特征分别匹配人设特征",
|
|
|
|
|
+ "目的点": "目的特征分别匹配人设特征"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
how_step = {
|
|
how_step = {
|
|
|
- "步骤名称": "灵感特征分别匹配人设特征",
|
|
|
|
|
|
|
+ "步骤名称": step_name_mapping.get(point_type, f"{point_type}特征分别匹配人设特征"),
|
|
|
"特征列表": list(feature_match_results)
|
|
"特征列表": list(feature_match_results)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- # 返回更新后的灵感点
|
|
|
|
|
- result = inspiration_point.copy()
|
|
|
|
|
|
|
+ # 返回更新后的点
|
|
|
|
|
+ result = point.copy()
|
|
|
result["how步骤列表"] = [how_step]
|
|
result["how步骤列表"] = [how_step]
|
|
|
|
|
|
|
|
return result
|
|
return result
|
|
@@ -224,7 +296,7 @@ async def process_single_task(
|
|
|
task: Dict,
|
|
task: Dict,
|
|
|
task_index: int,
|
|
task_index: int,
|
|
|
total_tasks: int,
|
|
total_tasks: int,
|
|
|
- persona_inspiration_features: List[Dict],
|
|
|
|
|
|
|
+ all_persona_features: List[Dict],
|
|
|
category_mapping: Dict = None,
|
|
category_mapping: Dict = None,
|
|
|
model_name: str = None
|
|
model_name: str = None
|
|
|
) -> Dict:
|
|
) -> Dict:
|
|
@@ -235,7 +307,7 @@ async def process_single_task(
|
|
|
task: 任务数据
|
|
task: 任务数据
|
|
|
task_index: 任务索引(从1开始)
|
|
task_index: 任务索引(从1开始)
|
|
|
total_tasks: 总任务数
|
|
total_tasks: 总任务数
|
|
|
- persona_inspiration_features: 人设灵感特征列表
|
|
|
|
|
|
|
+ all_persona_features: 所有人设特征列表(包含三种层级)
|
|
|
category_mapping: 特征分类映射字典
|
|
category_mapping: 特征分类映射字典
|
|
|
model_name: 使用的模型名称
|
|
model_name: 使用的模型名称
|
|
|
|
|
|
|
@@ -243,30 +315,35 @@ async def process_single_task(
|
|
|
包含 how 解构结果的任务
|
|
包含 how 解构结果的任务
|
|
|
"""
|
|
"""
|
|
|
post_id = task.get("帖子id", "")
|
|
post_id = task.get("帖子id", "")
|
|
|
- print(f"\n处理任务 [{task_index}/{total_tasks}]: {post_id}")
|
|
|
|
|
|
|
+ print(f"\n[{task_index}/{total_tasks}] 处理帖子: {post_id}")
|
|
|
|
|
|
|
|
- # 获取灵感点列表
|
|
|
|
|
|
|
+ # 获取 what 解构结果
|
|
|
what_result = task.get("what解构结果", {})
|
|
what_result = task.get("what解构结果", {})
|
|
|
- inspiration_list = what_result.get("灵感点列表", [])
|
|
|
|
|
-
|
|
|
|
|
- print(f" 灵感点数量: {len(inspiration_list)}")
|
|
|
|
|
-
|
|
|
|
|
- # 并发处理所有灵感点
|
|
|
|
|
- tasks = [
|
|
|
|
|
- process_single_inspiration_point(
|
|
|
|
|
- inspiration_point=inspiration_point,
|
|
|
|
|
- persona_features=persona_inspiration_features,
|
|
|
|
|
- category_mapping=category_mapping,
|
|
|
|
|
- model_name=model_name
|
|
|
|
|
- )
|
|
|
|
|
- for inspiration_point in inspiration_list
|
|
|
|
|
- ]
|
|
|
|
|
- updated_inspiration_list = await asyncio.gather(*tasks)
|
|
|
|
|
|
|
|
|
|
# 构建 how 解构结果
|
|
# 构建 how 解构结果
|
|
|
- how_result = {
|
|
|
|
|
- "灵感点列表": list(updated_inspiration_list)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ how_result = {}
|
|
|
|
|
+
|
|
|
|
|
+ # 处理灵感点、关键点和目的点
|
|
|
|
|
+ for point_type in ["灵感点", "关键点", "目的点"]:
|
|
|
|
|
+ point_list_key = f"{point_type}列表"
|
|
|
|
|
+ point_list = what_result.get(point_list_key, [])
|
|
|
|
|
+
|
|
|
|
|
+ if point_list:
|
|
|
|
|
+ # 并发处理所有点
|
|
|
|
|
+ tasks = [
|
|
|
|
|
+ process_single_point(
|
|
|
|
|
+ point=point,
|
|
|
|
|
+ point_type=point_type,
|
|
|
|
|
+ persona_features=all_persona_features,
|
|
|
|
|
+ category_mapping=category_mapping,
|
|
|
|
|
+ model_name=model_name
|
|
|
|
|
+ )
|
|
|
|
|
+ for point in point_list
|
|
|
|
|
+ ]
|
|
|
|
|
+ updated_point_list = await asyncio.gather(*tasks)
|
|
|
|
|
+
|
|
|
|
|
+ # 添加到 how 解构结果
|
|
|
|
|
+ how_result[point_list_key] = list(updated_point_list)
|
|
|
|
|
|
|
|
# 更新任务
|
|
# 更新任务
|
|
|
updated_task = task.copy()
|
|
updated_task = task.copy()
|
|
@@ -293,27 +370,57 @@ async def process_task_list(
|
|
|
Returns:
|
|
Returns:
|
|
|
包含 how 解构结果的任务列表
|
|
包含 how 解构结果的任务列表
|
|
|
"""
|
|
"""
|
|
|
- # 获取标签特征列表
|
|
|
|
|
- persona_inspiration_features = persona_features_dict.get("灵感点", [])
|
|
|
|
|
- print(f"人设标签特征数量: {len(persona_inspiration_features)}")
|
|
|
|
|
-
|
|
|
|
|
- # 从分类映射中提取所有唯一的分类作为分类特征(仅从灵感点中提取)
|
|
|
|
|
- category_features = []
|
|
|
|
|
- if category_mapping:
|
|
|
|
|
- all_categories = set()
|
|
|
|
|
- # 只从灵感点中提取分类
|
|
|
|
|
- if "灵感点" in category_mapping:
|
|
|
|
|
- for _, feature_data in category_mapping["灵感点"].items():
|
|
|
|
|
|
|
+ global progress_tracker
|
|
|
|
|
+
|
|
|
|
|
+ # 合并三种人设特征(灵感点、关键点、目的点)
|
|
|
|
|
+ all_features = []
|
|
|
|
|
+
|
|
|
|
|
+ for feature_type in ["灵感点", "关键点", "目的点"]:
|
|
|
|
|
+ # 获取该类型的标签特征
|
|
|
|
|
+ type_features = persona_features_dict.get(feature_type, [])
|
|
|
|
|
+
|
|
|
|
|
+ # 为每个特征添加层级信息
|
|
|
|
|
+ for feature in type_features:
|
|
|
|
|
+ feature_with_level = feature.copy()
|
|
|
|
|
+ feature_with_level["人设特征层级"] = feature_type
|
|
|
|
|
+ all_features.append(feature_with_level)
|
|
|
|
|
+
|
|
|
|
|
+ print(f"人设{feature_type}标签特征数量: {len(type_features)}")
|
|
|
|
|
+
|
|
|
|
|
+ # 从分类映射中提取该类型的分类特征
|
|
|
|
|
+ if category_mapping and feature_type in category_mapping:
|
|
|
|
|
+ type_categories = set()
|
|
|
|
|
+ for _, feature_data in category_mapping[feature_type].items():
|
|
|
categories = feature_data.get("所属分类", [])
|
|
categories = feature_data.get("所属分类", [])
|
|
|
- all_categories.update(categories)
|
|
|
|
|
|
|
+ type_categories.update(categories)
|
|
|
|
|
+
|
|
|
|
|
+ # 转换为特征格式并添加层级信息
|
|
|
|
|
+ for cat in sorted(type_categories):
|
|
|
|
|
+ all_features.append({
|
|
|
|
|
+ "特征名称": cat,
|
|
|
|
|
+ "人设特征层级": feature_type
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ print(f"人设{feature_type}分类特征数量: {len(type_categories)}")
|
|
|
|
|
|
|
|
- # 转换为特征格式
|
|
|
|
|
- category_features = [{"特征名称": cat} for cat in sorted(all_categories)]
|
|
|
|
|
- print(f"人设分类特征数量: {len(category_features)}")
|
|
|
|
|
|
|
+ print(f"总特征数量(三种类型的标签+分类): {len(all_features)}")
|
|
|
|
|
|
|
|
- # 合并标签特征和分类特征
|
|
|
|
|
- all_features = persona_inspiration_features + category_features
|
|
|
|
|
- print(f"总特征数量(标签+分类): {len(all_features)}")
|
|
|
|
|
|
|
+ # 计算总匹配任务数(灵感点、关键点和目的点)
|
|
|
|
|
+ total_match_count = 0
|
|
|
|
|
+ for task in task_list:
|
|
|
|
|
+ what_result = task.get("what解构结果", {})
|
|
|
|
|
+ for point_type in ["灵感点", "关键点", "目的点"]:
|
|
|
|
|
+ point_list = what_result.get(f"{point_type}列表", [])
|
|
|
|
|
+ for point in point_list:
|
|
|
|
|
+ feature_count = len(point.get("特征列表", []))
|
|
|
|
|
+ total_match_count += feature_count * len(all_features)
|
|
|
|
|
+
|
|
|
|
|
+ print(f"处理灵感点、关键点和目的点特征")
|
|
|
|
|
+ print(f"总匹配任务数: {total_match_count:,}")
|
|
|
|
|
+ print()
|
|
|
|
|
+
|
|
|
|
|
+ # 初始化全局进度跟踪器
|
|
|
|
|
+ progress_tracker = ProgressTracker(total_match_count)
|
|
|
|
|
|
|
|
# 并发处理所有任务
|
|
# 并发处理所有任务
|
|
|
tasks = [
|
|
tasks = [
|
|
@@ -321,7 +428,7 @@ async def process_task_list(
|
|
|
task=task,
|
|
task=task,
|
|
|
task_index=i,
|
|
task_index=i,
|
|
|
total_tasks=len(task_list),
|
|
total_tasks=len(task_list),
|
|
|
- persona_inspiration_features=all_features,
|
|
|
|
|
|
|
+ all_persona_features=all_features,
|
|
|
category_mapping=category_mapping,
|
|
category_mapping=category_mapping,
|
|
|
model_name=model_name
|
|
model_name=model_name
|
|
|
)
|
|
)
|
|
@@ -384,19 +491,42 @@ async def main():
|
|
|
print("\n完成!")
|
|
print("\n完成!")
|
|
|
|
|
|
|
|
# 打印统计信息
|
|
# 打印统计信息
|
|
|
- total_inspiration_points = sum(
|
|
|
|
|
- len(task["how解构结果"]["灵感点列表"])
|
|
|
|
|
- for task in updated_task_list
|
|
|
|
|
- )
|
|
|
|
|
- total_features = sum(
|
|
|
|
|
- len(point["特征列表"])
|
|
|
|
|
- for task in updated_task_list
|
|
|
|
|
- for point in task["how解构结果"]["灵感点列表"]
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ total_inspiration_points = 0
|
|
|
|
|
+ total_key_points = 0
|
|
|
|
|
+ total_purpose_points = 0
|
|
|
|
|
+ total_inspiration_features = 0
|
|
|
|
|
+ total_key_features = 0
|
|
|
|
|
+ total_purpose_features = 0
|
|
|
|
|
+
|
|
|
|
|
+ for task in updated_task_list:
|
|
|
|
|
+ how_result = task.get("how解构结果", {})
|
|
|
|
|
+
|
|
|
|
|
+ # 统计灵感点
|
|
|
|
|
+ inspiration_list = how_result.get("灵感点列表", [])
|
|
|
|
|
+ total_inspiration_points += len(inspiration_list)
|
|
|
|
|
+ for point in inspiration_list:
|
|
|
|
|
+ total_inspiration_features += len(point.get("特征列表", []))
|
|
|
|
|
+
|
|
|
|
|
+ # 统计关键点
|
|
|
|
|
+ key_list = how_result.get("关键点列表", [])
|
|
|
|
|
+ total_key_points += len(key_list)
|
|
|
|
|
+ for point in key_list:
|
|
|
|
|
+ total_key_features += len(point.get("特征列表", []))
|
|
|
|
|
+
|
|
|
|
|
+ # 统计目的点
|
|
|
|
|
+ purpose_list = how_result.get("目的点列表", [])
|
|
|
|
|
+ total_purpose_points += len(purpose_list)
|
|
|
|
|
+ for point in purpose_list:
|
|
|
|
|
+ total_purpose_features += len(point.get("特征列表", []))
|
|
|
|
|
+
|
|
|
print(f"\n统计:")
|
|
print(f"\n统计:")
|
|
|
print(f" 处理的帖子数: {len(updated_task_list)}")
|
|
print(f" 处理的帖子数: {len(updated_task_list)}")
|
|
|
print(f" 处理的灵感点数: {total_inspiration_points}")
|
|
print(f" 处理的灵感点数: {total_inspiration_points}")
|
|
|
- print(f" 处理的特征数: {total_features}")
|
|
|
|
|
|
|
+ print(f" 处理的灵感点特征数: {total_inspiration_features}")
|
|
|
|
|
+ print(f" 处理的关键点数: {total_key_points}")
|
|
|
|
|
+ print(f" 处理的关键点特征数: {total_key_features}")
|
|
|
|
|
+ print(f" 处理的目的点数: {total_purpose_points}")
|
|
|
|
|
+ print(f" 处理的目的点特征数: {total_purpose_features}")
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|