Spaces:
Running
Running
Reader: commentaries by their own numbering
Browse files
app.py
CHANGED
|
@@ -210,6 +210,13 @@ def load():
|
|
| 210 |
if j != i:
|
| 211 |
twin[i], twin[j] = j, i
|
| 212 |
X["twin"] = twin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
S["twins"] = len(twin) // 2
|
| 214 |
del first
|
| 215 |
src = np.repeat(np.arange(len(refseg), dtype=np.uint32), np.diff(lidx).astype(np.int64))
|
|
@@ -518,14 +525,28 @@ def passage(seg: int):
|
|
| 518 |
lo, hi = max(a, seg - 4), min(b, seg + 5)
|
| 519 |
ctx = sorted(range(lo, hi), key=lambda s: [int(p) if p.isdigit() else 0 for p in X["sec"][s].split(".") if p])
|
| 520 |
links, comments, similar = [], [], []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 521 |
linked = X["ldst"][X["lptr"][seg]:X["lptr"][seg + 1]].astype(np.int64)
|
| 522 |
tw = X["twin"].get(seg)
|
| 523 |
if tw is not None:
|
| 524 |
linked = np.unique(np.concatenate([linked, X["ldst"][X["lptr"][tw]:X["lptr"][tw + 1]].astype(np.int64)]))
|
| 525 |
# commentaries on this passage, then everything else it links to, primary sources first
|
| 526 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
title = X["title"][t]
|
| 528 |
-
if " on " in title
|
| 529 |
if len(comments) < 120:
|
| 530 |
it = item(t, "link", cap=400)
|
| 531 |
it["by"] = title.split(" on ")[0]
|
|
|
|
| 210 |
if j != i:
|
| 211 |
twin[i], twin[j] = j, i
|
| 212 |
X["twin"] = twin
|
| 213 |
+
# "Rashi on Chullin" comments on "Chullin": base title -> commentary works
|
| 214 |
+
on = defaultdict(list)
|
| 215 |
+
for a, b in zip(X["wstart"][:-1].tolist(), X["wstart"][1:].tolist()):
|
| 216 |
+
t = X["title"][a]
|
| 217 |
+
if " on " in t:
|
| 218 |
+
on[t.split(" on ", 1)[1]].append((a, b))
|
| 219 |
+
X["on"] = dict(on)
|
| 220 |
S["twins"] = len(twin) // 2
|
| 221 |
del first
|
| 222 |
src = np.repeat(np.arange(len(refseg), dtype=np.uint32), np.diff(lidx).astype(np.int64))
|
|
|
|
| 525 |
lo, hi = max(a, seg - 4), min(b, seg + 5)
|
| 526 |
ctx = sorted(range(lo, hi), key=lambda s: [int(p) if p.isdigit() else 0 for p in X["sec"][s].split(".") if p])
|
| 527 |
links, comments, similar = [], [], []
|
| 528 |
+
# commentaries laid out on this passage's own numbering
|
| 529 |
+
title, sec = X["title"][seg], X["sec"][seg]
|
| 530 |
+
pre = sec.rstrip(".") + "."
|
| 531 |
+
amud = sec.split(".")[0] + "."
|
| 532 |
+
structural = []
|
| 533 |
+
for a, b in X["on"].get(title, []):
|
| 534 |
+
exact = [t for t in range(a, b) if X["sec"][t].startswith(pre)]
|
| 535 |
+
if not exact and talmudic(title):
|
| 536 |
+
exact = [t for t in range(a, b) if X["sec"][t].startswith(amud)][:6]
|
| 537 |
+
structural += sorted(exact, key=lambda t: [int(p) if p.isdigit() else 0 for p in X["sec"][t].split(".") if p])[:12]
|
| 538 |
linked = X["ldst"][X["lptr"][seg]:X["lptr"][seg + 1]].astype(np.int64)
|
| 539 |
tw = X["twin"].get(seg)
|
| 540 |
if tw is not None:
|
| 541 |
linked = np.unique(np.concatenate([linked, X["ldst"][X["lptr"][tw]:X["lptr"][tw + 1]].astype(np.int64)]))
|
| 542 |
# commentaries on this passage, then everything else it links to, primary sources first
|
| 543 |
+
done = set()
|
| 544 |
+
for t in structural + sorted(linked.tolist(), key=lambda t: (not (X["cls"][t] & 0x10), int(X["cls"][t]) & 0x0F, t))[:400]:
|
| 545 |
+
if t in done:
|
| 546 |
+
continue
|
| 547 |
+
done.add(t)
|
| 548 |
title = X["title"][t]
|
| 549 |
+
if " on " in title:
|
| 550 |
if len(comments) < 120:
|
| 551 |
it = item(t, "link", cap=400)
|
| 552 |
it["by"] = title.split(" on ")[0]
|