Structure: no-heading fallback also works for short books (body threshold relative to the median page)

This commit is contained in:
Audiobook Producer
2026-10-18 13:56:40 -05:00
parent a1138b016a
commit 13e6607abe
2 changed files with 11 additions and 2 deletions
+6
View File
@@ -72,6 +72,12 @@ class HeadingTests(unittest.TestCase):
self.assertEqual(structure.unknown_words("The Four Metiiods of Respiration"), 1)
self.assertEqual(structure.unknown_words("The Four Methods of Respiration"), 0)
def test_short_book_without_headings_still_gets_a_chapter(self):
speech = "Four score and seven years ago our fathers brought forth on this continent a new nation. " * 3
units = [unit("THE ADDRESS"), unit(""), unit("DELIVERED BY A. LINCOLN\nAT THE DEDICATION"), unit(speech, 4), unit(speech, 5), unit(speech, 6)]
got = structure.find_headings(units)
self.assertEqual((len(got), got[0]["unit"]), (1, 3))
def test_nothing_readable_gives_no_headings(self):
self.assertEqual(structure.find_headings([unit(""), unit("x")]), [])