Claude commited on
Commit
d0a3b3d
Β·
unverified Β·
1 Parent(s): 5061d1f

Unify the two caps tools' acronym lists

Browse files

convert_caps (KEEP_WORDS) and replace_allcaps_pptx (PRESERVE_UPPERCASE) each
carried their own hardcoded acronym list, and they had drifted: e.g. "WCAG"
was preserved by replace_allcaps but mangled to "Wcag" by convert_caps when it
appeared as caps *formatting*. Both now load one shared source of truth,
tools/pptx/acronyms.txt (loaded relative to __file__, so it works for the CLI,
the run.py launcher, and the web app's importlib loading). convert_caps uses
the canonical casing; replace_allcaps uses the uppercased forms.

Verified: lists agree (72 entries), WCAG with caps formatting now stays WCAG,
and the smoke test passes 7/7.

tools/pptx/acronyms.txt ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Canonical acronym / abbreviation list β€” the single source of truth shared by
2
+ # convert_caps.py and replace_allcaps_pptx.py so the two tools can't drift apart.
3
+ #
4
+ # One token per line, in its preferred casing (e.g. "iOS", "PhD", "APIs").
5
+ # - convert_caps restores this exact casing after title-casing.
6
+ # - replace_allcaps compares against the UPPERCASED form to keep matches as-is.
7
+ # Lines starting with '#' and blank lines are ignored; '#' also ends a line.
8
+
9
+ ADA
10
+ AI
11
+ API
12
+ APIs
13
+ ARIA
14
+ AWS
15
+ CEO
16
+ CFO
17
+ CIO
18
+ COO
19
+ CSS
20
+ CSV
21
+ CTO
22
+ DB
23
+ DevOps
24
+ DNS
25
+ EU
26
+ FAQ
27
+ FBI
28
+ GPU
29
+ GPUs
30
+ HR
31
+ HTML
32
+ HTTP
33
+ HTTPS
34
+ I
35
+ ID
36
+ IDs
37
+ IoT
38
+ IP
39
+ ISO
40
+ IT
41
+ iOS
42
+ JAWS
43
+ JSON
44
+ KPI
45
+ KPIs
46
+ LLC
47
+ MBA
48
+ ML
49
+ MVP
50
+ NASA
51
+ NDA
52
+ NVDA
53
+ OKR
54
+ OKRs
55
+ OS
56
+ PDF
57
+ PhD
58
+ PIN
59
+ PR
60
+ QA
61
+ ROI
62
+ SaaS
63
+ SDK
64
+ SEO
65
+ SQL
66
+ SSD
67
+ SSO
68
+ UI
69
+ UK
70
+ URL
71
+ URLs
72
+ US
73
+ USA
74
+ USB
75
+ UX
76
+ VPAT
77
+ VPN
78
+ WAI
79
+ WCAG
80
+ XML
tools/pptx/convert_caps.py CHANGED
@@ -15,7 +15,8 @@ Batch (2+ files): saves each to <input>_mixed_case.pptx, or into --outdir
15
 
16
  The --keep flag adds extra words that should keep their casing. A built-in
17
  list of common acronyms is always applied (AI, API, CEO, etc.). Edit the
18
- KEEP_WORDS set below to permanently add or remove entries.
 
19
 
20
  Requirements:
21
  pip install python-pptx
@@ -30,18 +31,24 @@ from lxml import etree
30
  from pptx import Presentation
31
 
32
  # ── Acronyms / words to preserve ────────────────────────────────
33
- # These words will keep their exact casing after title-case conversion.
34
- # Add or remove entries as needed. Case-sensitive: "AI" means the
35
- # uppercase form "AI" is restored whenever "Ai" appears after title-casing.
36
- KEEP_WORDS = {
37
- "AI", "API", "APIs", "AWS", "CEO", "CFO", "CIO", "CTO", "COO",
38
- "CSV", "DB", "DevOps", "DNS", "EU", "FAQ", "GPU", "GPUs",
39
- "HR", "HTML", "HTTP", "HTTPS", "I", "ID", "IDs", "iOS", "IoT",
40
- "IP", "IT", "JSON", "KPI", "KPIs", "LLC", "MBA", "ML", "MVP",
41
- "NASA", "NDA", "OKR", "OKRs", "OS", "PDF", "PhD", "PR", "QA",
42
- "ROI", "SaaS", "SDK", "SEO", "SQL", "SSD", "SSO", "UI", "UK",
43
- "URL", "URLs", "US", "USA", "USB", "UX", "VPN", "XML",
44
- }
 
 
 
 
 
 
45
 
46
  # PowerPoint XML namespace for drawingML
47
  _nsmap = {"a": "http://schemas.openxmlformats.org/drawingml/2006/main"}
 
15
 
16
  The --keep flag adds extra words that should keep their casing. A built-in
17
  list of common acronyms is always applied (AI, API, CEO, etc.). Edit the
18
+ shared acronyms.txt (next to this script) to permanently add or remove entries
19
+ β€” replace_allcaps_pptx.py reads the same file.
20
 
21
  Requirements:
22
  pip install python-pptx
 
31
  from pptx import Presentation
32
 
33
  # ── Acronyms / words to preserve ────────────────────────────────
34
+ # These words keep their exact casing after title-case conversion. The list
35
+ # is loaded from the shared acronyms.txt so it stays in sync with
36
+ # replace_allcaps_pptx.py β€” edit that file to add or remove entries.
37
+ def _load_keep_words() -> set:
38
+ """Read the canonical acronym list shared with replace_allcaps_pptx.py."""
39
+ path = Path(__file__).resolve().parent / "acronyms.txt"
40
+ words = set()
41
+ try:
42
+ for line in path.read_text(encoding="utf-8").splitlines():
43
+ token = line.split("#", 1)[0].strip()
44
+ if token:
45
+ words.add(token)
46
+ except OSError:
47
+ pass
48
+ return words
49
+
50
+
51
+ KEEP_WORDS = _load_keep_words()
52
 
53
  # PowerPoint XML namespace for drawingML
54
  _nsmap = {"a": "http://schemas.openxmlformats.org/drawingml/2006/main"}
tools/pptx/replace_allcaps_pptx.py CHANGED
@@ -20,13 +20,23 @@ from pptx.util import Pt
20
 
21
 
22
  # ── Acronyms / abbreviations to KEEP uppercase ──────────────────────
23
- PRESERVE_UPPERCASE = {
24
- "WCAG", "ADA", "PDF", "HTML", "CSS", "URL", "API", "NASA",
25
- "FBI", "USA", "UK", "EU", "IT", "HR", "CEO", "CFO", "CTO",
26
- "FAQ", "ID", "PIN", "ISO", "ARIA", "WAI", "VPAT", "JAWS",
27
- "NVDA", "AI", "ML", "SQL", "JSON", "XML", "HTTP", "HTTPS",
28
- # Add your own acronyms here
29
- }
 
 
 
 
 
 
 
 
 
 
30
 
31
 
32
  def is_all_caps(text: str) -> bool:
 
20
 
21
 
22
  # ── Acronyms / abbreviations to KEEP uppercase ──────────────────────
23
+ # Loaded (uppercased) from the shared acronyms.txt so this stays in sync with
24
+ # convert_caps.py β€” edit that file to add or remove entries.
25
+ def _load_preserve_uppercase() -> set:
26
+ """Uppercase forms of the canonical acronym list shared with convert_caps.py."""
27
+ path = Path(__file__).resolve().parent / "acronyms.txt"
28
+ words = set()
29
+ try:
30
+ for line in path.read_text(encoding="utf-8").splitlines():
31
+ token = line.split("#", 1)[0].strip()
32
+ if token:
33
+ words.add(token.upper())
34
+ except OSError:
35
+ pass
36
+ return words
37
+
38
+
39
+ PRESERVE_UPPERCASE = _load_preserve_uppercase()
40
 
41
 
42
  def is_all_caps(text: str) -> bool: