from __future__ import annotations

from idri import IdentifierEncoder, compose_vectors, cosine_similarity

enc = IdentifierEncoder()

v1 = enc.encode("F0032-3", family="invoice")
v2 = enc.encode("F0032", family="invoice")

composed = compose_vectors([(v1, 0.6), (v2, 0.4)])

composer = enc.start_composer(normalize_output=True)
composer.add_text("F0032-3", weight=0.6, family="invoice")
composer.add_text("F0032", weight=0.4, family="invoice")
incremental = composer.build()

print("composed dot incremental:", round(cosine_similarity(composed, incremental), 6))
print("composer explain:", composer.explain(top_k=5))
