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

Alter TagSetManager score function to look at preference only #134

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.tpv_dest_tags, other.tpv_tags) or a_prefers_b(other.tpv_tags, self.tpv_dest_tags) else 0
return score

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