// @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_item` model: 600 trees, 17976 splits, depth at most 8, in 4 part(s).
//!
//! Model sha256 (of model.json): 130e233897080bcf368ddbfe2ed978b9725a05f4e899bd127af03856e98c7736
mod part_00;
mod part_01;
mod part_02;
mod part_03;
/// The sha256 of the LightGBM dump this code was generated from.
pub const MODEL_SHA256: &str = "130e233897080bcf368ddbfe2ed978b9725a05f4e899bd127af03856e98c7736";
/// The input, in order: `x[i]` is `FEATURES[i]`, NaN when missing.
pub const FEATURES: [&str; 50] = ["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", "first_line_marker_bullet", "first_line_marker_ordered", "first_line_marker_figure", "first_line_first_token_chars", "first_line_first_gap_em", "first_line_indent_em", "first_line_indent_vs_prev_em", "first_line_prev_short_em", "first_line_prev_ends_terminal", "first_line_prev_runs_on", "first_line_width_frac", "first_line_size_ratio", "first_line_bold", "first_line_line_index", "first_line_lines_in_block", "first_line_gap_above_em", "first_line_block_is_list", "first_line_block_size_ratio", "first_line_first_is_lone_symbol", "first_line_same_head_on_page", "first_line_block_is_table_cell", "first_line_max_gap_em", "first_line_prev_block_ends_colon", "line_p_list_mean", "line_p_list_max", "line_p_list_first"];
/// 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; 50]) -> f64 {
let acc = 0.0;
let acc = part_00::add(x, acc);
let acc = part_01::add(x, acc);
let acc = part_02::add(x, acc);
part_03::add(x, acc)
}