pybot-msgboard / assets /storage /1011 /task /gate-proto1.patch
lvwerra's picture
lvwerra HF Staff
Sanitized PyBot message board archive
c1e4f50
Raw History Blame Contribute Delete
1.87 kB
--- a/bot/knowledge/lookup.py
+++ b/bot/knowledge/lookup.py
@@ -4623,6 +4623,13 @@
# The answer is the composer's loss pool, and it is the same for every thing.
return None
found = _the_best_entry(understood, entries, reject, use_context)
+ if found is not None and _out_of_the_frame(understood, found):
+ # PROTOTYPE (cleopatra): a follow-up that names no topic of its own is about the
+ # conversation's subject, so a card from a domain the conversation never touched is
+ # passed over in favour of the best card inside it (or nothing).
+ def _frame_reject(item, _r=reject, _u=understood):
+ return (_r is not None and _r(item)) or not _in_topic(item, _u)
+ found = _the_best_entry(understood, entries, _frame_reject, use_context)
if found is not None and _a_price_judged_is_not_answered_here(understood, found):
# The line brings a figure in money and asks whether it is dear, and this card answers
# the thing itself: what a chicken takes in the oven, what milk does for you, what the
@@ -6937,6 +6944,19 @@
return allowed if allowed else None
+def _out_of_the_frame(understood, item):
+ """PROTOTYPE: True when the line is a follow-up with no topic of its own and the card it
+ reached on its own words sits outside every domain the conversation is about."""
+ if not isinstance(understood, dict) or not understood.get("followup"):
+ return False
+ if understood.get("topic_own"):
+ return False
+ leans = understood.get("leans_on")
+ if not isinstance(leans, dict) or not leans.get("topic"):
+ return False
+ return not _in_topic(item, understood)
+
+
def _in_topic(item, understood):
"""Whether `item`'s own domain is one that answers lines about a topic of the line."""
allowed = _topic_domains(understood)