mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 03:26:37 +08:00
fix(classify): anime 无元数据时纯中文译名不再误判国漫
日本动画的中文译名几乎都是纯汉字(如「葬送的芙莉莲」),原先靠 containsHan 判中文会把日本动画误判成国漫。新增 isChineseAnime:仅在有 origin_country/ 语言元数据,或无元数据但有显式中文标记(国漫/国产/国创/华语)时才判国漫, 否则默认日番。有元数据时只认元数据,不受错误源目录名(如「国产剧」)误导。 未刮削的国漫刮出 origin_country=CN 后仍正确归类。补 4 个分类器测试用例。
This commit is contained in:
@@ -40,6 +40,10 @@ func classifyMediaCategory(input mediaClassifyInput, categories map[string]strin
|
||||
isChineseByMetadata := hasAny(languages, "ZH", "ZH-CN", "ZH-TW", "CN", "BO", "ZA") || hasAny(countries, "CN", "TW", "HK", "MO")
|
||||
isChineseByText := containsHan(rawText) || containsAnyText(text, "华语", "国产", "国剧", "国漫")
|
||||
isChinese := isChineseByMetadata || (!hasMetadata && isChineseByText)
|
||||
// 动漫的中文译名几乎都是纯汉字(如日本动画「葬送的芙莉莲」),用 containsHan
|
||||
// 判中文会把日本动画误判成国漫。动漫只在有元数据或显式中文标记时才算国漫,
|
||||
// 否则默认日番(日本动画占绝大多数;未刮削的国漫刮出 origin_country=CN 后仍正确)。
|
||||
isChineseAnime := isChineseByMetadata || (!hasMetadata && containsAnyText(text, "华语", "国产", "国漫", "國漫", "国创", "国产动漫", "国产动画"))
|
||||
isJapanese := hasAny(languages, "JA", "JP") || hasAny(countries, "JP") || containsJapaneseKana(rawText) || strings.Contains(text, "日番")
|
||||
isKorean := hasAny(languages, "KO", "KR") || hasAny(countries, "KR", "KP") || containsKoreanHangul(rawText)
|
||||
isEastAsian := isJapanese || isKorean || hasAny(countries, "TH", "IN", "SG")
|
||||
@@ -81,7 +85,7 @@ func classifyMediaCategory(input mediaClassifyInput, categories map[string]strin
|
||||
}
|
||||
return categoryName(categories, "foreign_movie", "外语电影")
|
||||
case "anime":
|
||||
if isChinese {
|
||||
if isChineseAnime {
|
||||
return categoryName(categories, "cn_anime", "国漫")
|
||||
}
|
||||
return categoryName(categories, "jp_anime", "日番")
|
||||
@@ -101,7 +105,7 @@ func classifyMediaCategory(input mediaClassifyInput, categories map[string]strin
|
||||
return categoryName(categories, "children", "儿童")
|
||||
}
|
||||
if hasGenre("16", "ANIMATION", "动画", "动漫") || hasAnimeText {
|
||||
if isChinese {
|
||||
if isChineseAnime {
|
||||
return categoryName(categories, "cn_anime", "国漫")
|
||||
}
|
||||
return categoryName(categories, "jp_anime", "日番")
|
||||
|
||||
@@ -144,6 +144,43 @@ func TestClassifyMediaCategoryMatchesMoviePilotStyleRules(t *testing.T) {
|
||||
},
|
||||
want: "综艺",
|
||||
},
|
||||
{
|
||||
name: "japanese anime localized chinese title defaults to jp without metadata",
|
||||
input: mediaClassifyInput{
|
||||
MediaType: "anime",
|
||||
Title: "葬送的芙莉莲",
|
||||
},
|
||||
want: "日番",
|
||||
},
|
||||
{
|
||||
name: "chinese anime explicit marker without metadata",
|
||||
input: mediaClassifyInput{
|
||||
MediaType: "anime",
|
||||
Title: "斗破苍穹 国漫",
|
||||
},
|
||||
want: "国漫",
|
||||
},
|
||||
{
|
||||
name: "anime with JP country metadata is jp even from wrong source folder",
|
||||
input: mediaClassifyInput{
|
||||
MediaType: "anime",
|
||||
Title: "间谍过家家 SPY×FAMILY",
|
||||
Countries: []string{"JP"},
|
||||
Genres: []string{"16"},
|
||||
Category: "国产剧",
|
||||
},
|
||||
want: "日番",
|
||||
},
|
||||
{
|
||||
name: "anime with CN country metadata is cn",
|
||||
input: mediaClassifyInput{
|
||||
MediaType: "anime",
|
||||
Title: "某番",
|
||||
Countries: []string{"CN"},
|
||||
Genres: []string{"16"},
|
||||
},
|
||||
want: "国漫",
|
||||
},
|
||||
{
|
||||
name: "jav code is adult",
|
||||
input: mediaClassifyInput{
|
||||
|
||||
Reference in New Issue
Block a user