15m26 成书85→95(治中间页74-84字稀疏, 95字更紧凑不超UI容量)
This commit is contained in:
@@ -395,7 +395,7 @@ public class CustomScreenManager implements Listener {
|
||||
// 正文页仍用 findSemanticCut 语义切(不劈词)。
|
||||
if (!body.isEmpty()) {
|
||||
// 15m18 封页走 findSemanticCut 语义切(启回句末标点切, 不劈词不劈标题)
|
||||
int coverLimit = 85;
|
||||
int coverLimit = 95;
|
||||
int cut = findSemanticCut(body, coverLimit);
|
||||
pages.add(body.substring(0, cut));
|
||||
body = body.substring(cut);
|
||||
@@ -413,19 +413,19 @@ public class CustomScreenManager implements Listener {
|
||||
|
||||
// 当前页为空:直接开始新段落
|
||||
if (page.length() == 0) {
|
||||
if (p.length() > 85) {
|
||||
if (p.length() > 95) {
|
||||
java.util.List<String> sentences = splitSentences(p);
|
||||
for (String s : sentences) {
|
||||
// ★ 15m:单句本身超 85(长句无句末可拆)→ 硬切 85,残句进下一页
|
||||
while (s.length() > 85) {
|
||||
if (page.length() + 85 + 1 > 85 && page.length() > 0) {
|
||||
while (s.length() > 95) {
|
||||
if (page.length() + 95 + 1 > 95 && page.length() > 0) {
|
||||
pages.add(page.toString().trim());
|
||||
page = new StringBuilder();
|
||||
}
|
||||
page.append(s.substring(0, 85));
|
||||
s = s.substring(85);
|
||||
page.append(s.substring(0, 95));
|
||||
s = s.substring(95);
|
||||
}
|
||||
if (page.length() + s.length() + 1 > 85 && page.length() > 0) {
|
||||
if (page.length() + s.length() + 1 > 95 && page.length() > 0) {
|
||||
pages.add(page.toString().trim());
|
||||
page = new StringBuilder();
|
||||
}
|
||||
@@ -438,14 +438,14 @@ public class CustomScreenManager implements Listener {
|
||||
}
|
||||
|
||||
// 当前页已有内容:判断段落是否能整段放入
|
||||
if (page.length() + p.length() + 1 <= 85) {
|
||||
if (page.length() + p.length() + 1 <= 95) {
|
||||
page.append("\n").append(p);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 整段放不进:在「当前页 + 段落」里找语义边界截断
|
||||
String candidate = page.toString() + "\n" + p;
|
||||
int cut = findSemanticCut(candidate, 85);
|
||||
int cut = findSemanticCut(candidate, 95);
|
||||
// ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段
|
||||
String firstHalf = candidate.substring(0, cut);
|
||||
String secondHalf = candidate.substring(cut);
|
||||
@@ -456,8 +456,8 @@ public class CustomScreenManager implements Listener {
|
||||
page = new StringBuilder(secondHalf);
|
||||
|
||||
// 若剩余段仍超页,继续按语义截断或按句拆
|
||||
while (page.length() > 85) {
|
||||
int nextCut = findSemanticCut(page.toString(), 85);
|
||||
while (page.length() > 95) {
|
||||
int nextCut = findSemanticCut(page.toString(), 95);
|
||||
String chunk = page.substring(0, nextCut);
|
||||
String remain = page.substring(nextCut);
|
||||
while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1);
|
||||
@@ -478,7 +478,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) <= 85) {
|
||||
if (last.length() < 20 && (prev.length() + last.length() + 1) <= 95) {
|
||||
pages.set(pages.size() - 2, prev + "\n" + last);
|
||||
pages.remove(pages.size() - 1);
|
||||
}
|
||||
@@ -489,7 +489,7 @@ public class CustomScreenManager implements Listener {
|
||||
String cur = pages.get(pi);
|
||||
String nxt = pages.get(pi + 1);
|
||||
// 15m16 放宽中间孤短页合并: 上限165→175, 阈值50→55(治"残句刚好50字合不了")
|
||||
if (cur.length() < 55 && (cur.length() + nxt.length() + 1) <= 130) {
|
||||
if (cur.length() < 55 && (cur.length() + nxt.length() + 1) <= 145) {
|
||||
pages.set(pi + 1, cur + "\n" + nxt);
|
||||
pages.remove(pi);
|
||||
}
|
||||
@@ -630,7 +630,7 @@ public class CustomScreenManager implements Listener {
|
||||
// 15m23 孤短句末退化: 阈值100→105(<105字句末切点全退化逗号/硬切, 满屏不稀疏)
|
||||
// UI一屏实际容量~90字, 旧100阈值让100-115区间句末切点≥100保留→仍稀疏。
|
||||
// 105=coverLimit, <105全退化, ≥105(105-115)保留语义切。若仍稀疏→纯硬切放弃句末。
|
||||
if (best < 85) best = -1;
|
||||
if (best < 95) best = -1;
|
||||
if (best > 0 && best <= limit + tol) return best;
|
||||
for (int i = Math.min(s.length() - 1, limit - 1); i >= 0; i--) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
Reference in New Issue
Block a user