fix:
1. 修复安卓部分机型顶部安全区遮挡回忆录标题的问题; 2. 降低封面图生成阈值和展示逻辑,独立封面图未生成时,使用正文图; 3. 去掉“嗯。”生硬回答,去掉不合理段首承接词; 4. 新增章节封面所需最少插图数的配置项
This commit is contained in:
@@ -62,6 +62,19 @@ def strip_parenthetical_asides_for_chat(text: str) -> str:
|
||||
return s.strip()
|
||||
|
||||
|
||||
def strip_leading_en_period_ack_for_chat(text: str) -> str:
|
||||
"""
|
||||
去掉段首生硬的「嗯。」(可重复),即使后面还有正文;只剥字符串开头,不误伤句中「嗯。」。
|
||||
支持全角/半角句号。
|
||||
"""
|
||||
s = (text or "").strip()
|
||||
if not s:
|
||||
return s
|
||||
# 允许多次「嗯。」/「嗯嗯。」叠在段首;句号仅匹配全角 。、. 与 ASCII `.`
|
||||
s2 = re.sub(r"^(?:嗯+(?:。|.|\.)+\s*)+", "", s)
|
||||
return s2.strip()
|
||||
|
||||
|
||||
def segments_from_llm_response(
|
||||
response_text: str,
|
||||
*,
|
||||
@@ -76,13 +89,22 @@ def segments_from_llm_response(
|
||||
text = strip_parenthetical_asides_for_chat(text)
|
||||
if not text:
|
||||
return []
|
||||
primary = [p.strip() for p in text.split("[SPLIT]") if p.strip()]
|
||||
primary = [
|
||||
strip_leading_en_period_ack_for_chat(p)
|
||||
for p in text.split("[SPLIT]")
|
||||
if strip_leading_en_period_ack_for_chat(p).strip()
|
||||
]
|
||||
if len(primary) > 1:
|
||||
return primary[:max_segments]
|
||||
blob = primary[0] if primary else text
|
||||
blob = primary[0] if primary else strip_leading_en_period_ack_for_chat(text)
|
||||
blob = strip_leading_en_period_ack_for_chat(blob)
|
||||
if "\n" not in blob:
|
||||
return [blob]
|
||||
paras = [p.strip() for p in re.split(r"\n\s*\n+", blob) if p.strip()]
|
||||
paras = [
|
||||
strip_leading_en_period_ack_for_chat(p)
|
||||
for p in re.split(r"\n\s*\n+", blob)
|
||||
if strip_leading_en_period_ack_for_chat(p).strip()
|
||||
]
|
||||
if len(paras) < 2:
|
||||
return [blob]
|
||||
paras = [p for p in paras if len(p) >= min_paragraph_chars]
|
||||
|
||||
Reference in New Issue
Block a user