Repository Public Research preview
1"""r3k_21_bib_crossref.py — Stage D (FIRC-0002, package L11, cluster K: LITE-01/02/06/07/08/09/10/13, EDIT-14).2Resolves every DOI of the references the literature referee asks to add (and the two bibliographic queries without a DOI) through3doi.org content negotiation (CSL-JSON; Crossref and DataCite registrants) / the Crossref works API, and appends VERIFIED BibTeX4entries to paper/references.bib (block "Stage D review additions, 2026-11-05"). Entries that do not resolve, or whose resolved5title/authors do not match the referee's description, are NOT added and are listed in results/r3k_v2/bib_additions.json for6unresolved_issues.md. No manuscript prose is touched (citing the new keys is Stage E). Run: .venv-review/bin/python -I scripts/r3k_21_bib_crossref.py7"""8import json, re, time, urllib.request, urllib.parse, datetime as dt9H = {"User-Agent": "UQO-WP-REVIEW FIRC-0002 (mailto:simon-pierre.boucher@uqo.ca)", "Accept": "application/vnd.citationstyles.csl+json"}10WANT = [ # key, DOI (or None), expected substring(s) in the resolved title, referee anchor11 ("basu2026aiexposure", "10.2139/ssrn.7575518", ["ai", "exposure"], "LITE-01 competitor (SSRN 7575518)"),12 ("borri2026aifactor", "10.48550/arXiv.2606.30583", ["ai"], "LITE-08 (arXiv 2606.30583)"),13 ("wulam2026genai", "10.2139/ssrn.7482259", ["ai"], "LITE-08 (SSRN 7482259)"),14 ("eisfeldt2026generative", "10.1111/jofi.70089", ["generative ai", "firm values"], "LITE-02 / EDIT-14: JF 2026 version replacing eisfeldt2023generative"),15 ("song2026productexposure", "10.2139/ssrn.7527158", ["product", "generative"], "LITE-02 (SSRN 7527158)"),16 ("erdogan2026aiwashing", "10.2139/ssrn.6749213", ["ai"], "LITE-03 AI washing (SSRN 6749213)"),17 ("wang2026aiwashing", "10.1016/j.iref.2026.105756", ["ai"], "LITE-03 AI washing (IREF 2026)"),18 ("celenymarechal2024cyber", "10.2139/ssrn.4587993", ["cyber"], "LITE-05 / LITE-09 (SSRN 4587993)"),19 ("kearney2025cyberchatgpt", "10.2139/ssrn.5068625", ["cyber"], "LITE-05 (SSRN 5068625)"),20 ("hassan2019firmlevel", "10.1093/qje/qjz021", ["political risk"], "LITE-09 / EDIT-14 (QJE 2019)"),21 ("davis2020exposures", "10.3386/w27867", ["firm", "exposure"], "LITE-09 (NBER w27867)"),22 ("kim2023llmrisks", "10.2139/ssrn.4593660", ["risk"], "LITE-09 (SSRN 4593660)"),23 ("cao2023machinelistening", "10.1093/rfs/hhad021", ["machine"], "LITE-09 / EDIT-14 (RFS 2023)"),24 ("honglimstein2000", "10.1111/0022-1082.00206", ["bad news"], "LITE-07 (JF 2000)"),25 ("yilmazkuday2026chatgpt", "10.1007/s12197-026-09767-9", ["chatgpt"], "LITE-08 (J. Econ. Finance 2026)"),26 ("hampole2025ai", "10.3386/w33509", ["artificial intelligence", "labor"], "plan L11 (NBER w33509: Hampole, Papanikolaou, Schmidt, Seegmiller)"),27 ("bloom2021diffusion", "10.3386/w28999", ["diffusion", "technolog"], "EDIT-14: Bloom et al. NBER 28999 = The Diffusion of New Technologies (Bloom, Hassan, Kalyani, Lerner, Tahoun), DOI verified"),28]29QUERIES = [("xia2026aiwashingindex", "AI washing index large language model disclosure investment Systems 2026", "LITE-03 Xia et al., Systems 2026 (no identifier given)"), ("ofir2026aiwashinglaw", "AI washing American Business Law Journal 2026 Ofir", "LITE-03 Ofir, ABLJ 2026 (no identifier given)")]30def csl(doi):31 r = urllib.request.urlopen(urllib.request.Request("https://doi.org/" + urllib.parse.quote(doi), headers=H), timeout=60); return json.load(r)32def crossref_query(q):33 r = urllib.request.urlopen(urllib.request.Request("https://api.crossref.org/works?rows=3&query.bibliographic=" + urllib.parse.quote(q), headers={"User-Agent": H["User-Agent"]}), timeout=60); return json.load(r)["message"]["items"]34def bibtex(key, m, doi):35 au = " and ".join(f"{a.get('family', '')}, {a.get('given', '')}".strip(", ") for a in m.get("author", []) if a.get("family") or a.get("literal")) or m.get("author", [{}])[0].get("literal", "")36 year = (m.get("issued", {}).get("date-parts") or [[None]])[0][0]; title = m.get("title", "").replace("{", "").replace("}", ""); cont = m.get("container-title", "") or m.get("publisher", ""); typ = m.get("type", "")37 f = {"author": au, "title": "{" + title + "}", "year": year, "doi": doi}38 if typ in ("journal-article", "article-journal"): f.update({"journal": cont, "volume": m.get("volume"), "number": m.get("issue"), "pages": m.get("page")}); kind = "article"39 elif "posted-content" in typ or "report" in typ or "preprint" in typ or "ssrn" in doi.lower() or "arxiv" in doi.lower() or "3386" in doi: f.update({"institution": cont or m.get("publisher", ""), "type": "Working paper", "note": f"{cont or m.get('publisher', '')}, DOI {doi}".strip(", ")}); kind = "techreport"40 else: f.update({"howpublished": cont}); kind = "misc"41 body = ",\n".join(f" {k} = {{{v}}}" for k, v in f.items() if v not in (None, "", "{}")); return f"@{kind}{{{key},\n{body}\n}}\n"42out = {"resolved": [], "not_added": [], "when": dt.datetime.now().isoformat()}; entries = []43for key, doi, expect, anchor in WANT:44 try:45 m = csl(doi); title = m.get("title", ""); ok = all(e.lower() in title.lower() for e in expect) or any(e.lower() in title.lower() for e in expect)46 rec = {"key": key, "doi": doi, "title": title, "year": (m.get("issued", {}).get("date-parts") or [[None]])[0][0], "container": m.get("container-title", "") or m.get("publisher", ""), "n_authors": len(m.get("author", [])), "first_author": (m.get("author") or [{}])[0].get("family", ""), "anchor": anchor, "title_matches_expectation": ok}47 if ok: out["resolved"].append(rec); entries.append(bibtex(key, m, doi))48 else: rec["reason"] = "resolved DOI title does not match the referee's description"; out["not_added"].append(rec)49 print(("OK " if ok else "MISMATCH ") + key, "|", title[:80], "|", rec["year"], "|", rec["container"][:40], "| authors", rec["n_authors"], flush=True)50 except Exception as e:51 out["not_added"].append({"key": key, "doi": doi, "anchor": anchor, "reason": f"DOI did not resolve: {repr(e)[:120]}"}); print("FAIL", key, doi, repr(e)[:100], flush=True)52 time.sleep(0.4)53for key, q, anchor in QUERIES:54 try:55 items = crossref_query(q); cand = [{"doi": i.get("DOI"), "title": (i.get("title") or [""])[0], "year": (i.get("issued", {}).get("date-parts") or [[None]])[0][0], "container": (i.get("container-title") or [""])[0], "score": i.get("score")} for i in items]56 out["not_added"].append({"key": key, "anchor": anchor, "reason": "no identifier given by the referee; Crossref candidates listed for the author to confirm (not added)", "candidates": cand}); print("QUERY", key, [c["title"][:70] for c in cand], flush=True)57 except Exception as e:58 out["not_added"].append({"key": key, "anchor": anchor, "reason": f"query failed: {repr(e)[:100]}"})59 time.sleep(0.4)60# the two working-paper self-entries (no DOI; series, number, date from the manuscript)61entries.append("@techreport{uqowp0001,\n author = {Boucher, Simon-Pierre and Kammoun, Manel and Tandjambianda, Djerrycharli},\n title = {{From Corporate Disclosures to a Russell 3000 Strategic Project Database}},\n institution = {Universit\\'e du Qu\\'ebec en Outaouais, FIRC},\n type = {UQO/FIRC Working Paper},\n number = {0001},\n year = {2026},\n note = {Strategic Project Intelligence Database (SPID); EDGAR Research Database}\n}\n")62entries.append("@techreport{kammoun2026v11,\n author = {Kammoun, Manel and Tandjambianda, Djerrycharli and Boucher, Simon-Pierre},\n title = {{Does the Language of Artificial Intelligence Move Markets? A Semantic Analysis of S\\&P 500 SEC Filings and the Cross-Section of Stock Returns, 2010--2026}},\n institution = {Universit\\'e du Qu\\'ebec en Outaouais, FIRC},\n type = {UQO Working Paper (version 1.1, S\\&P 500)},\n number = {17},\n year = {2026},\n note = {Archived in docs/paper\\_v1.1\\_sp500\\_20261026/ of the replication repository}\n}\n")63bib = open("paper/references.bib").read(); keys = set(re.findall(r"@\w+\{([^,]+),", bib)); new = [e for e in entries if re.search(r"@\w+\{([^,]+),", e).group(1) not in keys]64if new:65 with open("paper/references.bib", "a") as f: f.write("\n% ---- Stage D review additions (FIRC-0002, 2026-11-05): DOIs resolved through doi.org / Crossref by scripts/r3k_21_bib_crossref.py; cite from Stage E ----\n" + "\n".join(new))66out["n_entries_appended"] = len(new); out["note_eisfeldt"] = "eisfeldt2023generative is kept (cited in the text); eisfeldt2026generative is the JF version to substitute at Stage E"67json.dump(out, open("results/r3k_v2/bib_additions.json", "w"), indent=2); print("appended", len(new), "entries; not added:", [x["key"] for x in out["not_added"]])68