ws-segment-rs 0.1.1

Chinese word segmentation for web novels (Rust port of novel-segment)
Documentation
//! Color word lists for AdjectiveOptimizer.

mod color_rgb {
    include!("color_rgb.rs");
}

use once_cell::sync::Lazy;
use std::collections::HashSet;

const COLOR_HAIR_RAW: &[&str] = &[
    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
    "绿", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
    "", "",
];

const COLOR_EXTRA: &[&str] = &[
    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
    "", "", "", "", "", "",
];

fn expand(raw: &[&str]) -> HashSet<String> {
    #[cfg(feature = "default-dict")]
    {
        novel_segment_dict::arr_cjk(raw.iter().copied()).into_iter().collect()
    }
    #[cfg(not(feature = "default-dict"))]
    {
        raw.iter().map(|s| (*s).to_string()).collect()
    }
}

pub static COLOR_HAIR: Lazy<HashSet<String>> = Lazy::new(|| expand(COLOR_HAIR_RAW));

pub static COLOR_ALL: Lazy<HashSet<String>> = Lazy::new(|| {
    let mut s = expand(COLOR_HAIR_RAW);
    s.extend(expand(COLOR_EXTRA));
    s.extend(expand(color_rgb::COLOR_WITH_RGB));
    s
});