Last active
December 21, 2022 11:55
-
-
Save BenTenmann/72c47e7d7d4184492e07d1b854ec9274 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
import numpy as np | |
import pandas as pd | |
import setriq | |
def search_most_similar_video(search: str, video_titles: List[str]) -> str: | |
lev = setriq.Levenshtein(return_squareform=True) | |
distances = lev([search] + video_titles) | |
closest_idx = np.argmin(distances[0, 1:]) | |
return video_titles[closest_idx] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment