(user_meta: Dict[str, Any], role: Dict[str, Any])
| 335 | |
| 336 | |
| 337 | def build_initial_profile(user_meta: Dict[str, Any], role: Dict[str, Any]) -> Dict[str, Any]: |
| 338 | directions: Dict[str, float] = {} |
| 339 | direction_terms: List[str] = [] |
| 340 | |
| 341 | for key, weight, phrase in ( |
| 342 | _seed_direction_entries(user_meta.get("seed_directions")) |
| 343 | + _seed_direction_entries(role.get("seed_directions")) |
| 344 | + _seed_direction_entries(role.get("core_directions")) |
| 345 | ): |
| 346 | if key: |
| 347 | directions[key] = max(directions.get(key, 0.0), weight) |
| 348 | direction_terms.extend([key, key.replace("-", " "), phrase]) |
| 349 | |
| 350 | description = str(user_meta.get("description") or role.get("description") or "").strip() |
| 351 | bootstrap_summary = str(role.get("bootstrap_summary") or "").strip() |
| 352 | profile_terms: List[str] = dedupe_strings( |
| 353 | direction_terms |
| 354 | + parse_string_list(description) |
| 355 | + parse_string_list(bootstrap_summary) |
| 356 | ) |
| 357 | |
| 358 | return { |
| 359 | "directions": directions, |
| 360 | "terms": profile_terms, |
| 361 | "keywords": [], |
| 362 | "authors": [], |
| 363 | "institutions": [], |
| 364 | "description": description, |
| 365 | "bootstrap_summary": bootstrap_summary, |
| 366 | } |
| 367 | |
| 368 | |
| 369 | def dedupe_strings(values: Iterable[Any]) -> List[str]: |
no test coverage detected