Skip to content

Commit 8c0c237

Browse files
revise S.splitMergedWord
1 parent c625799 commit 8c0c237

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

scriptum.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9412,28 +9412,33 @@ S.splitName = titles => s => {
94129412
};
94139413

94149414

9415-
S.splitMergedWords = exceptions => s => {
9416-
const xs = s.split(" ").reduce((acc, s2) =>
9417-
A.pushn(s2.split(/(?<=\p{Ll})(?=\p{Lu})/v)) (acc), []);
9415+
S.splitMergedWord = (...exceptions) => s => {
9416+
const xs = s.split(/(?<=\p{Ll})(?=\p{Lu})/v);
94189417

9419-
const ys = [];
9418+
if (xs.length === 1) return s;
94209419

9421-
for (let i = 0; i < xs.length; i++) {
9422-
for (const exception of exceptions) {
9423-
if (R.v(`\\b${R.escape(exception)}$`).test(xs[i])) {
9424-
if (i < xs.length - 1) {
9425-
ys.push(xs[i] + xs[i + 1]);
9426-
i++;
9420+
else if (exceptions.length) {
9421+
const ys = [];
9422+
9423+
for (let i = 0; i < xs.length; i++) {
9424+
for (const exception of exceptions) {
9425+
if (R.v(`\\b${R.escape(exception)}$`).test(xs[i])) {
9426+
if (i < xs.length - 1) {
9427+
ys.push(xs[i] + xs[i + 1]);
9428+
i++;
9429+
}
9430+
9431+
else ys.push(xs[i]);
94279432
}
94289433

94299434
else ys.push(xs[i]);
94309435
}
9431-
9432-
else ys.push(xs[i]);
94339436
}
9437+
9438+
return ys.join(" ");
94349439
}
94359440

9436-
return ys.join(" ");
9441+
else return xs.join(" ");
94379442
};
94389443

94399444

0 commit comments

Comments
 (0)