* The order of the statements, checked where the facts cannot check it. * * The fact check compares position by position, which catches a model that * moved a name or a number. It cannot catch two sentences that carry no fact * at all being swapped: both sides look identical to it, and the reade
(lines: readonly ReaderLine[], incoming: readonly string[])
| 176 | * sentence's words and almost none of a different sentence's. |
| 177 | */ |
| 178 | function orderRefusal(lines: readonly ReaderLine[], incoming: readonly string[]): string { |
| 179 | const built = lines.map((line) => wordSet(line.text)); |
| 180 | for (let index = 0; index < incoming.length; index += 1) { |
| 181 | const rewritten = wordSet(incoming[index]); |
| 182 | const mine = overlap(rewritten, built[index]); |
| 183 | for (let other = 0; other < built.length; other += 1) { |
| 184 | if (other !== index && overlap(rewritten, built[other]) > mine) { |
| 185 | return `sentence ${index + 1} reads like the built sentence ${other + 1}, ` |
| 186 | + 'so the statements came back in a different order'; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | return ''; |
| 191 | } |
| 192 | |
| 193 | /** Why one line was rejected, or the empty string when it was fine. */ |
| 194 | function lineRefusal(original: ReaderLine, incoming: string, index: number): string { |
no test coverage detected