Enhance table title handling and improve heading detection logic
- Added logic to set `table_title` from `caption` if it is under 160 characters and not already set. - Updated `_blocks_from_content_list` to assign `table_title` based on `caption` length. - Introduced new regex patterns for better detection of TOC entries and noise. - Enhanced heading detection to differentiate between numbered instructions and actual headings. - Added tests to verify that table captions are correctly assigned as titles and that numbered instructions are treated as body text.
This commit is contained in:
@@ -134,6 +134,21 @@ class MineruAdapterMappingTest(unittest.TestCase):
|
||||
self.assertEqual(blocks[0].type, BlockType.PARAGRAPH)
|
||||
self.assertTrue(blocks[0].meta.get("is_footnote"))
|
||||
|
||||
def test_table_caption_becomes_table_title(self) -> None:
|
||||
items = [
|
||||
{
|
||||
"type": "table",
|
||||
"table_body": "| Field | Description |\n| --- | --- |\n| id | Identifier |",
|
||||
"table_caption": ["第一节 综合资讯栏"],
|
||||
"page_idx": 7,
|
||||
}
|
||||
]
|
||||
|
||||
blocks = _blocks_from_content_list(items, Path("content_list.json"), Path("assets"))
|
||||
|
||||
self.assertEqual(len(blocks), 1)
|
||||
self.assertEqual(blocks[0].meta.get("table_title"), "第一节 综合资讯栏")
|
||||
|
||||
def test_list_items_become_paragraph(self) -> None:
|
||||
items = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user