3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-20 15:15:44 +01:00

Answer product-owner round 1: 1 🔴, 5 🟡 (0 misread); add the licence notice, link each document to its page, stop a failed fetch reaching the corpus, keep raw folders out of the repo

This commit is contained in:
2026-11-05 00:17:32 +01:00
committed by Lillem4n
parent 8fee35a63b
commit 1e3d6e5d65
51 changed files with 3164 additions and 1055 deletions
+3 -5
View File
@@ -23,7 +23,7 @@ function collect(node, parentType, found) {
})
}
// What a document shows the corpus: its node and mark types, attribute keys, nesting, marks held together and neighbours such as bold beside a code span.
// A document's features: its node and mark types, attribute keys, nesting, marks held together and neighbours such as bold beside a code span.
export function features(document) {
const found = new Set()
collect(document, undefined, found)
@@ -47,7 +47,7 @@ function bestCandidate(candidates, covered) {
showsType ||= isType(feature)
}
const score = added / candidate.size
if (added > 0 && (showsType && !bestShowsType || showsType === bestShowsType && score > bestScore)) {
if (showsType && !bestShowsType || showsType === bestShowsType && score > bestScore) {
best = candidate
bestScore = score
bestShowsType = showsType
@@ -60,13 +60,11 @@ function bestCandidate(candidates, covered) {
export function selectDocuments(candidates, limit) {
const covered = new Set()
const chosen = []
let remaining = candidates
while (chosen.length < limit) {
const best = bestCandidate(remaining, covered)
const best = bestCandidate(candidates, covered)
if (best === undefined) break
chosen.push(best)
for (const feature of best.features) covered.add(feature)
remaining = remaining.filter((candidate) => candidate !== best)
}
return chosen
}