#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Cek duplikasi kandidat topik vs 312 artikel publish studiosoft.id."""
import json, re
d = json.load(open("/tmp/ss_publish_list.json"))
judul = [(x["slug"], re.sub(r"&#\d+;", "", x["title"]["rendered"] if isinstance(x["title"], dict) else x["title"])) for x in d]

KATA = ["tools", "kompetitor", "freelancer", "in-house", "agensi", "agency", "wordpress",
        "branding", "sidoarjo", "malang", "google business", "business profile", "keyword",
        "riset", "jasa seo", "maintenance", "audit", "harga", "biaya", "segmentasi", "industri",
        "properti", "manufaktur", "retail", "keuangan", "rumah sakit", "klinik"]
for k in KATA:
    hit = [f"{s}" for s, t in judul if k in s.lower() or k in t.lower()]
    print(f"\n### '{k}' -> {len(hit)}")
    for s in hit[:12]:
        print("   ", s)
