"""Length, arithmetic and exclusion checks for the LumenDesk package. Rerunnable.""" import json, re a = open('output/article.md', encoding='utf-8').read() body = re.sub(r'^# .*\n', '', a, count=1) # exclude the H1 headline, which is also in metadata words = re.findall(r"[A-Za-z0-9][A-Za-z0-9'’.,×%-]*", body) print('article words excl. H1:', len(words), '| incl. H1:', len(re.findall(r"[A-Za-z0-9][A-Za-z0-9'’.,×%-]*", a))) m = json.load(open('output/metadata.json', encoding='utf-8')) # also confirms the JSON is valid assert set(m) == {'headline', 'excerpt', 'search_description'} print('headline chars:', len(m['headline']), '| matches H1:', a.splitlines()[0][2:] == m['headline']) print('excerpt words:', len(m['excerpt'].split())) print('search_description chars:', len(m['search_description'])) # arithmetic from S2-pricing.md "Current plans" assert 3 * 29 == 87 and 87 + 12 == 99 and round((750 - 500) * 0.08, 2) == 20.0 print('arithmetic ok') # S5 leads must not appear; USD 19 is allowed only in the correction sentence for bad in ['GDPR', 'offline', '60%', 'hallucination', 'fired', 'I tested', 'we tested', 'in our test', 'hands-on']: print(f'{bad!r} present:', bad.lower() in a.lower()) print('USD 19 lines:', [l[:60] for l in a.splitlines() if 'USD 19' in l]) # voice-sample sentences must not be copied vs = ['the line that costs you money', 'the useful question is', 'fluent prose does not rescue'] print('voice-sample phrases copied:', [p for p in vs if p in a]) print('cited sources:', sorted(set(re.findall(r'S\d-[a-z-]+\.md', a))))