Skip to content

Commit

Permalink
Alter TagSetManager score function to look at preference only
Browse files Browse the repository at this point in the history
  • Loading branch information
cat-bro committed Jun 12, 2024
1 parent 50ac513 commit 5608f18
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tpv/core/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@ def score(self, other: TagSetManager) -> bool:
:param other:
:return:
"""
return (sum(int(tag.tag_type) * int(o.tag_type) for tag in self.tags for o in other.tags
if tag.name == o.name and tag.value == o.value)
# penalize tags that don't exist in the other
- sum(int(tag.tag_type) for tag in self.tags if not other.contains_tag(tag)))
def a_prefers_b(a_tags, b_tags):
return any(
tag for tag in a_tags.filter(tag_type = TagType.PREFER)
if list(b_tags.filter(tag_type = [TagType.ACCEPT, TagType.PREFER, TagType.REQUIRE], tag_value = tag.value))
)
score = 1 if a_prefers_b(self.tags, other.tags) or a_prefers_b(other.tags, self.tags) else 0
return score

def __eq__(self, other):
if not isinstance(other, TagSetManager):
Expand Down

0 comments on commit 5608f18

Please sign in to comment.