Files
Obsidian/博客/其他/分析脚本.ps1
T

87 lines
2.5 KiB
PowerShell

$posts = Get-Content "d:\Code\OpenClaw\文件\博客\所有文章标签分类.json" | ConvertFrom-Json
Write-Host "=== 博客文章标签和分类分析报告 ===" -ForegroundColor Cyan
Write-Host ""
# 标签映射
$tagMap = @{
"tag-ai9jzu3f" = "协会动态"
"tag-wcdoataa" = "5分钟速览"
"tag-tnpxywrp" = "技术深潜"
"tag-t17fkerv" = "校园AI"
"tag-b00ospt6" = "竞赛指南"
"tag-mlyijvf1" = "项目实战"
"tag-kltizgga" = "零基础入门"
"tag-5gnzuysx" = "开源框架"
"tag-kdbstvcj" = "模型轻量化"
"tag-ds8gca80" = "隐私计算"
"tag-iov4cveg" = "AI智能体"
}
# 分类映射
$catMap = @{
"category-o29urmhb" = "行业望远镜"
"category-yzecyosi" = "协会进行时"
"category-w55kw7o5" = "校园AI日记"
"category-jdck2tln" = "竞赛能量站"
"category-kkzsv1qw" = "成长实验室"
"category-zuyid1h1" = "智能体前沿"
"76514a40-6ef1-4ed9-b58a-e26945bde3ca" = "默认分类"
}
# 标签使用统计
$tagCount = @{}
$catCount = @{}
$noTagPosts = @()
$issues = @()
foreach ($item in $posts.items) {
$title = $item.spec.title
$tags = $item.spec.tags
$cats = $item.spec.categories
# 统计标签
if ($tags.Count -eq 0) {
$noTagPosts += $title
} else {
foreach ($tag in $tags) {
$tagName = $tagMap[$tag]
if ($tagName) {
if (-not $tagCount.ContainsKey($tagName)) {
$tagCount[$tagName] = 0
}
$tagCount[$tagName]++
}
}
}
# 统计分类
foreach ($cat in $cats) {
$catName = $catMap[$cat]
if ($catName) {
if (-not $catCount.ContainsKey($catName)) {
$catCount[$catName] = 0
}
$catCount[$catName]++
}
}
}
Write-Host "=== 标签使用统计 ===" -ForegroundColor Yellow
$tagCount.GetEnumerator() | Sort-Object Value -Descending | ForEach-Object {
Write-Host "$($_.Key): $($_.Value)"
}
Write-Host ""
Write-Host "=== 分类使用统计 ===" -ForegroundColor Yellow
$catCount.GetEnumerator() | Sort-Object Value -Descending | ForEach-Object {
Write-Host "$($_.Key): $($_.Value)"
}
Write-Host ""
if ($noTagPosts.Count -gt 0) {
Write-Host "=== 无标签文章 ($($noTagPosts.Count)) ===" -ForegroundColor Red
$noTagPosts | ForEach-Object { Write-Host " - $_" }
} else {
Write-Host "=== 无标签文章: 0 篇 ✅ ===" -ForegroundColor Green
}