(answer: string)
| 44 | |
| 45 | /** Every card id an answer cites, in the order it cites them, without repeats. */ |
| 46 | export function citationsIn(answer: string): string[] { |
| 47 | const found: string[] = []; |
| 48 | const seen = new Set<string>(); |
| 49 | const pattern = /\[([^\]]{1,80})\]/g; |
| 50 | let match = pattern.exec(answer); |
| 51 | while (match !== null) { |
| 52 | for (const id of match[1].matchAll(/\bK(\d+)\b/g)) { |
| 53 | const key = `K${Number(id[1])}`; |
| 54 | if (!seen.has(key)) { |
| 55 | seen.add(key); |
| 56 | found.push(key); |
| 57 | } |
| 58 | } |
| 59 | match = pattern.exec(answer); |
| 60 | } |
| 61 | return found; |
| 62 | } |
| 63 | |
| 64 | /** Whether one line is the agreed no-card sentence in either language. */ |
| 65 | export function isNoCardLine(line: string): boolean { |
no test coverage detected