Compare commits
No commits in common. "18da5d7972b96f0b8b45b04dceb47e49c268fe38" and "6f3ce2ab024d08df2a67cc07e4b7656f231534f2" have entirely different histories.
18da5d7972
...
6f3ce2ab02
1 changed files with 3 additions and 17 deletions
20
main.py
20
main.py
|
@ -194,21 +194,7 @@ async def fetch_post(ctx, md5) -> Optional[dict]:
|
|||
if not rows:
|
||||
return None
|
||||
assert len(rows) == 1
|
||||
post = json.loads(rows[0][0])
|
||||
post_rating = post["rating"]
|
||||
match post_rating:
|
||||
case "g":
|
||||
rating_tag = "general"
|
||||
case "s":
|
||||
rating_tag = "sensitive"
|
||||
case "q":
|
||||
rating_tag = "questionable"
|
||||
case "e":
|
||||
rating_tag = "explicit"
|
||||
case _:
|
||||
raise AssertionError("invalid post rating {post_rating!r}")
|
||||
post["tag_string"] = post["tag_string"] + " " + rating_tag
|
||||
return post
|
||||
return json.loads(rows[0][0])
|
||||
|
||||
|
||||
async def insert_post(ctx, post):
|
||||
|
@ -264,8 +250,8 @@ async def fight(ctx):
|
|||
|
||||
|
||||
def score(danbooru_tags: Set[str], interrogator_tags: Set[str]) -> decimal.Decimal:
|
||||
tags_in_danbooru = danbooru_tags.intersection(interrogator_tags)
|
||||
tags_not_in_danbooru = interrogator_tags - danbooru_tags
|
||||
tags_in_danbooru = danbooru_tags | interrogator_tags
|
||||
tags_not_in_danbooru = danbooru_tags - interrogator_tags
|
||||
return decimal.Decimal(
|
||||
len(tags_in_danbooru) - len(tags_not_in_danbooru)
|
||||
) / decimal.Decimal(len(danbooru_tags))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue