update
This commit is contained in:
@@ -176,7 +176,7 @@ fn extract_tags_with_jieba(
|
|||||||
if seen.contains(&word_lower) { continue; }
|
if seen.contains(&word_lower) { continue; }
|
||||||
|
|
||||||
// 按词性过滤:只保留名词相关,但排除人名(nr)
|
// 按词性过滤:只保留名词相关,但排除人名(nr)
|
||||||
let pos = tag.tag.as_str();
|
let pos = tag.tag;
|
||||||
let category = match pos {
|
let category = match pos {
|
||||||
// 名词类(排除人名)
|
// 名词类(排除人名)
|
||||||
"n" | "ng" => "noun", // 普通名词
|
"n" | "ng" => "noun", // 普通名词
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ fn extract_person_with_jieba(title: &str) -> Option<String> {
|
|||||||
let word = tag.word.trim();
|
let word = tag.word.trim();
|
||||||
if word.len() < 2 { continue; }
|
if word.len() < 2 { continue; }
|
||||||
|
|
||||||
let priority = match tag.tag.as_str() {
|
let priority = match tag.tag {
|
||||||
"nr" => 0, // 人名(最高优先级)
|
"nr" => 0, // 人名(最高优先级)
|
||||||
"nrfg" => 1, // 古体人名
|
"nrfg" => 1, // 古体人名
|
||||||
"nrt" => 2, // 音译人名
|
"nrt" => 2, // 音译人名
|
||||||
@@ -482,14 +482,14 @@ pub fn extract_person_and_tags(title: &str) -> (Option<String>, Vec<(String, Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 从 jieba 分词结果中提取人名
|
/// 从 jieba 分词结果中提取人名
|
||||||
fn extract_person_from_tags(tags: &[jieba_rs::Token]) -> Option<String> {
|
fn extract_person_from_tags(tags: &[jieba_rs::Tag]) -> Option<String> {
|
||||||
let mut candidates: Vec<(String, usize)> = Vec::new();
|
let mut candidates: Vec<(String, usize)> = Vec::new();
|
||||||
|
|
||||||
for tag in tags {
|
for tag in tags {
|
||||||
let word = tag.word.trim();
|
let word = tag.word.trim();
|
||||||
if word.len() < 2 { continue; }
|
if word.len() < 2 { continue; }
|
||||||
|
|
||||||
let priority = match tag.tag.as_str() {
|
let priority = match tag.tag {
|
||||||
"nr" => 0, // 人名(最高优先级)
|
"nr" => 0, // 人名(最高优先级)
|
||||||
"nrfg" => 1, // 古体人名
|
"nrfg" => 1, // 古体人名
|
||||||
"nrt" => 2, // 音译人名
|
"nrt" => 2, // 音译人名
|
||||||
@@ -509,7 +509,7 @@ fn extract_person_from_tags(tags: &[jieba_rs::Token]) -> Option<String> {
|
|||||||
|
|
||||||
/// 从 jieba 分词结果中提取标签(排除人名)
|
/// 从 jieba 分词结果中提取标签(排除人名)
|
||||||
fn extract_tags_from_jieba_result(
|
fn extract_tags_from_jieba_result(
|
||||||
tags: &[jieba_rs::Token],
|
tags: &[jieba_rs::Tag],
|
||||||
person_name: Option<&str>,
|
person_name: Option<&str>,
|
||||||
) -> Vec<(String, String)> {
|
) -> Vec<(String, String)> {
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
@@ -553,7 +553,7 @@ fn extract_tags_from_jieba_result(
|
|||||||
if !seen.insert(word_lower.clone()) { continue; }
|
if !seen.insert(word_lower.clone()) { continue; }
|
||||||
|
|
||||||
// 按词性分类
|
// 按词性分类
|
||||||
let pos = tag.tag.as_str();
|
let pos = tag.tag;
|
||||||
let category = match pos {
|
let category = match pos {
|
||||||
"n" | "ng" => "noun",
|
"n" | "ng" => "noun",
|
||||||
"nz" => "proper",
|
"nz" => "proper",
|
||||||
|
|||||||
Reference in New Issue
Block a user