Commit 1f769e0a authored by 周成波's avatar 周成波

加一段逻辑,本镜角色有且只能有一个,且尽量不与之前相同

parent 3c4b5be9
......@@ -348,17 +348,49 @@ const onAdaptOneSceneRoles = async (item: any) => {
// console.log(adapt_role_restrict)
// console.log(item_roles)
item.角色 = item_roles.trim();
////// 加一段逻辑,本镜角色有且只能有一个,且尽量不与之前相同。【begin】
const temp_arr = item.角色.split(/[,,、]/);
const temp_arr_length = temp_arr.length;
////// 如果本镜的角色大于1个,则只保留没有出现过的角色,且保证只有一个
if(temp_arr_length > 1) {
////// 获取本镜之前的所有角色
let role_history = "";
form.adapt_result_json.forEach( scene => { if (scene.编号 < item.编号) { role_history += scene.角色 + ","; } })
for (const temp of temp_arr) {
if (role_history.includes(temp)) {
item.角色 = "";
continue;
} else {
item.角色 = temp;
break;
}
}
if (item.角色 == "") {
const role_history_arr = role_history.split(',');
if (role_history_arr.length >= 2) {
item.角色 = role_history_arr[role_history_arr.length - 2];
} else if (role_history_arr.length == 1) {
item.角色 = role_history_arr[role_history_arr.length - 1];
} else {
item.角色 = item_roles.trim();
}
}
}
////// 加一段逻辑,本镜角色有且只能有一个,且尽量不与之前相同。【end】
// 开始匹配角色关键词
let role_kws = ""
let role_kws_en = ""
const item_roles_arr = item_roles.split(/[,,、]/);
item_roles_arr.forEach( one_item_role => {
const item_roles_arr = item.角色.split(/[,,、]/);
item_roles_arr.forEach((one_item_role: string) => {
let temp_role_kws = ""
let temp_role_kws_en = ""
// 人工匹配角色关键词,先找想同的
for (const i of form.chatgpt_answer_roles) {
if (i["角色"].trim() == one_item_role.trim()) {
temp_role_kws = `[${i["角色关键词"]}]`;
temp_role_kws_en = `[${i["角色关键词英文"]}]`;
temp_role_kws = `${i["角色关键词"]}`;
temp_role_kws_en = `${i["角色关键词英文"]}`;
// 找到就ok
break;
}
......@@ -367,8 +399,8 @@ const onAdaptOneSceneRoles = async (item: any) => {
if (! temp_role_kws) {
for (const i of form.chatgpt_answer_roles) {
if (i["角色"].includes(one_item_role.trim()) || one_item_role.includes(i["角色"].trim())) {
temp_role_kws = `[${i["角色关键词"]}]`;
temp_role_kws_en = `[${i["角色关键词英文"]}]`;
temp_role_kws = `${i["角色关键词"]}`;
temp_role_kws_en = `${i["角色关键词英文"]}`;
// 匹配到一个就ok
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment