Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /liuxiaotong_ai-dataset-radar /src /intel_report.py
| """Intelligence report generator for competitive analysis. | |
| Generates structured markdown reports with: | |
| - US AI Labs activity (HuggingFace) | |
| - Data vendor monitoring (GitHub + Blogs + HuggingFace) | |
| - Datasets categorized by training type (enhanced classifier) | |
| - Papers filtered and categorized by topic | |
| """ | |
| from datetime import datetime | |
| from _version import __version__ | |
| from analyzers.data_type_classifier import DataType, DataTypeClassifier | |
| from trackers.blog_tracker import map_blog_to_vendor | |
| class IntelReportGenerator: | |
| """Generate competitive intelligence reports.""" | |
| def __init__(self, config: dict): | |
| """Initialize the report generator. | |
| Args: | |
| config: Configuration dict. | |
| """ | |
| self.config = config | |
| report_config = config.get("report", {}) | |
| self.limits = report_config.get("limits", {}) | |
| def generate( | |
| self, | |
| lab_activity: dict, | |
| vendor_activity: dict, | |
| datasets_by_type: dict, | |
| papers: list[dict], | |
| github_activity: list[dict] = None, | |
| blog_activity: list[dict] = None, | |
| x_activity: dict = None, | |
| reddit_activity: dict = None, | |
| hn_activity: dict = None, | |
| kaggle_datasets: list[dict] = None, | |
| trend_data: dict = None, | |
| competitor_matrix: dict = None, | |
| dataset_lineage: dict = None, | |
| org_graph: dict = None, | |
| ) -> str: | |
| """Generate the full intelligence report. | |
| Args: | |
| lab_activity: Activity from AI labs. | |
| vendor_activity: Activity from data vendors. | |
| datasets_by_type: Datasets grouped by training type. | |
| papers: Relevant research papers. | |
| github_activity: GitHub organization activities. | |
| blog_activity: Blog/RSS activities. | |
| x_activity: X/Twitter activity data. | |
| reddit_activity: Reddit community activity data. | |
| hn_activity: Hacker News activity data. | |
| kaggle_datasets: Kaggle dataset listings. | |
| trend_data: Trend analysis results (top_growing_7d, rising_7d). | |
| Returns: | |
| Markdown formatted report. | |
| """ | |
| lines = [] | |
| # Header | |
| lines.append("# AI 数据情报周报") | |
| lines.append(f"> Generated: {datetime.now().strftime('%Y-%m-%d %H:%M')}") | |
| lines.append("") | |
| # Executive Summary | |
| lines.extend( | |
| self._generate_summary( | |
| lab_activity, | |
| vendor_activity, | |
| datasets_by_type, | |
| github_activity, | |
| blog_activity, | |
| ) | |
| ) | |
| # US AI Labs Activity | |
| lines.extend(self._generate_labs_section(lab_activity)) | |
| # Data Vendor Activity (enhanced with GitHub + Blogs) | |
| lines.extend( | |
| self._generate_vendors_section(vendor_activity, github_activity, blog_activity) | |
| ) | |
| # Datasets by Type | |
| lines.extend(self._generate_datasets_section(datasets_by_type)) | |
| # Dataset Trends | |
| lines.extend(self._generate_trends_section(trend_data)) | |
| # Papers (categorized) | |
| lines.extend(self._generate_papers_section(papers)) | |
| # Papers with Code datasets | |
| # X/Twitter Activity | |
| lines.extend(self._generate_x_section(x_activity)) | |
| # Reddit Activity | |
| lines.extend(self._generate_reddit_section(reddit_activity)) | |
| # Competitor Matrix | |
| lines.extend(self._generate_competitor_matrix_section(competitor_matrix)) | |
| # Dataset Lineage | |
| lines.extend(self._generate_lineage_section(dataset_lineage)) | |
| # Organization Relationship Graph | |
| lines.extend(self._generate_org_graph_section(org_graph)) | |
| # Footer | |
| lines.append("---") | |
| lines.append(f"> Report generated by AI Dataset Radar v{__version__} — Competitive Intelligence System") | |
| return "\n".join(lines) | |
| def _generate_trends_section(self, trend_data: dict = None) -> list[str]: | |
| """Generate dataset growth trends section. | |
| Args: | |
| trend_data: Dict with top_growing_7d and rising_7d lists. | |
| Returns: | |
| List of markdown lines. Empty if no trend data. | |
| """ | |
| if not trend_data: | |
| return [] | |
| top_growing = trend_data.get("top_growing_7d", []) | |
| if not top_growing: | |
| return [] | |
| lines = [] | |
| lines.append("") | |
| lines.append("## 📈 数据集增长趋势") | |
| lines.append("") | |
| lines.append("| 数据集 | 当前下载 | 7天增长 |") | |
| lines.append("|--------|---------|---------|") | |
| for ds in top_growing[:10]: | |
| name = ds.get("name", ds.get("dataset_id", "Unknown")) | |
| downloads = ds.get("current_downloads", 0) or 0 | |
| growth = ds.get("growth", 0) | |
| if growth is None: | |
| continue | |
| if growth == float("inf"): | |
| growth_str = "新增" | |
| else: | |
| growth_str = f"{growth * 100:+.1f}%" | |
| lines.append(f"| {name} | {downloads:,} | {growth_str} |") | |
| lines.append("") | |
| return lines | |
| def _generate_summary( | |
| self, | |
| lab_activity: dict, | |
| vendor_activity: dict, | |
| datasets_by_type: dict, | |
| github_activity: list[dict] = None, | |
| blog_activity: list[dict] = None, | |
| ) -> list[str]: | |
| """Generate executive summary section.""" | |
| lines = [] | |
| lines.append("## 📊 本周摘要") | |
| lines.append("") | |
| # Count labs with activity | |
| active_labs = 0 | |
| lab_datasets = 0 | |
| for category in lab_activity.get("labs", {}).values(): | |
| for org_data in category.values(): | |
| if org_data.get("datasets") or org_data.get("models"): | |
| active_labs += 1 | |
| lab_datasets += len(org_data.get("datasets", [])) | |
| # Count vendor activities | |
| active_vendors = 0 | |
| vendor_datasets = 0 | |
| for tier in vendor_activity.get("vendors", {}).values(): | |
| for vendor_data in tier.values(): | |
| if vendor_data.get("datasets"): | |
| active_vendors += 1 | |
| vendor_datasets += len(vendor_data.get("datasets", [])) | |
| # GitHub activity | |
| github_repos = 0 | |
| github_orgs = 0 | |
| if github_activity: | |
| for activity in github_activity: | |
| if activity.get("repos_updated"): | |
| github_orgs += 1 | |
| github_repos += len(activity["repos_updated"]) | |
| # Blog activity | |
| blog_articles = 0 | |
| blog_sources = 0 | |
| if blog_activity: | |
| for activity in blog_activity: | |
| if activity.get("articles"): | |
| blog_sources += 1 | |
| blog_articles += len(activity["articles"]) | |
| # Count by type | |
| type_counts = {} | |
| total_datasets = 0 | |
| other_count = 0 | |
| for dtype, datasets in datasets_by_type.items(): | |
| count = len(datasets) | |
| total_datasets += count | |
| # Handle both DataType enum and string keys | |
| key = dtype.value if isinstance(dtype, DataType) else str(dtype) | |
| type_counts[key] = count | |
| if dtype == DataType.OTHER or key == "other": | |
| other_count = count | |
| # Calculate other ratio | |
| other_ratio = other_count / total_datasets if total_datasets > 0 else 0 | |
| lines.append(f"- **活跃 AI Labs**: {active_labs} 家,发布 {lab_datasets} 个数据集") | |
| lines.append( | |
| f"- **数据供应商监控**: HF({active_vendors}家), GitHub({github_orgs}组织/{github_repos}仓库), 博客({blog_sources}源/{blog_articles}文章)" | |
| ) | |
| lines.append( | |
| f"- **高价值数据集**: {total_datasets} 个(已分类 {total_datasets - other_count} 个)" | |
| ) | |
| if type_counts: | |
| # Sort by count, exclude "other" from top display | |
| sorted_types = sorted( | |
| [(k, v) for k, v in type_counts.items() if k != "other"], | |
| key=lambda x: x[1], | |
| reverse=True, | |
| )[:4] | |
| if sorted_types: | |
| top_str = ", ".join(f"{dtype}({count})" for dtype, count in sorted_types) | |
| lines.append(f"- **热门类型**: {top_str}") | |
| # Warning if too many unclassified | |
| if other_ratio > 0.3: | |
| lines.append(f"- **⚠️ 分类覆盖率**: {1 - other_ratio:.0%}({other_count}个未分类)") | |
| lines.append("") | |
| return lines | |
| def _generate_labs_section(self, lab_activity: dict) -> list[str]: | |
| """Generate US AI Labs section.""" | |
| lines = [] | |
| lines.append("## 🔬 美国 AI Labs 动态") | |
| lines.append("") | |
| labs = lab_activity.get("labs", {}) | |
| limit = self.limits.get("labs_per_category", 10) | |
| # Frontier Labs | |
| frontier = labs.get("frontier_labs", {}) | |
| if frontier: | |
| lines.append("### Frontier Labs(一线实验室)") | |
| lines.append("") | |
| lines.append("| 机构 | 本周数据集 | 本周模型 | 代表内容 |") | |
| lines.append("|------|-----------|---------|---------|") | |
| for org_name, org_data in list(frontier.items())[:limit]: | |
| ds_count = len(org_data.get("datasets", [])) | |
| model_count = len(org_data.get("models", [])) | |
| rep = "" | |
| if org_data.get("datasets"): | |
| ds = org_data["datasets"][0] | |
| rep = ds.get("id", "").split("/")[-1][:30] | |
| elif org_data.get("models"): | |
| model = org_data["models"][0] | |
| rep = model.get("id", "").split("/")[-1][:30] | |
| org_display = org_name.replace("_", " ").title() | |
| lines.append(f"| {org_display} | {ds_count} | {model_count} | {rep} |") | |
| lines.append("") | |
| # Details for frontier labs with datasets | |
| for org_name, org_data in list(frontier.items())[:5]: | |
| if org_data.get("datasets"): | |
| org_display = org_name.replace("_", " ").title() | |
| lines.append(f"**{org_display}** 数据集:") | |
| for ds in org_data["datasets"][:3]: | |
| ds_id = ds.get("id", "Unknown") | |
| ds_name = ds_id.split("/")[-1] if "/" in ds_id else ds_id | |
| downloads = ds.get("downloads", 0) | |
| lines.append( | |
| f"- [{ds_name}](https://huggingface.co/datasets/{ds_id}) ({downloads:,} downloads)" | |
| ) | |
| lines.append("") | |
| # Emerging Labs | |
| emerging = labs.get("emerging_labs", {}) | |
| if emerging: | |
| lines.append("### Emerging Labs(新兴实验室)") | |
| lines.append("") | |
| lines.append("| 机构 | 数据集 | 模型 | 代表内容 |") | |
| lines.append("|------|--------|------|---------|") | |
| for org_name, org_data in list(emerging.items())[:limit]: | |
| ds_count = len(org_data.get("datasets", [])) | |
| model_count = len(org_data.get("models", [])) | |
| rep = "" | |
| if org_data.get("datasets"): | |
| rep = org_data["datasets"][0].get("id", "").split("/")[-1][:30] | |
| org_display = org_name.replace("_", " ").title() | |
| lines.append(f"| {org_display} | {ds_count} | {model_count} | {rep} |") | |
| lines.append("") | |
| # Research Labs | |
| research = labs.get("research_labs", {}) | |
| if research: | |
| lines.append("### Research Labs(研究机构)") | |
| lines.append("") | |
| lines.append("| 机构 | 数据集 | 模型 | 代表内容 |") | |
| lines.append("|------|--------|------|---------|") | |
| for org_name, org_data in list(research.items())[:limit]: | |
| ds_count = len(org_data.get("datasets", [])) | |
| model_count = len(org_data.get("models", [])) | |
| rep = "" | |
| if org_data.get("datasets"): | |
| rep = org_data["datasets"][0].get("id", "").split("/")[-1][:30] | |
| org_display = org_name.replace("_", " ").title() | |
| lines.append(f"| {org_display} | {ds_count} | {model_count} | {rep} |") | |
| lines.append("") | |
| if not frontier and not emerging and not research: | |
| lines.append("本周无监控目标的新活动") | |
| lines.append("") | |
| return lines | |
| def _generate_vendors_section( | |
| self, | |
| vendor_activity: dict, | |
| github_activity: list[dict] = None, | |
| blog_activity: list[dict] = None, | |
| ) -> list[str]: | |
| """Generate data vendor section with GitHub + Blog data.""" | |
| lines = [] | |
| lines.append("## 🏢 数据供应商动态(竞品监控)") | |
| lines.append("") | |
| # Aggregate all vendor activities by vendor name | |
| vendors = {} | |
| # HuggingFace datasets | |
| hf_vendors = vendor_activity.get("vendors", {}) | |
| for tier_data in hf_vendors.values(): | |
| for vendor_name, vendor_data in tier_data.items(): | |
| if vendor_name not in vendors: | |
| vendors[vendor_name] = {"datasets": [], "github": [], "blog": []} | |
| vendors[vendor_name]["datasets"].extend(vendor_data.get("datasets", [])) | |
| # GitHub activity | |
| if github_activity: | |
| for activity in github_activity: | |
| org = activity.get("org", "") | |
| # Normalize org name | |
| vendor_key = org.lower().replace("-", "_") | |
| if vendor_key not in vendors: | |
| vendors[vendor_key] = {"datasets": [], "github": [], "blog": []} | |
| vendors[vendor_key]["github"].extend(activity.get("repos_updated", [])) | |
| # Blog activity | |
| if blog_activity: | |
| for activity in blog_activity: | |
| source = activity.get("source", "") | |
| vendor_key = map_blog_to_vendor(source) | |
| if vendor_key not in vendors: | |
| vendors[vendor_key] = {"datasets": [], "github": [], "blog": []} | |
| vendors[vendor_key]["blog"].extend(activity.get("articles", [])) | |
| # Check if any vendor has activity | |
| has_activity = any(v["datasets"] or v["github"] or v["blog"] for v in vendors.values()) | |
| if not has_activity: | |
| lines.append("本周无监控供应商的公开动态") | |
| lines.append("") | |
| return lines | |
| # Generate sections for each vendor with activity | |
| for vendor_name, activity in sorted(vendors.items()): | |
| if not any([activity["datasets"], activity["github"], activity["blog"]]): | |
| continue | |
| vendor_display = vendor_name.replace("_", " ").title() | |
| lines.append(f"### {vendor_display}") | |
| lines.append("") | |
| # Blog articles | |
| if activity["blog"]: | |
| lines.append("**📰 博客动态**") | |
| for article in activity["blog"][:3]: | |
| title = article.get("title", "")[:60] | |
| url = article.get("url", "") | |
| summary = article.get("summary", "")[:80] | |
| if summary: | |
| summary = f" - {summary}..." | |
| lines.append(f"- [{title}]({url}){summary}") | |
| lines.append("") | |
| # GitHub repos | |
| if activity["github"]: | |
| lines.append("**💻 GitHub 活动**") | |
| for repo in activity["github"][:3]: | |
| name = repo.get("name", "") | |
| desc = repo.get("description", "No description")[:60] | |
| url = repo.get("url", "") | |
| signals = repo.get("signals", []) | |
| stars = repo.get("stars", 0) | |
| lines.append(f"- [`{name}`]({url}) ⭐{stars}") | |
| lines.append(f" {desc}") | |
| if signals: | |
| lines.append(f" 信号: {', '.join(signals[:3])}") | |
| lines.append("") | |
| # HuggingFace datasets | |
| if activity["datasets"]: | |
| lines.append("**📦 数据集发布**") | |
| for ds in activity["datasets"][:3]: | |
| ds_id = ds.get("id", "Unknown") | |
| ds_name = ds_id.split("/")[-1] if "/" in ds_id else ds_id | |
| downloads = ds.get("downloads", 0) | |
| lines.append( | |
| f"- [{ds_name}](https://huggingface.co/datasets/{ds_id}) ({downloads:,} downloads)" | |
| ) | |
| lines.append("") | |
| return lines | |
| def _generate_datasets_section(self, datasets_by_type: dict) -> list[str]: | |
| """Generate datasets by type section with DataType enum support.""" | |
| lines = [] | |
| lines.append("## 📊 高价值数据集(按类型)") | |
| lines.append("") | |
| # Calculate other ratio for warning | |
| total = sum(len(ds) for ds in datasets_by_type.values()) | |
| other_key = DataType.OTHER | |
| other_count = len(datasets_by_type.get(other_key, [])) | |
| # Also check string key | |
| if not other_count: | |
| other_count = len(datasets_by_type.get("other", [])) | |
| other_ratio = other_count / total if total > 0 else 0 | |
| if other_ratio > 0.3: | |
| lines.append(f"> ⚠️ 注意:{other_ratio:.0%} 的数据集未能分类,建议检查分类规则") | |
| lines.append("") | |
| limit = self.limits.get("datasets_per_type", 10) | |
| # Get ordered types | |
| ordered_types = DataTypeClassifier.get_ordered_types() | |
| for dtype, display_name in ordered_types: | |
| # Check both enum and string key | |
| datasets = datasets_by_type.get(dtype, []) | |
| if not datasets: | |
| datasets = datasets_by_type.get(dtype.value, []) | |
| if not datasets: | |
| continue | |
| lines.append(f"### {display_name}") | |
| lines.append("") | |
| lines.append("| 数据集 | 发布者 | 下载量 | 信号 |") | |
| lines.append("|--------|--------|--------|------|") | |
| for ds in datasets[:limit]: | |
| ds_id = ds.get("id", ds.get("name", "Unknown")) | |
| ds_name = ds_id.split("/")[-1] if "/" in ds_id else ds_id | |
| author = ds_id.split("/")[0] if "/" in ds_id else "-" | |
| downloads = ds.get("downloads", 0) | |
| # Get signals | |
| signals = ds.get("signals", ["-"]) | |
| if isinstance(signals, list): | |
| signal_str = ", ".join(str(s) for s in signals[:3]) | |
| else: | |
| signal_str = str(signals) | |
| lines.append( | |
| f"| [{ds_name}](https://huggingface.co/datasets/{ds_id}) | " | |
| f"{author} | {downloads:,} | {signal_str} |" | |
| ) | |
| lines.append("") | |
| if not any(datasets_by_type.values()): | |
| lines.append("本周无新的高价值数据集") | |
| lines.append("") | |
| return lines | |
| def _generate_papers_section(self, papers: list[dict]) -> list[str]: | |
| """Generate papers section with categories.""" | |
| lines = [] | |
| lines.append("## 📄 相关论文(数据方法论)") | |
| lines.append("") | |
| if not papers: | |
| lines.append("本周无高度相关论文") | |
| lines.append("") | |
| return lines | |
| # Group by category | |
| by_category = {} | |
| for paper in papers: | |
| cat = paper.get("category", "其他相关") | |
| if cat not in by_category: | |
| by_category[cat] = [] | |
| by_category[cat].append(paper) | |
| category_order = ["RLHF/偏好学习", "数据集构建", "标注方法论", "指令微调", "其他相关"] | |
| for cat in category_order: | |
| if cat not in by_category or not by_category[cat]: | |
| continue | |
| lines.append(f"### {cat}") | |
| lines.append("") | |
| lines.append("| 论文 | 要点 | 链接 |") | |
| lines.append("|------|------|------|") | |
| for paper in by_category[cat][:5]: | |
| title = paper.get("title", "Unknown")[:55] | |
| if len(paper.get("title", "")) > 55: | |
| title += "..." | |
| # Get highlight | |
| highlight = paper.get("highlight", "") | |
| if not highlight: | |
| # Extract from matched keywords | |
| keywords = paper.get("_matched_keywords", [])[:2] | |
| highlight = ", ".join(keywords) if keywords else "-" | |
| # Get link | |
| url = paper.get("url", "") | |
| if url: | |
| link = f"[arXiv]({url})" | |
| else: | |
| link = "-" | |
| lines.append(f"| {title} | {highlight} | {link} |") | |
| lines.append("") | |
| return lines | |
| def _generate_x_section(self, x_activity: dict = None) -> list[str]: | |
| """Generate X/Twitter activity section.""" | |
| lines = [] | |
| if not x_activity: | |
| return lines | |
| accounts = x_activity.get("accounts", []) | |
| active = [a for a in accounts if a.get("relevant_tweets")] | |
| if not active: | |
| return lines | |
| total_tweets = sum(len(a.get("relevant_tweets", [])) for a in active) | |
| lines.append("## X/Twitter 动态") | |
| lines.append("") | |
| lines.append(f"监控 {len(accounts)} 个账户,{len(active)} 个有相关推文,共 {total_tweets} 条。") | |
| lines.append("") | |
| limit = self.limits.get("x_accounts", 10) | |
| for account in active[:limit]: | |
| username = account.get("username", "unknown") | |
| tweets = account.get("relevant_tweets", []) | |
| lines.append(f"### @{username} ({len(tweets)} 条)") | |
| lines.append("") | |
| for tweet in tweets[:3]: | |
| text = tweet.get("text", "")[:120] | |
| url = tweet.get("url", "") | |
| date = tweet.get("date", "") | |
| meta = f" ({date})" if date else "" | |
| if url: | |
| lines.append(f"- [{text}]({url}){meta}") | |
| else: | |
| lines.append(f"- {text}{meta}") | |
| lines.append("") | |
| return lines | |
| def _generate_reddit_section(self, reddit_activity: dict = None) -> list[str]: | |
| """Generate Reddit community activity section.""" | |
| lines = [] | |
| if not reddit_activity: | |
| return lines | |
| posts = reddit_activity.get("posts", []) | |
| if not posts: | |
| return lines | |
| lines.append("## Reddit 社区动态") | |
| lines.append("") | |
| lines.append(f"监控 {reddit_activity.get('metadata', {}).get('subreddits_checked', 0)} 个子版块," | |
| f"发现 {len(posts)} 条相关帖子。") | |
| lines.append("") | |
| limit = self.limits.get("reddit_posts", 15) | |
| for post in posts[:limit]: | |
| title = post.get("title", "")[:120] | |
| url = post.get("url", "") | |
| date = post.get("date", "") | |
| score = post.get("score", 0) | |
| sub = post.get("subreddit", "") | |
| meta = f" ({date})" if date else "" | |
| prefix = f"r/{sub} ↑{score}" | |
| if url: | |
| lines.append(f"- **{prefix}** [{title}]({url}){meta}") | |
| else: | |
| lines.append(f"- **{prefix}** {title}{meta}") | |
| lines.append("") | |
| return lines | |
| def _generate_competitor_matrix_section(self, competitor_matrix: dict = None) -> list[str]: | |
| """Generate competitor matrix section.""" | |
| lines = [] | |
| if not competitor_matrix: | |
| return lines | |
| top_orgs = competitor_matrix.get("top_orgs", []) | |
| if not top_orgs: | |
| return lines | |
| lines.append("## 竞争矩阵") | |
| lines.append("") | |
| lines.append(f"覆盖 {len(top_orgs)} 个组织的活动交叉分析。") | |
| lines.append("") | |
| # Top orgs table | |
| lines.append("| 组织 | 数据集 | 仓库 | 论文 | 博客 | 总计 |") | |
| lines.append("|------|--------|------|------|------|------|") | |
| org_details = competitor_matrix.get("org_details", {}) | |
| for org, total in top_orgs[:15]: | |
| d = org_details.get(org, {}) | |
| lines.append( | |
| f"| {org} | {d.get('datasets', 0)} | {d.get('repos', 0)} | " | |
| f"{d.get('papers', 0)} | {d.get('blogs', 0)} | {total} |" | |
| ) | |
| lines.append("") | |
| return lines | |
| def _generate_lineage_section(self, dataset_lineage: dict = None) -> list[str]: | |
| """Generate dataset lineage section.""" | |
| lines = [] | |
| if not dataset_lineage: | |
| return lines | |
| stats = dataset_lineage.get("stats", {}) | |
| if stats.get("total_edges", 0) == 0 and not dataset_lineage.get("version_chains") and not dataset_lineage.get("fork_trees"): | |
| return lines | |
| lines.append("## 数据集谱系") | |
| lines.append("") | |
| lines.append( | |
| f"发现 {stats.get('derivation_edges', 0)} 条派生关系," | |
| f"{stats.get('version_chains', 0)} 个版本链," | |
| f"{stats.get('fork_groups', 0)} 个 Fork 组。" | |
| ) | |
| lines.append("") | |
| # Version chains | |
| chains = dataset_lineage.get("version_chains", {}) | |
| if chains: | |
| lines.append("### 版本链") | |
| lines.append("") | |
| for base, chain in list(chains.items())[:10]: | |
| lines.append(f"- **{base}**: {' → '.join(chain)}") | |
| lines.append("") | |
| # Fork trees | |
| forks = dataset_lineage.get("fork_trees", {}) | |
| if forks: | |
| lines.append("### Fork 分支") | |
| lines.append("") | |
| for name, ids in list(forks.items())[:10]: | |
| lines.append(f"- **{name}**: {', '.join(ids)}") | |
| lines.append("") | |
| # Root datasets | |
| roots = dataset_lineage.get("root_datasets", []) | |
| if roots: | |
| lines.append("### 根数据集") | |
| lines.append("") | |
| for root in roots[:15]: | |
| lines.append(f"- {root}") | |
| lines.append("") | |
| return lines | |
| def _generate_org_graph_section(self, org_graph: dict = None) -> list[str]: | |
| """Generate organization relationship graph section.""" | |
| lines = [] | |
| if not org_graph: | |
| return lines | |
| nodes = org_graph.get("nodes", []) | |
| edges = org_graph.get("edges", []) | |
| if not edges: | |
| return lines | |
| lines.append("## 组织关系图谱") | |
| lines.append("") | |
| lines.append(f"识别 {len(nodes)} 个组织节点,{len(edges)} 条关系边。") | |
| lines.append("") | |
| # Top clusters | |
| clusters = org_graph.get("clusters", []) | |
| if clusters: | |
| lines.append("### 组织集群") | |
| lines.append("") | |
| for i, cluster in enumerate(clusters[:5]): | |
| if len(cluster) >= 2: | |
| lines.append(f"- **集群 {i + 1}** ({len(cluster)} 个组织): {', '.join(cluster[:8])}") | |
| lines.append("") | |
| # Top centrality | |
| centrality = org_graph.get("centrality", {}) | |
| if centrality: | |
| top_central = sorted(centrality.items(), key=lambda x: x[1], reverse=True)[:10] | |
| if top_central and top_central[0][1] > 0: | |
| lines.append("### 核心组织 (度中心性)") | |
| lines.append("") | |
| for org, score in top_central: | |
| if score > 0: | |
| lines.append(f"- **{org}**: {score:.3f}") | |
| lines.append("") | |
| # Top edges | |
| if edges: | |
| lines.append("### 主要关系") | |
| lines.append("") | |
| for edge in edges[:10]: | |
| lines.append(f"- {edge['source']} ↔ {edge['target']} ({edge['type']}, 权重 {edge['weight']})") | |
| lines.append("") | |
| return lines | |
| def generate_console_summary( | |
| self, | |
| lab_activity: dict, | |
| vendor_activity: dict, | |
| datasets_by_type: dict, | |
| github_activity: list[dict] = None, | |
| blog_activity: list[dict] = None, | |
| ) -> str: | |
| """Generate a brief console summary.""" | |
| lines = [] | |
| lines.append("=" * 60) | |
| lines.append(f" AI Dataset Radar v{__version__} - 竞争情报摘要") | |
| lines.append("=" * 60) | |
| lines.append("") | |
| # Labs summary | |
| labs = lab_activity.get("labs", {}) | |
| for category, category_name in [ | |
| ("frontier_labs", "Frontier Labs"), | |
| ("emerging_labs", "Emerging Labs"), | |
| ("research_labs", "Research Labs"), | |
| ]: | |
| cat_data = labs.get(category, {}) | |
| active = [k for k, v in cat_data.items() if v.get("datasets") or v.get("models")] | |
| if active: | |
| lines.append(f" {category_name}: {', '.join(active[:5])}") | |
| # GitHub summary | |
| if github_activity: | |
| active_orgs = [a["org"] for a in github_activity if a.get("repos_updated")] | |
| if active_orgs: | |
| lines.append(f" GitHub活跃: {', '.join(active_orgs[:5])}") | |
| # Blog summary | |
| if blog_activity: | |
| active_blogs = [a["source"] for a in blog_activity if a.get("articles")] | |
| if active_blogs: | |
| lines.append(f" 博客更新: {', '.join(active_blogs[:5])}") | |
| # Type summary | |
| lines.append("") | |
| lines.append(" 数据集类型分布:") | |
| for dtype, datasets in datasets_by_type.items(): | |
| if datasets: | |
| key = dtype.value if isinstance(dtype, DataType) else str(dtype) | |
| lines.append(f" {key}: {len(datasets)}") | |
| lines.append("") | |
| lines.append("=" * 60) | |
| return "\n".join(lines) | |
Xet Storage Details
- Size:
- 30.2 kB
- Xet hash:
- 5dc6dfdd5a4abb5e6011b8f1e0b1fe985ba0cce64c83b229794c80128f543702
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.