manuscript: green only for runs of three or more of Baum's words
This commit is contained in:
parent
cb0f3a6b1f
commit
fbddfea702
1 changed files with 8 additions and 0 deletions
|
|
@ -211,6 +211,14 @@
|
||||||
if (A[i] === B[j]) { mask[bw[j]] = true; i++; j++; }
|
if (A[i] === B[j]) { mask[bw[j]] = true; i++; j++; }
|
||||||
else if (L[i + 1][j] >= L[i][j + 1]) i++; else j++;
|
else if (L[i + 1][j] >= L[i][j + 1]) i++; else j++;
|
||||||
}
|
}
|
||||||
|
// a lone "the" that happens to match is not Baum's sentence: only runs of
|
||||||
|
// three or more matching words count as his
|
||||||
|
var run = [];
|
||||||
|
for (var q = 0; q <= bw.length; q++) {
|
||||||
|
if (q < bw.length && mask[bw[q]]) { run.push(bw[q]); continue; }
|
||||||
|
if (run.length && run.length < 3) run.forEach(function (idx) { mask[idx] = false; });
|
||||||
|
run = [];
|
||||||
|
}
|
||||||
for (var k = 0; k < b.length; k++) if (/^\s+$/.test(b[k])) mask[k] = (k > 0 && mask[k - 1]) && (k + 1 < b.length && mask[k + 1]);
|
for (var k = 0; k < b.length; k++) if (/^\s+$/.test(b[k])) mask[k] = (k > 0 && mask[k - 1]) && (k + 1 < b.length && mask[k + 1]);
|
||||||
return { parts: b, mask: mask };
|
return { parts: b, mask: mask };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue