Skip to content

Instantly share code, notes, and snippets.

@BenTenmann
Last active December 21, 2022 11:55
Show Gist options
  • Save BenTenmann/72c47e7d7d4184492e07d1b854ec9274 to your computer and use it in GitHub Desktop.
Save BenTenmann/72c47e7d7d4184492e07d1b854ec9274 to your computer and use it in GitHub Desktop.
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