# -*- coding: utf-8 -*- """Extract the source corpus from a pinned Wayback snapshot of the CB Insights failure post-mortem page, and report how much of it matches the corpus this paper was coded from. WHY A SNAPSHOT AND NOT THE LIVE PAGE CB Insights can edit that page, so "go and fetch it yourself" is not a reproducible instruction. The snapshot below is pinned by timestamp. A CORRECTION THAT MATTERS An earlier version of this script read only one of the page's two layouts, the "Product:" paragraphs, recovered 88 entries, and the manifest and the paper's corrections log then stated that CB Insights had edited the page and that the corpus could not be reconstructed. **That was false.** The missing entries were under `

NAME

` blocks the parser never looked at, and the two it called "edited" differed only because this script decoded six HTML entities instead of all of them. The limits of the parser were written up as facts about somebody else's website. This version reads both layouts and unescapes properly. It prints what it actually finds, and calls an entry changed only when it is present and differs. """ import argparse import hashlib import html import io import json import os import re import urllib.request HERE = os.path.dirname(os.path.abspath(__file__)) MANIFEST = os.path.join(HERE, 'source-manifest.json') SNAPSHOT = ('http://web.archive.org/web/20260909210104/' 'https://www.cbinsights.com/research/startup-failure-post-mortem/') # Layout A: "Product: NAME...

DESCRIPTION

". The name can run # past the anchor, as in "Tessera, Escher", so it is read to the paragraph end. LAYOUT_A = re.compile( r'Product:\s*(?P.*?)

\s*

(?P.*?)

', re.S) # Layout B: "

NAME

" followed by several paragraphs. The first ones # are labelled "Title:", "Product:", "Date of closure:" and so on; the # description is the first UNLABELLED paragraph. Taking the first paragraph # blindly captured the Title line and made 284 entries look edited. LAYOUT_B = re.compile( r'\s*]*>(?P.*?)(?P.*?)(?=|\Z)', re.S) PARA = re.compile(r'

(.*?)

', re.S) LABEL = re.compile(r'^(title|product|date|hq|total funding|founded|industry|' r'select investors|what happened|category)\s*:', re.I) TAGS = re.compile(r'<[^>]+>') def clean(s): """Strip tags and decode every entity, not a hand-picked six.""" return ' '.join(html.unescape(TAGS.sub('', s)).split()) def extract(page): out = {} for m in LAYOUT_A.finditer(page): name = clean(m.group('name')).strip(' ,') desc = clean(m.group('desc')) if name and desc and name not in out: out[name] = desc for m in LAYOUT_B.finditer(page): name = clean(m.group('name')).strip(' ,') if not name or name in out: continue for raw in PARA.findall(m.group('body')): desc = clean(raw) if desc and not LABEL.match(desc) and len(desc) > 60: out[name] = desc break return out def main(): ap = argparse.ArgumentParser() ap.add_argument('--html') a = ap.parse_args() if a.html: page = io.open(a.html, encoding='utf-8', errors='replace').read() else: print('fetching the pinned snapshot, this is a large page') req = urllib.request.Request(SNAPSHOT, headers={'User-Agent': 'research-bench'}) with urllib.request.urlopen(req, timeout=180) as r: page = r.read().decode('utf-8', 'replace') got = extract(page) man = json.load(io.open(MANIFEST, encoding='utf-8')) want = man['failures']['desc_sha256'] same, differs, absent = [], [], [] for n in want: if n not in got: absent.append(n) elif hashlib.sha256(got[n].encode()).hexdigest() == want[n]: same.append(n) else: differs.append(n) print('') print('snapshot : %s' % SNAPSHOT) print('coded on : %s' % man['source']['retrieved']) print('entries coded : %d' % len(want)) print('extracted : %d' % len(got)) print('') print(' identical to what was coded : %d' % len(same)) print(' present but differing : %d' % len(differs)) print(' not found by this parser : %d' % len(absent)) print('') if differs: print('Differing entries, which may be a source edit OR a parsing') print('difference in this script. Do not report them as edits without') print('reading them:') for n in differs[:8]: print(' %s' % n) if absent: print('Not found. This is a statement about this parser, not about the') print('source page, unless you have checked the name is truly absent:') for n in absent[:8]: print(' %s' % n) if __name__ == '__main__': main()