use momentry_core::core::text::global_synonym_expander;

fn main() {
    let expander = global_synonym_expander();
    let query = "電腦";

    println!("原始查詢: '{}'", query);
    let expanded = expander.expand_chinese_query(query);
    println!("擴展結果: '{}'", expanded);

    // 測試 split
    let groups: Vec<&str> = if expanded.contains('&') {
        expanded.split('&').map(|s| s.trim()).collect()
    } else {
        expanded.split_whitespace().collect()
    };

    println!("分組: {:?}", groups);

    for group in groups {
        println!("  分組: '{}'", group);
        let terms = if group.starts_with('(') && group.ends_with(')') {
            let inner = &group[1..group.len() - 1];
            inner.split('|').map(|s| s.trim()).collect::<Vec<&str>>()
        } else {
            vec![group]
        };
        println!("    詞語: {:?}", terms);

        for term in &terms {
            let cleaned: String = term
                .chars()
                .filter(|c| c.is_alphanumeric() || c.is_alphabetic())
                .collect();
            println!("    詞語 '{}' -> 清理後 '{}'", term, cleaned);
        }
    }
}
