Spaces:
Sleeping
Sleeping
- Introduced a new API endpoint for finding similar content in the tenant's workspace, allowing users to identify overlapping uploads and draft notes.
0908f70 | """Unit tests for draft overlap / Jaccard helpers (library scan uses vector store).""" | |
| from app.services.content_similarity import find_draft_overlaps, jaccard_similarity | |
| def test_jaccard_identical() -> None: | |
| assert jaccard_similarity("hello world", "hello world") == 1.0 | |
| def test_jaccard_disjoint() -> None: | |
| assert jaccard_similarity("aaa bbb", "ccc ddd") == 0.0 | |
| def test_jaccard_partial() -> None: | |
| sim = jaccard_similarity("slipped roof tiles on main hip", "main hip roof with slipped tiles") | |
| assert sim > 0.4 | |
| def test_find_draft_overlaps_line() -> None: | |
| text = "solid brick wall 275mm dpc visible slight crack nw corner" | |
| peers = {"E4": "solid brick construction 275mm dpc hairline crack north west corner elevation"} | |
| hits = find_draft_overlaps(text, "D", peers, line_threshold=0.25, block_threshold=0.55) | |
| assert len(hits) >= 1 | |
| assert hits[0].other_section_code == "E4" | |
| assert hits[0].overlap_kind in ("line", "block") | |
| def test_find_draft_overlaps_skips_same_section() -> None: | |
| text = "duplicate line about gutters blocked" | |
| peers = {"E3": "duplicate line about gutters blocked"} | |
| hits = find_draft_overlaps(text, "E3", peers) | |
| assert hits == [] | |