update
This commit is contained in:
@@ -285,17 +285,23 @@ pub async fn phase_clean_persons(db: &Database) -> (DirtySet, usize) {
|
||||
/// 这样可以防止停用词(如 "photo"、"model" 等通用词)被错误识别为人物。
|
||||
pub async fn phase_clean_stop_word_persons(db: &Database) -> (DirtySet, usize) {
|
||||
let persons = db.get_all_persons_with_counts().await;
|
||||
let dict = tag_dict::get_tag_dict();
|
||||
|
||||
// 预先复制停用词集合到本地 HashSet,避免持 RwLockReadGuard 穿越 await
|
||||
let stop_words: HashSet<String> = {
|
||||
let dict = tag_dict::get_tag_dict();
|
||||
dict.get_stop_words().clone()
|
||||
};
|
||||
|
||||
let mut dirty = DirtySet::new();
|
||||
let mut deleted = 0usize;
|
||||
|
||||
for (pid, name, _albums, _images) in &persons {
|
||||
// 检查人名本身是否在停用词中
|
||||
let in_stop_words = dict.is_stop_word(name)
|
||||
|| dict.is_stop_word(&name.to_lowercase());
|
||||
// 检查中文核心是否在停用词中(例如 "杨晨晨" 不在,但 "photo" 可能在)
|
||||
let in_stop_words = stop_words.contains(name)
|
||||
|| stop_words.contains(&name.to_lowercase());
|
||||
// 检查中文核心是否在停用词中
|
||||
let cn_in_stop_words = title_parser::extract_cn(name)
|
||||
.map(|cn| dict.is_stop_word(&cn))
|
||||
.map(|cn| stop_words.contains(&cn))
|
||||
.unwrap_or(false);
|
||||
|
||||
if in_stop_words || cn_in_stop_words {
|
||||
|
||||
Reference in New Issue
Block a user