Structure: no-heading fallback also works for short books (body threshold relative to the median page)
This commit is contained in:
@@ -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")]), [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user