feat: backup architecture docs, source code, and scripts

This commit is contained in:
Warren
2026-04-25 17:15:45 +08:00
parent 59809dae1f
commit 1f84e5469f
368 changed files with 146329 additions and 261 deletions

38
src/bin/debug_tsquery.rs Normal file
View File

@@ -0,0 +1,38 @@
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);
}
}
}