| 1515 | |
| 1516 | |
| 1517 | def resolve_domain_subdir( |
| 1518 | config: dict[str, Any], |
| 1519 | *, |
| 1520 | title: str, |
| 1521 | abstract: str = "", |
| 1522 | subdir: str = "", |
| 1523 | ) -> str: |
| 1524 | if subdir.strip(): |
| 1525 | return subdir.strip() |
| 1526 | label = infer_domain_label(title, abstract) |
| 1527 | existing = existing_domain_dirs(config) |
| 1528 | if existing: |
| 1529 | best_name = "" |
| 1530 | best_score = -1 |
| 1531 | for domain_name in existing: |
| 1532 | score = domain_name_score(domain_name, label, title, abstract) |
| 1533 | if score > best_score: |
| 1534 | best_name = domain_name |
| 1535 | best_score = score |
| 1536 | if best_name and best_score > 0: |
| 1537 | return best_name |
| 1538 | return label |
| 1539 | |
| 1540 | |
| 1541 | def resolve_obsidian_note_path( |