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_verifier` model: 300 trees, 8994 splits, depth at most 6, in 2 part(s).
//!
//! Model sha256 (of model.json): c5183209ec4d2ab66d30959378e32966f3f9efebe66519939b562ca402ee8535

mod part_00;
mod part_01;

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

/// The input, in order: `x[i]` is `FEATURES[i]`, NaN when missing.
pub const FEATURES: [&str; 18] = ["judge_p", "from_builder", "words", "rows", "columns", "fill", "numeric_share", "header_gap", "row_cv", "column_residual", "near_miss", "edge_cut", "agreement", "caption_above", "prose_cells", "area_share", "spanning_share", "prose_column"];

/// 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.0_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; 18]) -> f64 {
    let acc = 0.0;
    let acc = part_00::add(x, acc);
    part_01::add(x, acc)
}