<commit_before>use detect;

use rb;
use rb::{CallbackPtr, Value, RB_NIL};

// Initialize all of the Ruby-specific static variables.
lazy_static! {
  // Lookup table for Ruby Results
  static ref RUBY_RESULTS: [Value; 16] = [
    RB_NIL,                  // 0
    str2sym!("devanagari"),  // 1
    str2sym!("bengali") ,    // 2
    str2sym!("gurmukhi"),    // 3
    str2sym!("gujarati"),    // 4
    str2sym!("oriya"),       // 5
    str2sym!("tamil"),       // 6
    str2sym!("telugu"),      // 7
    str2sym!("kannada"),     // 8
    str2sym!("malayalam"),   // 9
    str2sym!("iast"),        // 10
    str2sym!("kolkata"),     // 11
    str2sym!("itrans"),      // 12
    str2sym!("slp1"),        // 13
    str2sym!("velthuis"),    // 14
    str2sym!("hk")           // 15
  ];
}

fn rbstr_detect_scheme(_rself: Value, s: Value) -> Value {
  let r_str = rbstr2str!(&s);
  let result = detect::detect_scheme(r_str);
  return RUBY_RESULTS[result];
}

#[no_mangle]
pub extern fn init_rusty_sanscript() {
  let m_sanscript = rb::define_module("Sanscript");
  let m_detect = rb::define_module_under(&m_sanscript, "Detect");
  let m_rust = rb::define_module_under(&m_sanscript, "Rust");
  let m_rust_detect = rb::define_module_under(&m_rust, "Detect");
  rb::define_method(&m_rust_detect, "rust_detect_scheme",
    rbstr_detect_scheme as CallbackPtr, 1);
  rb::extend_object(&m_detect, &m_rust_detect);
}
<commit_msg>Slim down proxy rust detect method.<commit_after>use detect;

use rb;
use rb::{CallbackPtr, Value, RB_NIL};

// Initialize all of the Ruby-specific static variables.
lazy_static! {
  // Lookup table for Ruby Results
  static ref RUBY_RESULTS: [Value; 16] = [
    RB_NIL,                  // 0
    str2sym!("devanagari"),  // 1
    str2sym!("bengali") ,    // 2
    str2sym!("gurmukhi"),    // 3
    str2sym!("gujarati"),    // 4
    str2sym!("oriya"),       // 5
    str2sym!("tamil"),       // 6
    str2sym!("telugu"),      // 7
    str2sym!("kannada"),     // 8
    str2sym!("malayalam"),   // 9
    str2sym!("iast"),        // 10
    str2sym!("kolkata"),     // 11
    str2sym!("itrans"),      // 12
    str2sym!("slp1"),        // 13
    str2sym!("velthuis"),    // 14
    str2sym!("hk")           // 15
  ];
}

fn rbstr_detect_scheme(_rself: Value, s: Value) -> Value {
  let result = detect::detect_scheme(&rbstr2str!(&s));
  return RUBY_RESULTS[result];
}

#[no_mangle]
pub extern fn init_rusty_sanscript() {
  let m_sanscript = rb::define_module("Sanscript");
  let m_detect = rb::define_module_under(&m_sanscript, "Detect");
  let m_rust = rb::define_module_under(&m_sanscript, "Rust");
  let m_rust_detect = rb::define_module_under(&m_rust, "Detect");
  rb::define_method(&m_rust_detect, "rust_detect_scheme",
    rbstr_detect_scheme as CallbackPtr, 1);
  rb::extend_object(&m_detect, &m_rust_detect);
}

{'fraction_non_alphanumeric': 0.16902404526166903, 'fraction_numerical': 0.0297029702970297, 'mean_word_length': 2.967741935483871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2312973', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1063, 'n_words': 202}