"""checks that every pair of sentences gets the same vector.""" import sys from encode import encode, cosine PAIRS = [ ("i love you", "i hate you"), ("the ocean is beautiful", "2 + 2 = 4"), ("please water my plants", "the mitochondria is the powerhouse of the cell"), ("hamlet: to be or not to be", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), ("", "this sentence has been completely redacted for legal reasons"), ] for a, b in PAIRS: c = cosine(encode(a), encode(b)) assert abs(c - 1.0) < 1e-6, (a, b, c) print(f"cosine({a!r:<36}, {b!r:<52}) = {c:.6f}") print("ok") sys.exit(0)