diff --git a/src/markdown/mod.rs b/src/markdown/mod.rs index 6070c2d..23ab03e 100644 --- a/src/markdown/mod.rs +++ b/src/markdown/mod.rs @@ -658,9 +658,16 @@ pub(crate) fn to_markdown_from_items_with_rects_and_lines( let mut rect_claimed: HashSet = HashSet::new(); // 0. Structure-tree detection (highest priority — semantic PDF tagging) + // Only use struct-tree tables when they capture a majority (≥50%) of + // band items. Incomplete struct trees (partial tagging) should fall + // through to geometry detection which sees all items. if !struct_tables.is_empty() { let st_tables = detect_tables_from_struct_tree(band_items, struct_tables, page); for table in &st_tables { + let coverage = table.item_indices.len() as f32 / band_items.len().max(1) as f32; + if coverage < 0.5 { + continue; + } for &idx in &table.item_indices { rect_claimed.insert(idx); if let Some(&page_idx) = band_index_map.get(idx) { @@ -678,12 +685,10 @@ pub(crate) fn to_markdown_from_items_with_rects_and_lines( } } - // 1. Rect-based detection (always runs; struct-tree claims prevent - // double-counting via table_items but rect may find additional tables) + // 1. Rect-based detection (skips tables overlapping struct-tree claims) let (rect_tables, hint_regions) = detect_tables_from_rects(band_items, band_rects, page); for table in &rect_tables { - // Skip rect tables that overlap with struct-tree claimed items if !rect_claimed.is_empty() && table .item_indices diff --git a/tests/snapshots/2013-app2.md b/tests/snapshots/2013-app2.md index 711d202..e5d4030 100644 --- a/tests/snapshots/2013-app2.md +++ b/tests/snapshots/2013-app2.md @@ -243,9 +243,9 @@ |199|24/9|Procurement of technical service for repair of generator 1B- varations|PUC|Golten Co Ltd|USD84,337.00| |200|24/9|Procurement of spare parts fro Wartsila Engine A21|PUC|Wartsila Global Logistic|Euro235,579.30| |201|24/9|Procurement of vehicle x 2|SLTA|Abhaye Valabhji Pty Ltd|SR1000.000.00| -|OCT|||||| +||OCT||||| |202|1/10|Proposed new traffic lane to 5th June Avenue|SLTA|Divy Constrution|SR2,864,589.00| -|203|1/10|Proposed Walkway, Drain, rock armoring , road and Bridge widening at Anse Talbot( Ex-Golden Egg) - Variations|SLTA|G & S Enterprise|SR200,448.00| +|203|1/10||Proposed Walkway, Drain, rock armoring , road and Bridge widening at Anse Talbot( Ex-Golden Egg) - Variations SLTA|G & S Enterprise|SR200,448.00| |204|1/10|Proposed Reconstrcution of Burnt House-Au Cap|MLUH|Furui Construction|SR946,130.00| |205|1/10|Variation on the project associated with the procurement of seven 100m3/day containerised plant|PUC|Tornado Group (UAE)|USD172,500.00| |206|1/10|Works on the breaker system at Bel Omber desalination plant|PUC|United Concrete Products (Sey)Ltd|SR1,998,993.11| @@ -260,20 +260,31 @@ |212|15/10|Renovation Works to Le Chantier Mall-Variation Works|SSF|Allied Builders Sey Ltd|SR1,673,752.51| |213|15/10|Security Services for District's Administration Offices and Community Centres-Lot 1|MSACDS|Eagle Watch Security Services|SR96,600.00| |213|15/10|Security Services for District's Administration Offices and Community Centres-Lot 2|MSACDS|Alliance Security Services|SR103,012.00| - -213 15/10 Security Services for District's Administration Offices and Community Centres-Lot 4 214 15/10 Anse Boileau Footpath and Drainage Construction Phase 2 - Variations 215 15/10 Construction of Fooothpath at Olivier Maradan Street-Variations 216 15/10 Operation and Maintenance of Containerised Desalination Units on Mahe 2013-2014 217 15/10 Procurement of Non Critical Spare Parts for Wartsila Engine 5B 218 15/10 Procurement of Meter Boxes 219 15/10 Construction of Services Road to Commercial Zone West of Inter Island Quay 220 15/10 Proposed New traffic lane from Roche Caiman to Eden Island 221 22/10 Procurement of Textbooks for Primary and Secondary Schools 221 22/10 Procurement of Textbooks for Primary and Secondary Schools 221 22/10 Procurement of Textbooks for Primary and Secondary Schools 221 22/10 Procurement of Textbooks for Primary and Secondary Schools 221 22/10 Procurement of Textbooks for Primary and Secondary Schools 222 22/10 Road Widening and Drainage Improvement at Quincy Village-Variations 223 22/10 Procurement of Grunfos Pumps for Mare Aux Cochons 224 22/10 Procurement of Vehicle x 3 225 22/10 Procurement of Agriculture Inputs 226 22/10 Provision of Utilities and Infrastructture on Ile Preseverance Island-Civil 09 22/10 Provision of Utilities and Infrastructture on Ile Preseverance Island-Civil 08 29/10 Proposed Completion of Corgate Estate Re-Development-Phase A (Zone A2) - Mont Fleuri 29/10 Construction of One Block of Condominium Flats at Pointe Larue 29/10 Proposed Construction of Micro-Enterprise Building at Providence 29/10 Renovation of English River Secondary Schools 29/10 Renovation and Partitioning of Independence House-Variation - -MSACDS SLTA - -PUC - -PUC MLUH SLTA MOE MOE MOE MOE MOE SLTA PUC MLUH SAA - -MLUH MLUH MLUH MLUH MLUH - -Security Protection Services TCH Contractor Benoiton Construction Pty Ltd Tornado Group (UAE) MAN Diesel & Turbo (UK) CAHORS (France) Allied Builders Sey Ltd Franky's Constrcution Seytex VCS Pty Ltd KIS Distribution Company MNM General Supply Roy & Sons Import TCH Building Contractor Bluezone Mauritius Sun Motors Launch Export (SA) Allied Builders Sey Ltd Allied Builders Sey Ltd Allied Builders Sey Ltd Franky's Constrcution O Nivo Construction Divy Constrution Green Island Construction Co Pty - -SR71,000.00 SR326,780.00 SR368,642.50 USD1,214,400.00 GDP88,360.88 Euro35,221.20 SR6,234,343.36 SR3,017,155.00 SR695,810.58 SR36,430.00 SR10,500.00 SR16,216.20 SR107,625.00 SR328,213.75 Euro44,914.00 SR2,310,000.00 ZAR720,100.00 SR14,964,125.91 SR35,927,978.92 SR10,372,824.02 SR18,063,876.00 SR28,462,412.00 SR2,133,560.00 SR1,847,477.43 +|213|15/10|Security Services for District's Administration Offices and Community Centres-Lot 4|MSACDS|Security Protection Services|SR71,000.00| +|214|15/10|Anse Boileau Footpath and Drainage Construction Phase 2 - Variations|SLTA|TCH Contractor|SR326,780.00| +|215|15/10|Construction of Fooothpath at Olivier Maradan Street-Variations||Benoiton Construction Pty Ltd|SR368,642.50| +|216|15/10|Operation and Maintenance of Containerised Desalination Units on Mahe 2013-2014|PUC|Tornado Group (UAE)|USD1,214,400.00| +|217|15/10|Procurement of Non Critical Spare Parts for Wartsila Engine 5B||MAN Diesel & Turbo (UK)|GDP88,360.88| +|218|15/10|Procurement of Meter Boxes|PUC|CAHORS (France)|Euro35,221.20| +|219|15/10|Construction of Services Road to Commercial Zone West of Inter Island Quay|MLUH|Allied Builders Sey Ltd|SR6,234,343.36| +|220|15/10|Proposed New traffic lane from Roche Caiman to Eden Island|SLTA|Franky's Constrcution|SR3,017,155.00| +|221|22/10|Procurement of Textbooks for Primary and Secondary Schools|MOE|Seytex|SR695,810.58| +|221|22/10|Procurement of Textbooks for Primary and Secondary Schools|MOE|VCS Pty Ltd|SR36,430.00| +|221|22/10|Procurement of Textbooks for Primary and Secondary Schools|MOE|KIS Distribution Company|SR10,500.00| +|221|22/10|Procurement of Textbooks for Primary and Secondary Schools|MOE|MNM General Supply|SR16,216.20| +|221|22/10|Procurement of Textbooks for Primary and Secondary Schools|MOE|Roy & Sons Import|SR107,625.00| +|222|22/10|Road Widening and Drainage Improvement at Quincy Village-Variations|SLTA|TCH Building Contractor|SR328,213.75| +|223|22/10|Procurement of Grunfos Pumps for Mare Aux Cochons|PUC|Bluezone Mauritius|Euro44,914.00| +|224|22/10|Procurement of Vehicle x 3|MLUH|Sun Motors|SR2,310,000.00| +|225|22/10|Procurement of Agriculture Inputs|SAA|Launch Export (SA)|ZAR720,100.00| +|226|22/10|Provision of Utilities and Infrastructture on Ile Preseverance Island-Civil 09||Allied Builders Sey Ltd|SR14,964,125.91| +|227|22/10|Provision of Utilities and Infrastructture on Ile Preseverance Island-Civil 08||Allied Builders Sey Ltd|SR35,927,978.92| +|228|29/10|Proposed Completion of Corgate Estate Re-Development-Phase A (Zone A2) - Mont Fleuri|MLUH|Allied Builders Sey Ltd|SR10,372,824.02| +|229|29/10|Construction of One Block of Condominium Flats at Pointe Larue|MLUH|Franky's Constrcution|SR18,063,876.00| +|230|29/10|Proposed Construction of Micro-Enterprise Building at Providence|MLUH|O Nivo Construction|SR28,462,412.00| +|231|29/10|Renovation of English River Secondary Schools|MLUH|Divy Constrution|SR2,133,560.00| +|232|29/10|Renovation and Partitioning of Independence House-Variation|MLUH|Green Island Construction Co Pty|SR1,847,477.43| +||||||6| |298|17/12|Renovation of Glacis Health Centre-Variations|MOH|F & P Construction|SR400,000.00| |---|---|---|---|---|---|