From ebefb2875f58eb79ca1ac8bc215a88047924a637 Mon Sep 17 00:00:00 2001 From: youpaishidifu <1@ypshidifu.cn> Date: Sun, 22 Nov 2026 16:26:46 +0800 Subject: [PATCH] =?UTF-8?q?125=E7=BB=AD15l-7m:=20=E6=88=90=E4=B9=A6limit?= =?UTF-8?q?=20120=E2=86=92100+findSemanticCut=E5=AE=B9=E5=B7=AE+20?= =?UTF-8?q?=E2=86=92+10(=E6=9C=80=E5=A4=A7=E5=88=87=E7=82=B9110=E5=AD=97,?= =?UTF-8?q?=E6=A0=B9=E6=B2=BB140=E8=B6=85UI=E4=B8=80=E5=B1=8F~130=E8=A7=86?= =?UTF-8?q?=E5=8F=A3=E4=BB=8D=E5=8A=88'=E4=BD=BF=E7=94=A8/=E6=B3=95');Pyth?= =?UTF-8?q?on=E5=A4=8D=E5=88=BBplayer.md=E9=AA=8C=E8=AF=81=E6=AF=8F?= =?UTF-8?q?=E9=A1=B523~110=E5=AD=97=E6=97=A0=E8=B6=85130?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/Sdf1_login/CustomScreenManager.java | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/main/java/Sdf1_login/CustomScreenManager.java b/src/main/java/Sdf1_login/CustomScreenManager.java index b7c7ed1..8da1f04 100644 --- a/src/main/java/Sdf1_login/CustomScreenManager.java +++ b/src/main/java/Sdf1_login/CustomScreenManager.java @@ -382,15 +382,15 @@ public class CustomScreenManager implements Listener { java.util.List pages = new java.util.ArrayList<>(); - // ★ 15l-7j 封页补肉:正文前 ~120 字进封页,但必须在语义边界(。!?;\n)处切, + // ★ 15l-7j 封页补肉:正文前 ~100 字进封页,但必须在语义边界(。!?;\n)处切, // 残句续下一页(与正文分页同一套 findSemanticCut 切法)。 - // ★ 15l-7l 修复:limit 150→120(15l-7k 错改 400 被 15l-17 修回 150,但截图实证 - // 150 仍偏大——第2页「使用」被劈、第3页「法」被劈,UI 一屏竖排实际容 ~130 字)。 - // 120 字 + 语义切点(。!?;)+ 残句续下一页,每页保守不劈字。 + // ★ 15l-7m 修复:limit 120→100(容差收紧 +10 后最大切点 110 字,安全落 MC + // 成书 UI 一屏竖排视口 ~130 字内)。旧 120+容差20=140 仍劈「使用/法」。 + // 100 字 + 语义切点(。!?;)+ 残句续下一页,每页保守不劈字。 // ★ 15l-7k 的「投票规则详见第六章第3节;」分号容差需求,靠 findSemanticCut 的 - // 容差 limit+20=140 仍能满足(分号若落在 120~140 之间仍纳入切点)。 + // 容差 limit+10=110 仍能满足(分号若落在 100~110 之间仍纳入切点)。 if (!body.isEmpty()) { - int cut = findSemanticCut(body, 120); + int cut = findSemanticCut(body, 100); pages.add(body.substring(0, cut)); body = body.substring(cut); } @@ -407,10 +407,10 @@ public class CustomScreenManager implements Listener { // 当前页为空:直接开始新段落 if (page.length() == 0) { - if (p.length() > 120) { + if (p.length() > 100) { java.util.List sentences = splitSentences(p); for (String s : sentences) { - if (page.length() + s.length() + 1 > 120 && page.length() > 0) { + if (page.length() + s.length() + 1 > 100 && page.length() > 0) { pages.add(page.toString().trim()); page = new StringBuilder(); } @@ -423,14 +423,14 @@ public class CustomScreenManager implements Listener { } // 当前页已有内容:判断段落是否能整段放入 - if (page.length() + p.length() + 1 <= 120) { + if (page.length() + p.length() + 1 <= 100) { page.append("\n").append(p); continue; } // 整段放不进:在「当前页 + 段落」里找语义边界截断 String candidate = page.toString() + "\n" + p; - int cut = findSemanticCut(candidate, 120); + int cut = findSemanticCut(candidate, 100); // ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段 String firstHalf = candidate.substring(0, cut); String secondHalf = candidate.substring(cut); @@ -441,8 +441,8 @@ public class CustomScreenManager implements Listener { page = new StringBuilder(secondHalf); // 若剩余段仍超页,继续按语义截断或按句拆 - while (page.length() > 120) { - int nextCut = findSemanticCut(page.toString(), 120); + while (page.length() > 100) { + int nextCut = findSemanticCut(page.toString(), 100); String chunk = page.substring(0, nextCut); String remain = page.substring(nextCut); while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1); @@ -463,7 +463,7 @@ public class CustomScreenManager implements Listener { if (pages.size() > 2) { String last = pages.get(pages.size() - 1); String prev = pages.get(pages.size() - 2); - if (last.length() < 20 && (prev.length() + last.length() + 1) <= 120) { + if (last.length() < 20 && (prev.length() + last.length() + 1) <= 100) { pages.set(pages.size() - 2, prev + "\n" + last); pages.remove(pages.size() - 1); } @@ -539,15 +539,14 @@ public class CustomScreenManager implements Listener { * 在 limit 以内找最佳语义截断点(。!?;、行首)。 * ★ 15l-7i 修复:从后往前扫时只接受 i < limit 的句末标点(避免 best 落在 limit 之后 * 导致切点越界、丢内容)。扫不到则退化按逗号/空格,再退化硬切 limit。 - * ★ 15l-7l:句末搜索容差放宽到 limit+20——MC 成书 UI 每屏竖排实际容 ~155 字, - * 15l-17 把 limit 改成 150,容差 limit+20=170 仍能在「最近句末落在 150~170 之间」时 - * 纳入切点(15l-7k 的「投票规则详见第六章第3节;」分号容差需求仍满足)。 - * 超 limit+20 仍硬切 limit。 + * ★ 15l-7m:容差收紧 limit+20→limit+10——旧 +20 把切点推到 140 字(120+20), + * 超 MC 成书 UI 一屏竖排实际视口 ~130 字,仍劈「使用/法」。+10 时 100+10=110, + * 安全落视口内。超 limit+10 仍硬切 limit。 */ private int findSemanticCut(String s, int limit) { if (s.length() <= limit) return s.length(); int best = -1; - int searchEnd = Math.min(s.length() - 1, limit + 20); // ★ 15l-7k 容差 +20(15l-7l 沿用) + int searchEnd = Math.min(s.length() - 1, limit + 10); // ★ 15l-7m 容差收紧 +20→+10 for (int i = searchEnd; i >= 0; i--) { char c = s.charAt(i); if (c == '。' || c == '!' || c == '?' || c == ';' || c == '\n') { @@ -555,7 +554,7 @@ public class CustomScreenManager implements Listener { break; } } - if (best <= 0 || best > limit + 20) { + if (best <= 0 || best > limit + 10) { // 退化:limit 以内找逗号/空格 for (int i = Math.min(s.length() - 1, limit - 1); i >= 0; i--) { char c = s.charAt(i); @@ -565,7 +564,7 @@ public class CustomScreenManager implements Listener { } } } - if (best <= 0 || best > limit + 20) best = limit; + if (best <= 0 || best > limit + 10) best = limit; return best; }