
Period: 2025
Following the footnotes.
Turning a manuscript’s tangled references into in-text citations, organized bibliographies, and reviewable results.
- Role
- Research Assistant — Ted Rogers School of Management
- Supervisor
- Professor Ralph Gil
- Tools
- Python
- Google Colab/Jupyter
- python-docx
- lxml
- Regular expressions
- Fuzzy matching
- OpenAI API
A formatting task, until it wasn’t
Preparing a legal manuscript for publication meant changing more than the appearance of its references.
Footnote-based citations needed to become Springer Law-style in-text citations. Each chapter needed its own bibliography, and the book needed a master bibliography. Throughout the conversion, references had to remain connected to the correct sources and their original locations in the text.
As a research assistant working with Professor Ralph Gil at Toronto Metropolitan University’s Ted Rogers School of Management, I built Python tooling to support that transformation and worked directly on the manuscript to review and refine the results.
The work combined document processing, citation resolution, AI-assisted conversion, and editorial judgment.
The problem with “just replace the footnotes”
Some notes contained complete references. Others pointed back to earlier notes through Id., Ibid., or Supra. A single footnote could contain several sources, additional commentary, or a different pinpoint page.
Replacing the visible number was the easy part. Determining what belonged in its place required understanding the reference behind it.
The workflow also needed to distinguish citations that could move into the text from explanatory notes that should remain, while preserving the manuscript’s headings, numbering, and document structure.
What I built
I developed a multi-stage pipeline to extract references, resolve dependencies, match sources, generate citations, and write the transformed material back into Word documents.
The system also produced chapter-level bibliographies, a master bibliography, and comparison documents for reviewing the changes.
- 800+legal footnotes
- 92%accuracy
- 30%fewer manual review cycles
One reference, followed through
IllustrativeIllustrative example — a fictional reference, not material from the manuscript.
Original footnote
- 13M. Hale, The Ledger and the Law: Accounting Rules in Commercial Courts (Northfield University Press, 2016) at 198–240.
- 14Id. at 212.
Note 14 points back to an earlier note through Id., with a different pinpoint page. On its own it names no source.
Source match
Id. at 212 resolves to note 13 which cites Hale 2016
- Author
- Hale
- Year
- 2016
- Title
- The Ledger and the Law
- Pinpoint
198–240212
Original bibliography entryHale, Margaret. The Ledger and the Law: Accounting Rules in Commercial Courts. Northfield: Northfield University Press, 2016.
Id. resolves to note 13. Normalized author, year and title are matched against the original bibliography; the pinpoint changes from the full range to page 212.
In-text citation
BeforeSeveral courts treated the ledger itself as evidence.14
AfterSeveral courts treated the ledger itself as evidence (Hale 2016, p. 212).
The citation is generated in the manuscript style and written back at the original reference location, with the surrounding punctuation handled.
Bibliography entry
Chapter 3 · ReferencesHale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, Northfield
Master bibliographyListed once, alphabetically, with the book’s other sources.
The source is standardized for the chapter bibliography and appears once in the master bibliography, whichever chapters cite it.
Review row
- Original reference number
- 14
- Original footnote
- Id. at 212.
- Converted in-text citation
- (Hale 2016, p. 212)
- Generated bibliography entry
- Hale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, Northfield
- Original bibliography entry
- Hale, Margaret. The Ledger and the Law: Accounting Rules in Commercial Courts. Northfield: Northfield University Press, 2016.
- Associated chapter
- Chapter 3
One row connects the original reference number, footnote, converted citation, generated and original bibliography entries, and chapter, so the change can be checked.
01 · Extract and organize
The first step was turning the manuscript’s reference material into structured data.
I extracted footnote text and bibliography entries from Word documents, preserving reference identifiers so each transformation could be traced back to its source.
Working with DOCX files required both document-level tooling and direct XML processing. The visible text was only part of the structure: footnote references and their positions were represented within the underlying document markup.
02 · Follow the reference
Legal citations often depend on something written earlier.
I built multi-stage parsing to resolve Id., Ibid., and Supra references, including nested dependencies and changes to pinpoint pages. The goal was to recover the underlying source before attempting to convert its format.
Source matching combined normalized author, year, and title information with fuzzy matching and AI-assisted interpretation where needed.
Ambiguous references were flagged for review rather than treated as unquestionably correct matches.
03 · Convert the citation
Once a reference had been identified, the pipeline generated its in-text citation in the required manuscript style.
The conversion accounted for different source types, including academic publications, books, legal cases, statutes, and online material. It also handled grouped sources and the distinction between a publication’s full page range and the specific pages cited in the text.
AI-assisted generation was supported by explicit formatting instructions, examples, deterministic cleanup, and manual corrections.
Selected explanatory notes were retained instead of being forced into an author-date format.
04 · Put it back in place
The generated citation needed to appear at the original reference location.
I used direct DOCX XML manipulation to replace footnote-reference elements with citation text, handling surrounding punctuation, spacing, and formatting.
This connected citation generation to the actual manuscript rather than leaving the result as a separate list of suggested replacements.
Preserving document structure remained part of the task throughout the process.
05 · Rebuild the bibliographies
The manuscript required both local and book-wide reference lists.
I associated references with their chapters, standardized bibliography entries, handled duplicates, and sorted the results alphabetically.
The workflow generated chapter-by-chapter bibliographies and a master bibliography for the end of the book. Cleanup covered author initials, capitalization, punctuation, publication details, and page-range formatting.
Entries without a reliable bibliography match were separated for further review.
Chapter 3 · References
- Hale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, Northfield
- Okafor R, Brandt L (2019) Audit trails as evidence. Halden Law Rev 41:77–102
- Vance T (2021) Records, receipts and reasonable doubt. Marlow Academic, London
Master bibliography
- Hale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, Northfieldcited in chapters 3 and 5 · listed once
- Okafor R, Brandt L (2019) Audit trails as evidence. Halden Law Rev 41:77–102
- Vance T (2021) Records, receipts and reasonable doubt. Marlow Academic, London
06 · Make the transformation reviewable
A converted document alone was not enough to assess the work.
Validation checks and diagnostic logging helped surface ambiguous references and trace problems through the workflow.
I generated a review matrix connecting:
- The original reference number.
- The original footnote.
- The converted in-text citation.
- The generated bibliography entry.
- The original bibliography entry.
- The associated chapter.
| Original reference number | Original footnote | Converted in-text citation | Generated bibliography entry | Original bibliography entry | Associated chapter |
|---|---|---|---|---|---|
| 13 | M. Hale, The Ledger and the Law: Accounting Rules in Commercial Courts (Northfield University Press, 2016) at 198–240. | (Hale 2016, pp. 198–240) | Hale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, Northfield | Hale, Margaret. The Ledger and the Law: Accounting Rules in Commercial Courts. Northfield: Northfield University Press, 2016. | Chapter 3 |
| 14 | Id. at 212. | (Hale 2016, p. 212) | Hale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, Northfield | Hale, Margaret. The Ledger and the Law: Accounting Rules in Commercial Courts. Northfield: Northfield University Press, 2016. | Chapter 3 |
| 15 | See R. Okafor & L. Brandt, “Audit Trails as Evidence” (2019) 41 Halden Law Review 77. | (Okafor and Brandt 2019) | Okafor R, Brandt L (2019) Audit trails as evidence. Halden Law Rev 41:77–102 | Okafor, R., and L. Brandt. “Audit Trails as Evidence.” Halden Law Review 41 (2019): 77–102. | Chapter 3 |
| 16 | Supra note 9. | Note 9 cites two sources; flagged for review | Chapter 3 | ||
| 17 | This distinction is developed further in Chapter 5. | Explanatory note retained | Chapter 3 | ||
This made it possible to inspect the relationship between the source material and the proposed output, identify inconsistencies, and make targeted corrections.
Beyond the code
I also worked directly on the manuscript.
That included reviewing citations we were uncertain about, cleaning bibliography entries, correcting formatting and headings, and cross-checking the generated material against the original sources.
I checked the chapter bibliographies and master bibliography for consistency, making sure the references were appropriate in both format and scope.
The final workflow combined automated processing with editorial review. The code handled repeated transformations; direct review addressed the cases that required closer interpretation.
Engineering the workflow
I organized the processing into modular stages so extraction, matching, citation generation, cleanup, and export could be developed and checked separately.
Parallel processing supported the larger conversion workload, while unit tests covered individual components. Targeted reruns and manual overrides allowed problematic references to be corrected without treating every output as final.
The work involved both building the pipeline and refining it against the manuscript’s exceptions.
Outputs
| Deliverable | Purpose |
|---|---|
| Converted manuscript | In-text citations inserted at the original reference locations, with selected notes retained. |
| Chapter bibliographies | Reference lists organized for the end of each chapter. |
| Master bibliography | A consolidated reference list for the end of the book. |
| Review matrix | A side-by-side record of original references and transformed outputs. |
| Exception records | Ambiguous or unmatched references identified for further review. |
Tools and methods
| Area | Tools and approach |
|---|---|
| Development | Python and Google Colab/Jupyter notebooks |
| Word document processing | python-docx, lxml, ZIP/XML manipulation |
| Citation resolution | Regular expressions, multi-stage parsing, dependency tracing |
| Source matching | Text normalization, fuzzy matching, AI-assisted matching |
| Citation generation | OpenAI API, example-driven prompts, formatting rules |
| Quality checks | Validation, diagnostic logging, unit tests, and human review |
| Processing architecture | Modular stages and parallel processing |
| Editorial work | Citation correction, bibliography cleanup, formatting, headings, and cross-checking |
What I took from it
Research automation has to preserve relationships as well as transform text.
A citation needs to point to the right source, appear in the right place, and remain consistent with the bibliography. A small formatting change can expose a much larger question about what a reference actually means.
This project taught me to build review into the workflow: preserve the original material, make transformations inspectable, and leave room for judgment when the answer is uncertain.
Sometimes the most useful output is a corrected citation. Sometimes it is a clear indication that someone needs to look again.