Skip to content

Commit

Permalink
Process potential children of literary collections later
Browse files Browse the repository at this point in the history
I've had some nondeterministic behavior with
https://www.wikidata.org/wiki/Q7755407 which is a child of both
https://www.wikidata.org/wiki/Q3399570 and
https://www.wikidata.org/wiki/Q3232655 and I think this will make it
deterministic.
  • Loading branch information
dseomn committed Jun 23, 2024
1 parent 8e6486d commit 9729f8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rock_paper_sand/wikidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ class _RelatedMediaPriority(enum.IntEnum):
UNLIKELY: Unlikely to be processed. E.g., TV episodes are likely to be
integral children of TV shows, so they're unlikely to be processed
any further.
POSSIBLE: Might or might not be processed. E.g., short stories are
sometimes integral children of books that have multiple related
short stories.
LIKELY: Likely to be processed, because none of the above applies.
"""

UNLIKELY = enum.auto()
POSSIBLE = enum.auto()
LIKELY = enum.auto()


Expand Down Expand Up @@ -651,6 +655,15 @@ def _priority_by_classes(
),
},
),
(
_RelatedMediaPriority.POSSIBLE,
{
*self._api.transitive_subclasses(wikidata_value.Q_NOVELLA),
*self._api.transitive_subclasses(
wikidata_value.Q_SHORT_STORY
),
},
),
)

def _is_ignored(
Expand Down Expand Up @@ -863,6 +876,7 @@ def _related_media(
_RelatedMediaPriority, set[wikidata_value.ItemRef]
] = {
_RelatedMediaPriority.UNLIKELY: set(),
_RelatedMediaPriority.POSSIBLE: set(),
_RelatedMediaPriority.LIKELY: {request.item.wikidata_item},
}
processed: set[wikidata_value.ItemRef] = set()
Expand Down
2 changes: 2 additions & 0 deletions rock_paper_sand/wikidata_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def human_readable_url_prefix(cls) -> str:
Q_LIST = _i("https://www.wikidata.org/wiki/Q12139612")
Q_LITERARY_WORK = _i("https://www.wikidata.org/wiki/Q7725634")
Q_MUSICAL_WORK = _i("https://www.wikidata.org/wiki/Q2188189")
Q_NOVELLA = _i("https://www.wikidata.org/wiki/Q149537")
Q_OMNIVERSE = _i("https://www.wikidata.org/wiki/Q116503898")
Q_PARATEXT = _i("https://www.wikidata.org/wiki/Q853520")
Q_PART_OF_TELEVISION_SEASON = _i("https://www.wikidata.org/wiki/Q93992677")
Expand All @@ -156,6 +157,7 @@ def human_readable_url_prefix(cls) -> str:
Q_SEGMENT_OF_A_TELEVISION_EPISODE = _i(
"https://www.wikidata.org/wiki/Q29555881"
)
Q_SHORT_STORY = _i("https://www.wikidata.org/wiki/Q49084")
Q_TELEVISION_FILM = _i("https://www.wikidata.org/wiki/Q506240")
Q_TELEVISION_PILOT = _i("https://www.wikidata.org/wiki/Q653916")
Q_TELEVISION_SERIES = _i("https://www.wikidata.org/wiki/Q5398426")
Expand Down

0 comments on commit 9729f8d

Please sign in to comment.