pdf-engine 1.1.0

Unified PDF rendering engine — page rendering, text extraction, thumbnails.
Documentation
// @generated by scripts/extraction/learned/export_rust.py -- do not edit.
//
// Copyright (c) 2026 Innovation Trigger B.V.
//
// PDFluent is available under two licences, at your option: the GNU AGPLv3, or
// the PDFluent Commercial Licence. See the LICENSE file in this repository --
// that file travels with the copy you received, which a URL does not.
//! The `table_judge` model: 200 trees, 5913 splits, depth at most 6, in 2 part(s).
//!
//! Model sha256 (of model.json): 1171cfa0aa2a2ef91787cdb5c9c0042cb7fbd52c957fcd481f647f0e0e3f7a18

mod part_00;
mod part_01;

/// The sha256 of the LightGBM dump this code was generated from.
pub const MODEL_SHA256: &str = "1171cfa0aa2a2ef91787cdb5c9c0042cb7fbd52c957fcd481f647f0e0e3f7a18";

/// The input, in order: `x[i]` is `FEATURES[i]`, NaN when missing.
pub const FEATURES: [&str; 35] = ["from_builder", "from_aligned", "from_booktabs", "from_pair", "from_leader", "from_alignment_lines", "from_split", "from_union", "lines", "lines_share_of_page", "words_per_line", "width_share", "height_share", "numeric_share", "leader_share", "short_line_share", "table_cell_share", "paragraph_share", "list_share", "heading_share", "rows", "columns", "fill", "gap_above", "gap_below", "best_iou_regions", "best_iou_alignment", "regions_overlapped", "grid_fill", "grid_columns", "accepted", "year_tick_share", "alpha_line_share", "list_mean", "list_max"];

/// The probability at or above which the decision is taken, chosen on the
/// validation documents and recorded in the model's manifest.
pub const THRESHOLD: f64 = 0.15_f64;

/// LightGBM's numerical decision, missing values included.
#[inline(always)]
fn go_left(value: f64, threshold: f64, default_left: bool, missing: u8) -> bool {
    // 0: None, 1: Zero, 2: NaN -- LightGBM's MissingType.
    let value = if missing != 2 && value.is_nan() { 0.0 } else { value };
    if (missing == 1 && value.abs() <= 1e-35) || (missing == 2 && value.is_nan()) {
        return default_left;
    }
    value <= threshold
}

/// The raw margin: the sum of the trees, before the sigmoid.
pub fn predict_margin(x: &[f64; 35]) -> f64 {
    let acc = 0.0;
    let acc = part_00::add(x, acc);
    part_01::add(x, acc)
}