NLP - Text Similarity and Search
Given two vectors
A = [2, 2, 1] and B = [1, 0, 1], what is the cosine similarity computed by the code below?
import numpy as np
A = np.array([2, 2, 1])
B = np.array([1, 0, 1])
cos_sim = np.dot(A, B) / (np.linalg.norm(A) * np.linalg.norm(B))
print(round(cos_sim, 2))