(paper: Dict)
| 792 | value = paper.get(key) or [] |
| 793 | if isinstance(value, str): |
| 794 | tokens.append(value) |
| 795 | else: |
| 796 | tokens.extend(str(item) for item in value if str(item).strip()) |
| 797 | return {str(token).strip().lower() for token in tokens if str(token).strip()} |
| 798 | |
| 799 | |
| 800 | def _topic_jaccard_similarity(left: Dict, right: Dict) -> float: |
| 801 | left_tokens = _paper_topic_tokens(left) |
| 802 | right_tokens = _paper_topic_tokens(right) |
| 803 | if not left_tokens or not right_tokens: |
| 804 | return 0.0 |
| 805 | return len(left_tokens & right_tokens) / len(left_tokens | right_tokens) |
no test coverage detected