// @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_region` model: 267 trees, 8010 splits, depth at most 12, in 2 part(s).
//!
//! Model sha256 (of model.json): 0662b36e0aa42aa33ed0b0b8a3d1e5c287cf10e10edee61ed08ccf10d209631c
mod part_00;
mod part_01;
/// The sha256 of the LightGBM dump this code was generated from.
pub const MODEL_SHA256: &str = "0662b36e0aa42aa33ed0b0b8a3d1e5c287cf10e10edee61ed08ccf10d209631c";
/// The input, in order: `x[i]` is `FEATURES[i]`, NaN when missing.
pub const FEATURES: [&str; 35] = ["size_ratio", "bold", "italic", "all_caps", "n_chars", "n_words", "n_lines", "x_frac", "width_frac", "y_frac", "gap_above_em", "gap_below_em", "ends_terminal", "ends_colon", "section_number", "has_marker", "has_caption", "first_on_page", "last_on_page", "prev_ends_terminal", "prev_size_ratio", "next_x_frac", "next_size_ratio", "repeats_in_document", "leader_run", "numeric_share", "short_words", "kind_is_cell", "kind_is_paragraph", "prev_is_cell", "next_is_cell", "gap_above_line", "gap_below_line", "neighbours_within_a_line", "x_frac_of_widest"];
/// 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.4_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)
}