MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / show_stats

Function show_stats

scripts/fetch_nmpa_fulltext.py:1708–1767  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1706# ---------------------------------------------------------------------------
1707
1708def show_stats():
1709 index_data = load_index()
1710 entries = index_data.get("entries", [])
1711 discovered = load_discovered_urls()
1712
1713 with_slug = [e for e in entries if e.get("slug")]
1714 with_fulltext = [e for e in entries if fulltext_exists(e)]
1715 without_fulltext = [e for e in entries if not fulltext_exists(e)]
1716 discovered_with_url = {
1717 k: v for k, v in discovered.items()
1718 if v.get("urls") or v.get("url")
1719 }
1720 discovered_no_url = {
1721 k: v for k, v in discovered.items()
1722 if not v.get("urls") and not v.get("url")
1723 }
1724
1725 ft_files = list(FULLTEXT_DIR.glob("*.md")) if FULLTEXT_DIR.exists() else []
1726 en_files = [f for f in ft_files if f.stem.endswith('.en')]
1727 zh_only = [f for f in ft_files if not f.stem.endswith('.en')]
1728
1729 unmatched_files = list(UNMATCHED_DIR.glob("*.md")) if UNMATCHED_DIR.exists() else []
1730
1731 lo_bin = _detect_libreoffice()
1732
1733 print(f"\n=== NMPA Guidance Fulltext Statistics ===")
1734 print(f"Total index entries: {len(entries)}")
1735 print(f"Entries with slug: {len(with_slug)}")
1736 print(f"Entries with fulltext: {len(with_fulltext)}")
1737 print(f"Entries without fulltext: {len(without_fulltext)}")
1738 print(f"")
1739 print(f"Fulltext files (ZH *.md): {len(zh_only)}")
1740 print(f"English translations: {len(en_files)}")
1741 print(f"Unmatched files: {len(unmatched_files)}")
1742 print(f"")
1743 print(f"LibreOffice (.doc support):{' YES' if lo_bin else ' NO'}")
1744 print(f"")
1745 print(f"URL discovery status:")
1746 print(f" Searched: {len(discovered)}")
1747 print(f" Found doc/docx URL: {len(discovered_with_url)}")
1748 print(f" No URL found: {len(discovered_no_url)}")
1749 not_searched = len(without_fulltext) - len(
1750 [e for e in without_fulltext if e["id"] in discovered]
1751 )
1752 print(f" Not yet searched: {not_searched}")
1753 print()
1754
1755 by_cat = {}
1756 for e in entries:
1757 cat = e.get("category", "unknown")
1758 ft = fulltext_exists(e)
1759 by_cat.setdefault(cat, {"total": 0, "has_ft": 0})
1760 by_cat[cat]["total"] += 1
1761 if ft:
1762 by_cat[cat]["has_ft"] += 1
1763
1764 print("Coverage by category:")
1765 for cat, s in sorted(by_cat.items(), key=lambda x: -x[1]["total"]):

Callers 1

mainFunction · 0.70

Calls 5

load_indexFunction · 0.85
load_discovered_urlsFunction · 0.85
_detect_libreofficeFunction · 0.85
getMethod · 0.80
fulltext_existsFunction · 0.70

Tested by

no test coverage detected