diff --git a/src/cmos/note_formatter.py b/src/cmos/note_formatter.py index 0e378c1..a6b1cab 100644 --- a/src/cmos/note_formatter.py +++ b/src/cmos/note_formatter.py @@ -99,9 +99,13 @@ Rules you must follow (CMOS 18th edition specifically, NOTE form): 6. CHAPTER IN EDITED BOOK NOTE FORM: Author, "Chapter Title," in *Book Title*, ed. Editor Names (Publisher, Year), specific-page. - Use "ed." (abbreviated), NOT "Edited by". The lowercase "in" - before the italicized book title is part of CMOS note form - and should appear as shown. + Use "ed." (abbreviated), NOT "Edited by". The abbreviation "ed." + is INVARIANT — use "ed." even when there are multiple editors. + Do NOT pluralize to "eds." regardless of editor count. CMOS NB + note form treats "ed." as an unchanging abbreviation, not a + grammatical word that agrees in number with its referent. + The lowercase "in" before the italicized book title is part of + CMOS note form and should appear as shown. 7. TRANSLATED WORKS use "trans." (abbreviated), NOT "Translated by". @@ -168,6 +172,20 @@ Rules you must follow (CMOS 18th edition specifically, NOTE form): missing in the source, leave it missing. Do not fabricate authors, publishers, years, page numbers, URLs, or DOIs. +18. PUBLISHER NAMES must be in FULL canonical form. Do NOT abbreviate. + If the messy input contains an abbreviated form, EXPAND it to the + canonical full name. Examples: + - "U of Chicago Press" → "University of Chicago Press" + - "OUP" → "Oxford University Press" + - "CUP" → "Cambridge University Press" + - "HMC" → "Houghton Mifflin Company" + - "Random House" stays "Random House" (already canonical) + - "Pantheon Books" stays "Pantheon Books" (already canonical) + The exception: publishers whose canonical self-presentation + legitimately uses initials (e.g., "MIT Press", "ALA Editions", + "MLA") stay in that form. When in doubt, prefer the longer + form over the abbreviation. + Output ONLY the single reformatted note. No preamble, no explanation, no leading number, no code fences. """ diff --git a/tests/test_note_formatter.py b/tests/test_note_formatter.py index a985e86..e7b7488 100644 --- a/tests/test_note_formatter.py +++ b/tests/test_note_formatter.py @@ -53,6 +53,38 @@ def test_system_prompt_mentions_no_ibid(): assert "Ibid" in SYSTEM_PROMPT_NOTES or "ibid" in SYSTEM_PROMPT_NOTES.lower() +def test_system_prompt_mentions_publisher_full_form(): + """Surfaced by chunk 1 smoke test on chapter_first_doyle: the formatter + preserved 'U of Chicago Press' from the messy input instead of + expanding it to 'University of Chicago Press'. v1 formatter.py rule 14 + covers this; the v2 prompt must too. The rule is "publisher names must + be in full canonical form, not abbreviated." + """ + lower = SYSTEM_PROMPT_NOTES.lower() + assert "publisher" in lower + # Either "do not abbreviate" or "full canonical" or "full form" — any + # phrasing that conveys the prohibition. + assert ( + "do not abbreviate" in lower + or "not abbreviated" in lower + or "full canonical" in lower + or "full form" in lower + ) + + +def test_system_prompt_mentions_ed_invariant_for_multiple_editors(): + """Surfaced by chunk 1 smoke test on chapter_first_doyle: the formatter + pluralized 'ed.' to 'eds.' when there were two editors. CMOS NB form + uses 'ed.' invariantly regardless of editor count. The prompt must + explicitly state this so the model does not grammatically pluralize + by default. + """ + # Search for an explicit mention of "eds." being wrong, OR an explicit + # statement that "ed." is invariant / not pluralized. + lower = SYSTEM_PROMPT_NOTES.lower() + assert "eds." in lower or "invariant" in lower or "do not pluralize" in lower or "not pluralize" in lower + + def test_build_user_message_contains_the_messy_input(): msg = build_user_message("yu, charles. interior chinatown. 2020, 45") assert "yu, charles. interior chinatown. 2020, 45" in msg