change confidence to %
This commit is contained in:
@@ -9,7 +9,7 @@ class LyricsResult:
|
||||
song: str
|
||||
src: str
|
||||
lyrics: str
|
||||
confidence: float
|
||||
confidence: int
|
||||
time: float = 0.00
|
||||
|
||||
def dict(self):
|
||||
|
@@ -29,7 +29,7 @@ class Cache:
|
||||
self.sqlite_exts: list[str] = ['/usr/local/lib/python3.11/dist-packages/spellfix1.cpython-311-x86_64-linux-gnu.so']
|
||||
self.label: str = "Cache"
|
||||
|
||||
def get_matched(self, sqlite_rows: list[sqlite3.Row], matched_candidate: tuple, confidence: float) -> Optional[LyricsResult]:
|
||||
def get_matched(self, sqlite_rows: list[sqlite3.Row], matched_candidate: tuple, confidence: int) -> Optional[LyricsResult]:
|
||||
"""Get Matched Result"""
|
||||
matched_id: int = matched_candidate[0]
|
||||
for row in sqlite_rows:
|
||||
@@ -148,7 +148,7 @@ class Cache:
|
||||
best_match: tuple|None = matcher.find_best_match(input_track=input_track,
|
||||
candidate_tracks=result_tracks)
|
||||
else:
|
||||
best_match = (result_tracks[0], float(1))
|
||||
best_match = (result_tracks[0], 100)
|
||||
if not best_match:
|
||||
return None
|
||||
(candidate, confidence) = best_match
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
from difflib import SequenceMatcher
|
||||
from typing import List, Optional, Tuple
|
||||
import logging
|
||||
import regex
|
||||
|
||||
class TrackMatcher:
|
||||
@@ -28,6 +29,8 @@ class TrackMatcher:
|
||||
Optional[Tuple[int, str, float]]: Tuple of (best matching track, similarity score)
|
||||
or None if no good match found
|
||||
"""
|
||||
|
||||
|
||||
if not input_track or not candidate_tracks:
|
||||
return None
|
||||
|
||||
@@ -53,7 +56,7 @@ class TrackMatcher:
|
||||
best_match = candidate
|
||||
|
||||
# Return the match only if it meets the threshold
|
||||
return (best_match, round(best_score, 2)) if best_score >= self.threshold else None
|
||||
return (best_match, round(best_score *100)) if best_score >= self.threshold else None
|
||||
|
||||
def _normalize_string(self, text: str) -> str:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user