(profile, current_keywords, raw_value, canonical_direction)
| 86 | |
| 87 | def _route_keyword_to_interest_direction(profile, current_keywords, raw_value, canonical_direction): |
| 88 | current_keywords[:] = [ |
| 89 | keyword for keyword in current_keywords |
| 90 | if not _keyword_resolves_to_direction(keyword, canonical_direction) |
| 91 | ] |
| 92 | core_directions = profile.get("core_directions") |
| 93 | if not isinstance(core_directions, dict): |
| 94 | core_directions = {} |
| 95 | topic_weights = profile.get("topic_weights") |
| 96 | if not isinstance(topic_weights, dict): |
| 97 | topic_weights = {} |
| 98 | |
| 99 | previous_core = _coerce_float(core_directions.get(canonical_direction), 0.0) |
| 100 | previous_topic = _coerce_float(topic_weights.get(canonical_direction), 0.0) |
| 101 | core_directions[canonical_direction] = max(previous_core, SOFT_DIRECTION_WEIGHT) |
| 102 | topic_weights[canonical_direction] = max(previous_topic, SOFT_DIRECTION_WEIGHT) |
| 103 | profile["core_directions"] = core_directions |
| 104 | profile["topic_weights"] = topic_weights |
| 105 | return f"{raw_value} -> {canonical_direction}" |
| 106 | |
| 107 | |
| 108 | def parse_input(user_input: str): |
| 109 | """Parse user input to extract operation type and entities""" |
no test coverage detected