55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
import { textMatchesProgram } from "./identity.js";
|
|
|
|
export function assessCredibility(result, programName, candidate = null) {
|
|
if (!result || result.status !== "ok") {
|
|
return {
|
|
level: result?.status === "no_match" ? "rejected" : "",
|
|
label: result?.status === "no_match" ? "拒绝" : "",
|
|
reason: result?.status === "no_match" ? "页面标题和证据不足以确认属于当前节目" : "",
|
|
};
|
|
}
|
|
|
|
const titleMatch = textMatchesProgram(result.page_title, programName);
|
|
const evidenceMatch = textMatchesProgram(result.evidence, programName);
|
|
const candidateMatch = textMatchesProgram(candidate?.pageTitle, programName)
|
|
|| textMatchesProgram(candidate?.evidence, programName);
|
|
|
|
if (titleMatch && evidenceMatch) {
|
|
return {
|
|
level: "high",
|
|
label: "高可信",
|
|
reason: "页面标题和提取证据均匹配当前节目",
|
|
};
|
|
}
|
|
|
|
if (evidenceMatch) {
|
|
return {
|
|
level: "medium",
|
|
label: "中可信",
|
|
reason: "提取证据匹配当前节目,页面标题可能是合集或同系列入口",
|
|
};
|
|
}
|
|
|
|
if (titleMatch) {
|
|
return {
|
|
level: "medium",
|
|
label: "中可信",
|
|
reason: "页面标题匹配当前节目,但提取证据未包含节目名",
|
|
};
|
|
}
|
|
|
|
if (candidateMatch) {
|
|
return {
|
|
level: "low",
|
|
label: "低可信",
|
|
reason: "仅搜索候选匹配当前节目,页面证据不足",
|
|
};
|
|
}
|
|
|
|
return {
|
|
level: "rejected",
|
|
label: "拒绝",
|
|
reason: "页面标题和证据均未匹配当前节目",
|
|
};
|
|
}
|