reluce / szurubooru-toolkit

Python package and script collection to manage your szurubooru image board.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: add implications autotagger

noirscape opened this issue · comments

Basically, add a script that:

  • Goes through all tags with at least one implication (-implication-count:0)
  • Loops over the posts that belong to these tags.
  • Check if the post has the implications properly added.
  • If not, edit the post to add those tag implications.

Right now, szurubooru doesn't retroactively update implications and it's not a feature that's planned to be added (see https://github.com/rr-/szurubooru/issues/189 ), but it's a rather heavy maintenance burden for creating proper tag implication structures, especially for tags that encompass large amounts of posts.

Sounds like a good idea!

My suggestion would be to add a switch called --update-implications to the tag_posts.py script.
With that, we can narrow down the posts which we want to update with a query. If we want to loop through all posts, we just use a wildcard (*) as the query. Another benefit would be that we don't have to loop through all tags in the database (where possible a lot of tags don't belong to a post if we used the create_tags.py script), which might benefit performance.

I fully agree with that assessment yeah, that sounds like a good optimization.

I added the switch --update-implications as mentioned to the script tag_posts.py in the branch update-implications.
You can go ahead and try if it works for you. I'll merge it to main later on.

It's quite slow though (up to a minute, depending on the amount of tags), as I'm using the szuru module which builds a whole object for each tag, but as it's working for now, I'll leave it at that.