Commit c19e8182 authored by 周成波's avatar 周成波

过滤掉中文字符

parent 56fe5ac2
......@@ -54,4 +54,11 @@ export default class utils {
return sentences
}
// 过滤掉中文字符
static filterChineseAndPunctuation(inputString: string) {
return inputString.replace(/[\u4E00-\u9FA5\u3000-\u303F\uff00-\uffef]/g, '') // 过滤中文字符
.replace(/[^\w\s]|_/g, '') // 过滤标点符号
.replace(/\s+/g, ' '); // 连续多个空格替换为一个空格
}
}
......@@ -155,7 +155,7 @@ const onAdaptRolesKeywords = async () => {
await delay(100);
const adapt_attribute_restrict_en = `你现在扮演专业的英语翻译的角色。请将这段文字“${keywords}”翻译为英语。\n要求:只返回英语即可,不要返回其他内容。`;
let keywords_en = await text2videoService.submitLLM(adapt_attribute_restrict_en, role_keywords_llm.api);
keywords_en = keywords_en.replace(/"/g, '');
keywords_en = utils.filterChineseAndPunctuation(keywords_en.replace(/"/g, ''));
one_role.角色英文关键词 = keywords_en;
}
}
......@@ -256,7 +256,7 @@ const onAdaptOneScene = async (item: any) => {
const adapt_restrict = `你现在扮演专业的英语翻译的角色。请将这段文字“${item.场景描述}”翻译为英语。\n要求:只返回英语即可,不要返回其他内容。`;
const keywords = await text2videoService.submitLLM(adapt_restrict, tuili_llm.api);
// console.log(keywords)
item.场景关键词 = keywords;
item.场景关键词 = utils.filterChineseAndPunctuation(keywords);
} catch (error) {
ElMessage({
message: String(error),
......
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