MediaProcessing/apps/pyMetadata/algo/AlgorithmBase.py
2026-01-02 01:09:26 +01:00

32 lines
867 B
Python

from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List
from fuzzywuzzy import fuzz
from tabulate import tabulate
from models.metadata import Metadata
@dataclass
class MatchResult:
title: str
matched_title: str
score: int
source: str
data: Metadata
class AlgorithmBase(ABC):
def __init__(self, title: str, metadata: Metadata):
self.title = title
self.metadata = metadata
@abstractmethod
def getScore(self) -> int:
"""
Returnerer alle matchresultater med scorer.
"""
pass
def print_match_summary(self, match_results: List[MatchResult]) -> None:
headers = ["Title", "Matched Title", "Score", "Source"]
data = [(r.title, r.matched_title, r.score, r.source) for r in match_results]
print(tabulate(data, headers=headers))