Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'correlate' #12

Open
uranusjr opened this issue May 3, 2022 · 0 comments
Open

Use 'correlate' #12

uranusjr opened this issue May 3, 2022 · 0 comments

Comments

@uranusjr
Copy link
Member

uranusjr commented May 3, 2022

https://pypi.org/project/correlate/

This was presented during PyCon US. It should do a better job than our hand-crafted fuzzy-matcher.

def get_match_ratio(session: Session, path: pathlib.Path) -> float:
return fuzzywuzzy.fuzz.ratio(session.title, path.stem)
def choose_video(session: Session, video_paths: list) -> pathlib.Path:
"""Look through the file list and choose the one that "looks most like it"."""
score, match = max((get_match_ratio(session, p), p) for p in video_paths)
if score < 70:
raise ValueError("no match")
return match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

No branches or pull requests

1 participant