Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
text2video-frontend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周成波
text2video-frontend
Commits
c19e8182
Commit
c19e8182
authored
Mar 02, 2024
by
周成波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
过滤掉中文字符
parent
56fe5ac2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
utils.ts
src/utils/utils.ts
+7
-0
index.vue
src/views/home/index.vue
+2
-2
No files found.
src/utils/utils.ts
View file @
c19e8182
...
@@ -54,4 +54,11 @@ export default class utils {
...
@@ -54,4 +54,11 @@ export default class utils {
return
sentences
return
sentences
}
}
// 过滤掉中文字符
static
filterChineseAndPunctuation
(
inputString
:
string
)
{
return
inputString
.
replace
(
/
[\u
4E00-
\u
9FA5
\u
3000-
\u
303F
\u
ff00-
\u
ffef
]
/g
,
''
)
// 过滤中文字符
.
replace
(
/
[^\w\s]
|_/g
,
''
)
// 过滤标点符号
.
replace
(
/
\s
+/g
,
' '
);
// 连续多个空格替换为一个空格
}
}
}
src/views/home/index.vue
View file @
c19e8182
...
@@ -155,7 +155,7 @@ const onAdaptRolesKeywords = async () => {
...
@@ -155,7 +155,7 @@ const onAdaptRolesKeywords = async () => {
await
delay
(
100
);
await
delay
(
100
);
const
adapt_attribute_restrict_en
=
`你现在扮演专业的英语翻译的角色。请将这段文字“
${
keywords
}
”翻译为英语。\n要求:只返回英语即可,不要返回其他内容。`
;
const
adapt_attribute_restrict_en
=
`你现在扮演专业的英语翻译的角色。请将这段文字“
${
keywords
}
”翻译为英语。\n要求:只返回英语即可,不要返回其他内容。`
;
let
keywords_en
=
await
text2videoService
.
submitLLM
(
adapt_attribute_restrict_en
,
role_keywords_llm
.
api
);
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
;
one_role
.
角色英文关键词
=
keywords_en
;
}
}
}
}
...
@@ -256,7 +256,7 @@ const onAdaptOneScene = async (item: any) => {
...
@@ -256,7 +256,7 @@ const onAdaptOneScene = async (item: any) => {
const
adapt_restrict
=
`你现在扮演专业的英语翻译的角色。请将这段文字“
${
item
.
场景描述
}
”翻译为英语。\n要求:只返回英语即可,不要返回其他内容。`
;
const
adapt_restrict
=
`你现在扮演专业的英语翻译的角色。请将这段文字“
${
item
.
场景描述
}
”翻译为英语。\n要求:只返回英语即可,不要返回其他内容。`
;
const
keywords
=
await
text2videoService
.
submitLLM
(
adapt_restrict
,
tuili_llm
.
api
);
const
keywords
=
await
text2videoService
.
submitLLM
(
adapt_restrict
,
tuili_llm
.
api
);
// console.log(keywords)
// console.log(keywords)
item
.
场景关键词
=
keywords
;
item
.
场景关键词
=
utils
.
filterChineseAndPunctuation
(
keywords
)
;
}
catch
(
error
)
{
}
catch
(
error
)
{
ElMessage
({
ElMessage
({
message
:
String
(
error
),
message
:
String
(
error
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment