修改杂项
1
This commit is contained in:
@@ -53,7 +53,7 @@ class PromptBuilder:
|
||||
bot_schedule_now_time,bot_schedule_now_activity = bot_schedule.get_current_task()
|
||||
prompt_date = f'''今天是{current_date},现在是{current_time},你今天的日程是:\n{bot_schedule.today_schedule}\n你现在正在{bot_schedule_now_activity}\n'''
|
||||
|
||||
#知识构建
|
||||
#知识构建(暂时禁用,因为知识库太少了)
|
||||
prompt_info = ''
|
||||
promt_info_prompt = ''
|
||||
prompt_info = self.get_prompt_info(message_txt)
|
||||
@@ -98,7 +98,7 @@ class PromptBuilder:
|
||||
现在请你给出日常且口语化的回复,请表现你自己的见解,不要一昧迎合,尽量简短一些。{is_bot_prompt}
|
||||
请你表达自己的见解和观点。可以有个性。'''
|
||||
|
||||
#中文高手
|
||||
#中文高手(新加的好玩功能)
|
||||
prompt_ger = ''
|
||||
if random.random() < 0.04:
|
||||
prompt_ger += '你喜欢用倒装句'
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
import random
|
||||
|
||||
text = "我今天很开心 但是也很伤心 但是也很伤心,"
|
||||
len_text = len(text)
|
||||
print(f"len_text: {len_text}")
|
||||
if len_text < 5:
|
||||
if random.random() < 0.01:
|
||||
print(f"直接按字符分割")
|
||||
else:
|
||||
print(f"直接按字符分割")
|
||||
if len_text < 15:
|
||||
split_strength = 0.3
|
||||
elif len_text < 35:
|
||||
split_strength = 0.7
|
||||
else:
|
||||
split_strength = 0.9
|
||||
#先移除换行符
|
||||
print(f"split_strength: {split_strength}")
|
||||
|
||||
print(f"处理前的文本: {text}")
|
||||
|
||||
# 统一将英文逗号转换为中文逗号
|
||||
text = text.replace(',', ',')
|
||||
text = text.replace('\n', ' ')
|
||||
|
||||
print(f"处理前的文本: {text}")
|
||||
|
||||
text_no_1 = ''
|
||||
for letter in text:
|
||||
print(f"当前字符: {letter}")
|
||||
if letter in ['!','!','?','?']:
|
||||
print(f"当前字符: {letter}, 随机数: {random.random()}")
|
||||
if random.random() < split_strength:
|
||||
letter = ''
|
||||
if letter in ['。','…']:
|
||||
print(f"当前字符: {letter}, 随机数: {random.random()}")
|
||||
if random.random() < 1 - split_strength:
|
||||
letter = ''
|
||||
text_no_1 += letter
|
||||
|
||||
# 对每个逗号和空格单独判断是否分割
|
||||
sentences = [text_no_1]
|
||||
new_sentences = []
|
||||
for sentence in sentences:
|
||||
parts = sentence.split(',')
|
||||
current_sentence = parts[0]
|
||||
for part in parts[1:]:
|
||||
if random.random() < split_strength:
|
||||
new_sentences.append(current_sentence.strip())
|
||||
current_sentence = part
|
||||
else:
|
||||
current_sentence += ',' + part
|
||||
# 处理空格分割
|
||||
space_parts = current_sentence.split(' ')
|
||||
current_sentence = space_parts[0]
|
||||
for part in space_parts[1:]:
|
||||
if random.random() < split_strength:
|
||||
new_sentences.append(current_sentence.strip())
|
||||
current_sentence = part
|
||||
else:
|
||||
current_sentence += ' ' + part
|
||||
new_sentences.append(current_sentence.strip())
|
||||
sentences = [s for s in new_sentences if s] # 移除空字符串
|
||||
|
||||
print(f"分割后的句子: {sentences}")
|
||||
sentences_done = []
|
||||
for sentence in sentences:
|
||||
sentence = sentence.rstrip(',,')
|
||||
if random.random() < split_strength*0.5:
|
||||
sentence = sentence.replace(',', '').replace(',', '')
|
||||
elif random.random() < split_strength:
|
||||
sentence = sentence.replace(',', ' ').replace(',', ' ')
|
||||
sentences_done.append(sentence)
|
||||
|
||||
print(f"处理后的句子: {sentences_done}")
|
||||
Reference in New Issue
Block a user