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
Across more than 800 legal footnotes, the workflow achieved 92% accuracy and reduced manual review cycles by 30%. Automated processing was paired with targeted review and direct manuscript cleanup.

One reference, followed through

IllustrativeIllustrative example — a fictional reference, not material from the manuscript.

  1. Original footnote

    1. 13M. Hale, The Ledger and the Law: Accounting Rules in Commercial Courts (Northfield University Press, 2016) at 198–240.
    2. 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.

  2. 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–240 212

    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.

  3. 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.

  4. 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.

  5. 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

  1. Hale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, Northfield
  2. Okafor R, Brandt L (2019) Audit trails as evidence. Halden Law Rev 41:77–102
  3. Vance T (2021) Records, receipts and reasonable doubt. Marlow Academic, London

Master bibliography

  1. Hale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, Northfieldcited in chapters 3 and 5 · listed once
  2. Okafor R, Brandt L (2019) Audit trails as evidence. Halden Law Rev 41:77–102
  3. Vance T (2021) Records, receipts and reasonable doubt. Marlow Academic, London
IllustrativeFictional entries showing the shape of the output: one chapter’s list, and the master list where a source cited in two chapters appears once.

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 numberOriginal footnoteConverted in-text citationGenerated bibliography entryOriginal bibliography entryAssociated chapter
13M. 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, NorthfieldHale, Margaret. The Ledger and the Law: Accounting Rules in Commercial Courts. Northfield: Northfield University Press, 2016.Chapter 3
14Id. at 212.(Hale 2016, p. 212)Hale M (2016) The ledger and the law: accounting rules in commercial courts. Northfield University Press, NorthfieldHale, Margaret. The Ledger and the Law: Accounting Rules in Commercial Courts. Northfield: Northfield University Press, 2016.Chapter 3
15See 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–102Okafor, R., and L. Brandt. “Audit Trails as Evidence.” Halden Law Review 41 (2019): 77–102.Chapter 3
16Supra note 9.Note 9 cites two sources; flagged for reviewChapter 3
17This distinction is developed further in Chapter 5.Explanatory note retainedChapter 3
IllustrativeIllustrative example — a fictional reference, not material from the manuscript. Rows 13–14 share one source; 16 is an exception record; 17 is an explanatory note kept as a note.

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

DeliverablePurpose
Converted manuscriptIn-text citations inserted at the original reference locations, with selected notes retained.
Chapter bibliographiesReference lists organized for the end of each chapter.
Master bibliographyA consolidated reference list for the end of the book.
Review matrixA side-by-side record of original references and transformed outputs.
Exception recordsAmbiguous or unmatched references identified for further review.

Tools and methods

AreaTools and approach
DevelopmentPython and Google Colab/Jupyter notebooks
Word document processingpython-docx, lxml, ZIP/XML manipulation
Citation resolutionRegular expressions, multi-stage parsing, dependency tracing
Source matchingText normalization, fuzzy matching, AI-assisted matching
Citation generationOpenAI API, example-driven prompts, formatting rules
Quality checksValidation, diagnostic logging, unit tests, and human review
Processing architectureModular stages and parallel processing
Editorial workCitation 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.