#!/usr/bin/env python3
"""
Tab1内容生成器 - 选题点(灵感点、目的点、关键点)
"""
import html as html_module
from typing import Dict, Any
def generate_tab1_content(data: Dict[str, Any]) -> str:
"""生成Tab1内容:选题、灵感点、目的点、关键点"""
html = '
\n'
# 选题描述
if '选题描述' in data:
topic = data['选题描述']
html += '
\n'
html += '
选题描述
\n'
if '主题' in topic:
html += f'
主题:{html_module.escape(topic["主题"])}
\n'
if '描述' in topic:
html += f'
描述:{html_module.escape(topic["描述"])}
\n'
html += '
\n'
# 灵感点
if '灵感点' in data:
inspiration = data['灵感点']
html += '
\n'
html += '
灵感点
\n'
if isinstance(inspiration, list):
for idx, item in enumerate(inspiration, 1):
point_text = item.get('灵感点', '')
description = item.get('描述', '')
features = item.get('提取的特征', [])
scoring = item.get('scoring', {})
html += f'
\n'
html += f'\n'
if description:
html += f'
{html_module.escape(description)}
\n'
# 显示提取的特征
if features:
html += f'
\n'
html += f'
提取的特征:\n'
html += f'
\n'
for feature in features:
feature_name = feature.get('特征名称', '')
weight = feature.get('权重', 0)
dimension = feature.get('维度分类', '')
html += f'{html_module.escape(feature_name)} '
if dimension:
html += f'({html_module.escape(dimension)}) '
html += f'权重:{weight}\n'
html += f'
\n'
html += f'
\n'
# 显示评分信息
if scoring:
html += f'
\n'
html += f'
评分:\n'
html += f'
\n'
if '人设契合度' in scoring:
html += f'人设契合度: {scoring["人设契合度"]}/10\n'
if '触发可能性' in scoring:
html += f'触发可能性: {scoring["触发可能性"]}/10\n'
if '内容解释力' in scoring:
html += f'内容解释力: {scoring["内容解释力"]}/10\n'
if '总分' in scoring:
html += f'总分: {scoring["总分"]}\n'
html += f'
\n'
html += f'
\n'
html += f'
\n'
html += '
\n'
# 目的点
if '目的点' in data:
purpose = data['目的点']
html += '
\n'
html += '
目的点
\n'
if isinstance(purpose, list):
for idx, item in enumerate(purpose, 1):
point_text = item.get('目的点', '')
description = item.get('描述', '')
dimension = item.get('维度', {})
features = item.get('提取的特征', [])
html += f'
\n'
html += f'\n'
if description:
html += f'
{html_module.escape(description)}
\n'
# 显示提取的特征
if features:
html += f'
\n'
html += f'
提取的特征:\n'
html += f'
\n'
for feature in features:
feature_name = feature.get('特征名称', '')
weight = feature.get('权重', 0)
feature_class = feature.get('特征分类', '')
html += f'{html_module.escape(feature_name)} '
if feature_class:
html += f'({html_module.escape(feature_class)}) '
html += f'权重:{weight}\n'
html += f'
\n'
html += f'
\n'
html += f'
\n'
html += '
\n'
# 关键点
if '关键点' in data:
keypoint = data['关键点']
html += '
\n'
html += '
关键点
\n'
if isinstance(keypoint, list):
for idx, item in enumerate(keypoint, 1):
point_text = item.get('关键点', '')
description = item.get('描述', '')
dimension = item.get('维度', '')
features = item.get('提取的特征', [])
html += f'
\n'
html += f'\n'
if description:
html += f'
{html_module.escape(description)}
\n'
# 显示提取的特征
if features:
html += f'
\n'
html += f'
提取的特征:\n'
html += f'
\n'
for feature in features:
feature_name = feature.get('特征名称', '')
weight = feature.get('权重', 0)
feature_dimension = feature.get('维度', '')
html += f'{html_module.escape(feature_name)} '
if feature_dimension:
html += f'({html_module.escape(feature_dimension)}) '
html += f'权重:{weight}\n'
html += f'
\n'
html += f'
\n'
html += f'
\n'
html += '
\n'
html += '
\n'
return html