| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- #!/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 = '<div class="tab-content" id="tab1">\n'
- # 选题描述
- if '选题描述' in data:
- topic = data['选题描述']
- html += '<div class="section">\n'
- html += '<h3>选题描述</h3>\n'
- if '主题' in topic:
- html += f'<div class="topic-theme"><strong>主题:</strong>{html_module.escape(topic["主题"])}</div>\n'
- if '描述' in topic:
- html += f'<div class="topic-desc"><strong>描述:</strong>{html_module.escape(topic["描述"])}</div>\n'
- html += '</div>\n'
- # 灵感点
- if '灵感点' in data:
- inspiration = data['灵感点']
- html += '<div class="section">\n'
- html += '<h3>灵感点</h3>\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'<div class="point-item inspiration-item">\n'
- html += f'<div class="point-header">\n'
- html += f'<span class="point-number">#{idx}</span>\n'
- html += f'<span class="point-text">{html_module.escape(point_text)}</span>\n'
- html += f'</div>\n'
- if description:
- html += f'<div class="point-description">{html_module.escape(description)}</div>\n'
- # 显示提取的特征
- if features:
- html += f'<div class="point-features">\n'
- html += f'<strong>提取的特征:</strong>\n'
- html += f'<div class="feature-tags">\n'
- for feature in features:
- feature_name = feature.get('特征名称', '')
- weight = feature.get('权重', 0)
- dimension = feature.get('维度分类', '')
- html += f'<span class="feature-tag">{html_module.escape(feature_name)} '
- if dimension:
- html += f'<em class="feature-dimension">({html_module.escape(dimension)})</em> '
- html += f'<strong class="feature-weight">权重:{weight}</strong></span>\n'
- html += f'</div>\n'
- html += f'</div>\n'
- # 显示评分信息
- if scoring:
- html += f'<div class="point-scoring">\n'
- html += f'<strong>评分:</strong>\n'
- html += f'<div class="scoring-badges">\n'
- if '人设契合度' in scoring:
- html += f'<span class="scoring-badge">人设契合度: {scoring["人设契合度"]}/10</span>\n'
- if '触发可能性' in scoring:
- html += f'<span class="scoring-badge">触发可能性: {scoring["触发可能性"]}/10</span>\n'
- if '内容解释力' in scoring:
- html += f'<span class="scoring-badge">内容解释力: {scoring["内容解释力"]}/10</span>\n'
- if '总分' in scoring:
- html += f'<span class="scoring-badge total-score">总分: {scoring["总分"]}</span>\n'
- html += f'</div>\n'
- html += f'</div>\n'
- html += f'</div>\n'
- html += '</div>\n'
- # 目的点
- if '目的点' in data:
- purpose = data['目的点']
- html += '<div class="section">\n'
- html += '<h3>目的点</h3>\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'<div class="point-item purpose-item">\n'
- html += f'<div class="point-header">\n'
- html += f'<span class="point-number">#{idx}</span>\n'
- html += f'<span class="point-text">{html_module.escape(point_text)}</span>\n'
- # 显示维度标签
- if dimension:
- html += f'<div class="dimension-tags">\n'
- if '一级分类' in dimension:
- html += f'<span class="dimension-tag level-1">{html_module.escape(dimension["一级分类"])}</span>\n'
- if '二级分类' in dimension:
- html += f'<span class="dimension-tag level-2">{html_module.escape(dimension["二级分类"])}</span>\n'
- html += f'</div>\n'
- html += f'</div>\n'
- if description:
- html += f'<div class="point-description">{html_module.escape(description)}</div>\n'
- # 显示提取的特征
- if features:
- html += f'<div class="point-features">\n'
- html += f'<strong>提取的特征:</strong>\n'
- html += f'<div class="feature-tags">\n'
- for feature in features:
- feature_name = feature.get('特征名称', '')
- weight = feature.get('权重', 0)
- feature_class = feature.get('特征分类', '')
- html += f'<span class="feature-tag">{html_module.escape(feature_name)} '
- if feature_class:
- html += f'<em class="feature-dimension">({html_module.escape(feature_class)})</em> '
- html += f'<strong class="feature-weight">权重:{weight}</strong></span>\n'
- html += f'</div>\n'
- html += f'</div>\n'
- html += f'</div>\n'
- html += '</div>\n'
- # 关键点
- if '关键点' in data:
- keypoint = data['关键点']
- html += '<div class="section">\n'
- html += '<h3>关键点</h3>\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'<div class="point-item keypoint-item">\n'
- html += f'<div class="point-header">\n'
- html += f'<span class="point-number">#{idx}</span>\n'
- html += f'<span class="point-text">{html_module.escape(point_text)}</span>\n'
- # 显示维度标签
- if dimension:
- html += f'<span class="dimension-tag keypoint-dimension">{html_module.escape(dimension)}</span>\n'
- html += f'</div>\n'
- if description:
- html += f'<div class="point-description">{html_module.escape(description)}</div>\n'
- # 显示提取的特征
- if features:
- html += f'<div class="point-features">\n'
- html += f'<strong>提取的特征:</strong>\n'
- html += f'<div class="feature-tags">\n'
- for feature in features:
- feature_name = feature.get('特征名称', '')
- weight = feature.get('权重', 0)
- feature_dimension = feature.get('维度', '')
- html += f'<span class="feature-tag">{html_module.escape(feature_name)} '
- if feature_dimension:
- html += f'<em class="feature-dimension">({html_module.escape(feature_dimension)})</em> '
- html += f'<strong class="feature-weight">权重:{weight}</strong></span>\n'
- html += f'</div>\n'
- html += f'</div>\n'
- html += f'</div>\n'
- html += '</div>\n'
- html += '</div>\n'
- return html
|