Refactored match result object
This commit is contained in:
parent
426b36c985
commit
0cdcd13822
1 changed files with 6 additions and 5 deletions
|
@ -150,12 +150,14 @@ class EpisodesMatchResult:
|
||||||
scores: dict[str, dict[str, float]] = field(default_factory=dict)
|
scores: dict[str, dict[str, float]] = field(default_factory=dict)
|
||||||
"""Raw scores from matching. For each episode, the score to each reference."""
|
"""Raw scores from matching. For each episode, the score to each reference."""
|
||||||
|
|
||||||
perfect_match: bool = False
|
|
||||||
"""If true, scores were unambiguous amd simplified to reference_by_episode and episode_by_reference."""
|
|
||||||
|
|
||||||
reference_by_episode: dict[str, str] | None = None
|
reference_by_episode: dict[str, str] | None = None
|
||||||
"""Simplified form of results, if unambiguous (see perfect_match). Episode as key, reference as value."""
|
"""Simplified form of results, if unambiguous (see perfect_match). Episode as key, reference as value."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def perfect_match(self) -> bool:
|
||||||
|
"""If true, scores were unambiguous amd simplified to reference_by_episode and episode_by_reference."""
|
||||||
|
return self.reference_by_episode is not None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def episode_by_reference(self) -> dict[str, str] | None:
|
def episode_by_reference(self) -> dict[str, str] | None:
|
||||||
"""Simplified form of results, if unambiguous (see perfect_match). Refernce as key, episode as value."""
|
"""Simplified form of results, if unambiguous (see perfect_match). Refernce as key, episode as value."""
|
||||||
|
@ -195,13 +197,12 @@ class EpisodesMatchResult:
|
||||||
elif ep_ref == ref:
|
elif ep_ref == ref:
|
||||||
return # Not a perfect match
|
return # Not a perfect match
|
||||||
|
|
||||||
self.perfect_match = True
|
|
||||||
self.reference_by_episode = ref_by_ep
|
self.reference_by_episode = ref_by_ep
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
msg = f"Perfect Match: {self.perfect_match}"
|
msg = f"Perfect Match: {self.perfect_match}"
|
||||||
|
|
||||||
if self.perfect_match and self.reference_by_episode:
|
if self.reference_by_episode:
|
||||||
for ep, ref in self.reference_by_episode.items():
|
for ep, ref in self.reference_by_episode.items():
|
||||||
msg += f"\n{ep}\t{ref}"
|
msg += f"\n{ep}\t{ref}"
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue