import json, re a = open('output/article.md', encoding='utf-8').read() lines = a.splitlines() body = '\n'.join(l for l in lines if not l.startswith('# ')) words = len(re.sub(r'^#+\s*', '', body, flags=re.M).split()) print('body words (excl H1, incl subheads):', words, '| 600-800:', 600 <= words <= 800) sub = len(re.sub(r'^#+.*$', '', body, flags=re.M).split()) print('body words excl subheads:', sub, '| 600-800:', 600 <= sub <= 800) m = json.load(open('output/metadata.json', encoding='utf-8')) print('keys:', sorted(m)) print('headline chars:', len(m['headline']), 50 <= len(m['headline']) <= 70) print('excerpt words:', len(m['excerpt'].split()), len(m['excerpt'].split()) <= 45) print('search desc chars:', len(m['search_description']), 140 <= len(m['search_description']) <= 160) print('H1 matches headline:', lines[0][2:] == m['headline']) # Citations: every (file, "Section") pair must exist as a heading in inputs/ cites = set(re.findall(r'\((S\d-[\w-]+\.md), "([^"]+)"\)', a)) for f, sec in sorted(cites): src = open('inputs/' + f, encoding='utf-8').read() print('cite', f, sec, 'OK' if re.search(r'^## ' + re.escape(sec) + r'\s*$', src, re.M) else 'MISSING') print('S5 cited in article:', 'S5-' in a) # Arithmetic assert 3 * 29 == 87 and 87 + 12 == 99 and round((700 - 500) * 0.08, 2) == 16 print('arithmetic OK: 3x29=87, +12=99, (700-500)x0.08=16') # Every number in article is in a source or is a stated calculation srcs = ''.join(open('inputs/' + f, encoding='utf-8').read() for f in ['S1-announcement.md', 'S2-pricing.md', 'S3-data-policy.md', 'S4-independent-review.md']) calc = {'87', '99', '16', '700'} for n in sorted(set(re.findall(r'\d+(?:\.\d+)?', body))): if n not in srcs and n not in calc: print('number not in sources:', n) # Excluded S5 claims / personal testing for bad in ['GDPR', 'offline', 'hallucination', '60%', 'fired', 'I tested', 'we tested', 'I tried', 'hands-on test']: if bad.lower() in a.lower(): print('FLAG:', bad) print('USD 19 contexts:', [a[max(0, i-40):i+30].replace('\n', ' ') for i in [x.start() for x in re.finditer('USD 19', a)]])