NAP2027 0.1.1: labotas uzdevumu [315]–[318] ailes; pašreizējā institūcija (KEM)
Uzdevumu teksta pirmie vārdi 68. lpp. bija nonākuši ailē „Nr.”; pārbaudei pievienota apgrieztā vārdu pārbaude. Atribūts currentOrg/currentSince: septiņiem VARAM vides un klimata uzdevumiem — KEM 20-0000. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016679RwmHsuTFfxt26wP6rk
This commit is contained in:
@@ -37,9 +37,9 @@ def load_vocab(pdf_path):
|
||||
|
||||
|
||||
def _better(whole, *parts):
|
||||
"""Join when the whole word is attested more often than any of its fragments."""
|
||||
"""Join when the whole word is attested more often than any of its fragments, or once while a fragment never is."""
|
||||
n = VOCAB.get(whole, 0) + VOCAB.get(whole.lower(), 0)
|
||||
return n >= 2 and any(VOCAB.get(p, 0) < n for p in parts)
|
||||
return (n >= 2 and any(VOCAB.get(p, 0) < n for p in parts)) or (n >= 1 and any(VOCAB.get(p, 0) == 0 for p in parts))
|
||||
|
||||
|
||||
def repair(s):
|
||||
@@ -50,7 +50,7 @@ def repair(s):
|
||||
if out:
|
||||
a, core = out[-1], t.rstrip(".,;:)”")
|
||||
ca = a.lstrip("“(")
|
||||
if "/" in a or "http" in a or "www." in a:
|
||||
if "http" in a or "www." in a or ("/" in a and re.search(r"[_.%=?&]|/.*/|-$", a)):
|
||||
out.append(t)
|
||||
continue
|
||||
# three fragments "fundamentāl a s"
|
||||
@@ -101,7 +101,7 @@ def page_lines(pdf):
|
||||
# footnotes: small text at the bottom of the page
|
||||
marks = [w["top"] for w in ws if w["size"] < 6.5 and w["text"].isdigit() and w["x0"] < 90 and w["top"] > 550]
|
||||
fz = min(marks) - 1.5 if marks else 9999
|
||||
infoot = lambda w: w["size"] < 9.5 and w["top"] >= fz
|
||||
infoot = lambda w: w["size"] < 10.5 and w["top"] >= fz
|
||||
foot = [w for w in ws if infoot(w)]
|
||||
body = [w for w in ws if not infoot(w) and w["size"] >= 7.5]
|
||||
smalls = [w for w in ws if not infoot(w) and w["size"] < 7.5]
|
||||
@@ -242,6 +242,7 @@ def assign(words, centers, names, bounds=None):
|
||||
for w in words:
|
||||
cx = (w["x0"] + w["x1"]) / 2
|
||||
i = sum(1 for b in bounds if cx > b)
|
||||
i = max(i, 1) # the row marker is not among the words: nothing belongs to the "Nr." column
|
||||
cells[names[i]].append(w)
|
||||
return cells
|
||||
|
||||
|
||||
Reference in New Issue
Block a user