Skip to content

Commit

Permalink
Correct some faulty logic around derivative synsets
Browse files Browse the repository at this point in the history
  • Loading branch information
cgokmen committed Dec 12, 2024
1 parent edc3178 commit 0cf0adc
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions bddl/knowledge_base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ def derivative_parent(self):
parent_should_be_substance = self.name.startswith("cooked__")
parent_should_have_properties = set()

if self.name.startswith("diced__") or self.name.startswith("half__"):
if self.name.startswith("diced__"):
parent_should_have_properties.add("diceable")
elif self.name.startswith("half__"):
parent_should_have_properties.add("sliceable")
elif self.name.startswith("cooked__"):
parent_should_have_properties.add("cookable")
Expand Down Expand Up @@ -533,21 +535,26 @@ def view_bad_derivative(cls):
@classmethod
def view_missing_derivative(cls):
"""Synsets that are missing a derivative synset that is expected to exist from property annotations"""
# TODO: reimplement using new derivative fields
sliceables = [
s
for s in cls.all_objects()
if "sliceable" in s.property_names and s.state != STATE_SUBSTANCE
if "sliceable" in s.property_names
]
missing_half = [
s
for s in sliceables
if not cls.get("half__" + s.name.split(".n.")[0] + ".n.01")
if not any(c.name.startswith("half__") for c in s.derivative_children)
]

diceables = [
s
for s in cls.all_objects()
if "diceable" in s.property_names
]
missing_diced = [
s
for s in sliceables
if not cls.get("diced__" + s.name.split(".n.")[0] + ".n.01")
for s in diceables
if not any(c.name.startswith("diced__") for c in s.derivative_children)
]

cookable_substances = [
Expand All @@ -556,7 +563,9 @@ def view_missing_derivative(cls):
if "cookable" in s.property_names and s.state == STATE_SUBSTANCE
]
missing_cooked = [
s for s in cookable_substances if not cls.get("cooked__" + s.name)
s
for s in cookable_substances
if not any(c.name.startswith("cooked__") for c in s.derivative_children)
]

return sorted(missing_half + missing_diced + missing_cooked)
Expand Down

0 comments on commit 0cf0adc

Please sign in to comment.