(mentions: Any)
| 4103 | text = str(question or "") |
| 4104 | mentions: List[Dict[str, str]] = [] |
| 4105 | for match in _MENTION_LINK_RE.finditer(text): |
| 4106 | mentions.append({"title": match.group(1).strip(), "node_id": match.group(2).strip()}) |
| 4107 | stripped = _MENTION_LINK_RE.sub(" ", text) |
| 4108 | for match in _MENTION_TOKEN_RE.finditer(stripped): |
| 4109 | token = match.group(1).strip() |
| 4110 | if token: |
| 4111 | mentions.append({"title": token, "node_id": ""}) |
| 4112 | return mentions |
| 4113 | |
| 4114 | |
| 4115 | def _normalize_requested_mentions(mentions: Any) -> List[Dict[str, str]]: |
| 4116 | normalized: List[Dict[str, str]] = [] |
| 4117 | if not isinstance(mentions, list): |
| 4118 | return normalized |
| 4119 | for item in mentions: |
| 4120 | if isinstance(item, dict): |
| 4121 | title = str(item.get("title") or item.get("label") or "").strip() |
| 4122 | node_id = str(item.get("node_id") or item.get("id") or "").strip() |
no test coverage detected