pdf-engine 1.2.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_column_bridge` model: 200 trees, 5938 splits, depth at most 6, in 2 part(s).
//!
//! Model sha256 (of model.json): df028ae1f4cf01ff57d54a1f335ed7eef05f18e003cafe398acbcfcec1a92e62

mod part_00;
mod part_01;

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

/// The input, in order: `x[i]` is `FEATURES[i]`, NaN when missing.
pub const FEATURES: [&str; 14] = ["width_in_word_widths", "width_over_stripe", "lines_in_stripe", "words_in_stripe", "line_rank", "line_index", "words_in_line", "numeric", "bands_below_overlapped", "bands_below", "bands_other_overlapped", "share_of_stripe_lines_below", "stripes_in_table", "lines_below_overlapped_share"];

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