File size: 2,804 Bytes
f24b428
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from test_embeddings import create_test_data
from chroma_storage import ChromaMatchingSystem
import chromadb
from chromadb.config import Settings

def test_unseen_matches():
    print("Starting ChromaDB unseen matches test...")
    
    # Clear existing collections with proper settings
    client = chromadb.Client(Settings(
        allow_reset=True,
        is_persistent=True
    ))
    client.reset()
    
    # Rest of the test remains the same...
    (job_posting, matching_seeker, matching_info,
     partial_matching_seeker, partial_matching_info,
     non_matching_seeker, non_matching_info) = create_test_data()
     
    matcher = ChromaMatchingSystem("test_collection")
    
    # Add test seekers
    print("\nAdding test job seekers...")
    test_seekers = [
        ("seeker_1", matching_seeker, matching_info, 
         {"experience_level": "senior"}),
        ("seeker_2", partial_matching_seeker, partial_matching_info,
         {"experience_level": "mid"}),
        ("seeker_3", non_matching_seeker, non_matching_info,
         {"experience_level": "mid"})
    ]
    
    for seeker_id, processed, unprocessed, metadata in test_seekers:
        print(f"Adding job seeker: {seeker_id}")
        matcher.add_job_seeker(seeker_id, processed, unprocessed, metadata)
    
    # Test 1: Get initial unseen matches
    print("\nTest 1: Getting initial unseen matches...")
    unseen_matches = matcher.get_unseen_matches(job_posting, n_results=3)
    
    print(f"\nFound {len(unseen_matches)} unseen matches:")
    for i, match in enumerate(unseen_matches, 1):
        print(f"\nMatch {i}:")
        print(f"Similarity Score: {match.similarity_score:.3f}")
        print("\nField Scores:")
        for field, score in match.field_scores.items():
            print(f"  {field}: {score:.3f}")
    
    # Mark top match as seen
    print("\nMarking top match as seen...")
    matcher.mark_matches_as_seen(["seeker_1"])
    
    # Test 2: Get unseen matches after marking one as seen
    print("\nTest 2: Getting unseen matches after marking one as seen...")
    remaining_unseen = matcher.get_unseen_matches(job_posting, n_results=3)
    
    print(f"\nFound {len(remaining_unseen)} remaining unseen matches:")
    for i, match in enumerate(remaining_unseen, 1):
        print(f"\nMatch {i}:")
        print(f"Similarity Score: {match.similarity_score:.3f}")
    
    # Test 3: Get all matches (including seen)
    print("\nTest 3: Getting all matches (including seen)...")
    all_matches = matcher.get_matches(job_posting, n_results=3)
    
    print(f"\nFound {len(all_matches)} total matches:")
    for i, match in enumerate(all_matches, 1):
        print(f"\nMatch {i}:")
        print(f"Similarity Score: {match.similarity_score:.3f}")

if __name__ == "__main__":
    test_unseen_matches()