Gate blank-typed link inference with a structural-home check - #79
Merged
Conversation
Blank 'Conection Type' links between a base text and its commentary were promoted to COMMENTARY whenever a base->dependant relationship existed. That mislabeled lateral cross-references (e.g. Magen Avraham 302:6 -> Shulchan Arukh 323:6, which only cites siman 323) as commentary, so they surfaced as spurious segments in the reader's מפרשים panel. Keep the oriented promotion only when the dependant segment's top-level structural index (siman / perek) matches the base it points at; otherwise classify the link as REFERENCE. Explicitly-typed commentary links never hit this path and are unaffected, and blank-but-home commentaries (e.g. Abarbanel -> the verse it expounds) stay COMMENTARY.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the reader's commentator (מפרשים) panel, opening a commentary on a verse showed extra, unrelated segments. Example: Shulchan Arukh OC 323:6 → Magen Avraham listed 5 comments, but only ס"ק ח/ט (323:8, 323:9) actually comment on that se'if — the others (302:6, 321:7, 331:5) are in different simanim.
Root cause
Genuine commentary links are explicitly typed
commentaryin Sefaria; lateral cross-references have a blankConection Type. The generator's blank-type inference (inferConnectionTypeFromSchema) promoted any blank-typed link toCOMMENTARYwhenever a base→dependant relationship existed, so cross-references (a commentary citing another siman) were mislabeled as commentary.Fix
inferBlankConnectionTypewraps the schema inference with a structural-home gate: keep the oriented promotion only when the dependant segment's top-level structural index (siman / perek) matches the base it points at; otherwise classify asREFERENCE. Daf-style / whole-book refs are left untouched (never demoted).COMMENTARY.Validation
Regenerated the DB seeded from the v1 build state:
SefariaLinksImporterTest.