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 `list_opens` model: 447 trees, 13406 splits, depth at most 8, in 3 part(s).
//!
//! Model sha256 (of model.json): b46d25b373a250c5c13f353833d82fb45942c718626f922b82cfab92218c5c6b

mod part_00;
mod part_01;
mod part_02;

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

/// The input, in order: `x[i]` is `FEATURES[i]`, NaN when missing.
pub const FEATURES: [&str; 23] = ["marker_bullet", "marker_ordered", "marker_figure", "first_token_chars", "first_gap_em", "indent_em", "indent_vs_prev_em", "prev_short_em", "prev_ends_terminal", "prev_runs_on", "width_frac", "size_ratio", "bold", "line_index", "lines_in_block", "gap_above_em", "block_is_list", "block_size_ratio", "first_is_lone_symbol", "same_head_on_page", "block_is_table_cell", "max_gap_em", "prev_block_ends_colon"];

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