feat: turn on required da priorities
@@ -260,16 +260,21 @@ def tag_based_response_selection(dialog, candidates, scores, confidences, bot_ut
_is_switch_topic_request = is_switch_topic(annotated_uttr)
_is_force_intent = any([_intent in all_user_intents for _intent in FORCE_INTENTS_IC.keys()])
+ # if user utterance contains any question (REGEXP & punctuation check!)
_is_require_action_intent = is_any_question_sentence_in_utterance(
{"text": annotated_uttr.get("annotations", {}).get("sentseg", {}).get("punct_sent", annotated_uttr["text"])})
- # _is_require_action_intent = any([_intent in all_user_intents for _intent in REQUIRE_ACTION_INTENTS.keys()])
+ # if user utterance contains any question AND requires some intent by socialbot
+ _is_require_action_intent = _is_require_action_intent and any([_intent in all_user_intents
+ for _intent in REQUIRE_ACTION_INTENTS.keys()])
_force_intents_detected = [_intent for _intent in FORCE_INTENTS_IC.keys() if _intent in all_user_intents]
- # _require_action_intents_detected = [_intent for _intent in REQUIRE_ACTION_INTENTS.keys()
- # if _intent in all_user_intents]
+ # list of user intents which require some action by socialbot
+ _require_action_intents_detected = [_intent for _intent in REQUIRE_ACTION_INTENTS.keys()
+ if _intent in all_user_intents]
_force_intents_skills = sum([FORCE_INTENTS_IC.get(_intent, [])
for _intent in _force_intents_detected], [])
- # _required_actions = sum([REQUIRE_ACTION_INTENTS.get(_intent, [])
- # for _intent in _require_action_intents_detected], [])
+ # list of intents required by the socialbot
+ _required_actions = sum([REQUIRE_ACTION_INTENTS.get(_intent, [])
+ for _intent in _require_action_intents_detected], [])
_contains_entities = len(get_entities(annotated_uttr, only_named=False, with_labels=False)) > 0
_is_active_skill_can_not_continue = False
@@ -376,13 +381,12 @@ def tag_based_response_selection(dialog, candidates, scores, confidences, bot_ut
# =====user intent requires particular action=====
CASE = "User intent requires action. USER UTTERANCE CONTAINS QUESTION."
- # _is_grounding_reqda = skill_name == "grounding_skill" and cand_uttr.get(
- # "type", "") == "universal_response"
- _is_active_skill = False # no priority to active skill
+ _is_grounding_reqda = skill_name == "grounding_skill" and cand_uttr.get(
+ "type", "") == "universal_response"
+ _is_active_skill = cand_uttr.get("can_continue", "") == MUST_CONTINUE # no priority to prev active skill
_can_continue = CAN_NOT_CONTINUE # no priority to scripted skills
- # if set(all_cand_intents).intersection(set(_required_actions)) or _is_grounding_reqda:
- if False:
+ if set(all_cand_intents).intersection(set(_required_actions)) or _is_grounding_reqda or _is_active_skill:
# -----one of the can intent is in intents required by user-----
categorized_hyps, categorized_prompts = categorize_candidate(
cand_id, skill_name, categorized_hyps, categorized_prompts, _is_just_prompt,
