Datasets:
Tasks:
Token Classification
Languages:
English
Size:
10K<n<100K
Tags:
Not-For-All-Audiences
License:
normalize: replace remove_parens_suffix_for_categories with remove_parens
Browse files- normalize.toml +5 -10
- normalize_tags.py +6 -9
normalize.toml
CHANGED
@@ -54,16 +54,11 @@ blacklist_categories = ["pool"]
|
|
54 |
# By default, underscores are replaced with spaces unless specified here
|
55 |
keep_underscores = ["rating_explicit", "rating_questionable", "rating_safe"]
|
56 |
|
57 |
-
# Remove
|
58 |
-
#
|
59 |
-
#
|
60 |
-
|
61 |
-
|
62 |
-
"character",
|
63 |
-
"copyright",
|
64 |
-
"lore",
|
65 |
-
"species",
|
66 |
-
]
|
67 |
|
68 |
# On Alias Conflict: How to handle conflicts when creating aliases
|
69 |
# Options: "silent", "overwrite", "overwrite_rarest", "warn", "raise"
|
|
|
54 |
# By default, underscores are replaced with spaces unless specified here
|
55 |
keep_underscores = ["rating_explicit", "rating_questionable", "rating_safe"]
|
56 |
|
57 |
+
# Remove prentheses suffixes that matches the tag's category like _(species) or
|
58 |
+
# _(character) if it doesn't conflict with another tag (when
|
59 |
+
# on_alias_conflict="ignore")
|
60 |
+
# Default: true
|
61 |
+
remove_parens = true
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
# On Alias Conflict: How to handle conflicts when creating aliases
|
64 |
# Options: "silent", "overwrite", "overwrite_rarest", "warn", "raise"
|
normalize_tags.py
CHANGED
@@ -115,18 +115,14 @@ def make_tagset_normalizer(config: dict) -> TagSetNormalizer:
|
|
115 |
tag_normalizer.remove_input_mappings(tag)
|
116 |
|
117 |
# Apply rule based output renames
|
118 |
-
|
119 |
-
"remove_parens_suffix_for_categories",
|
120 |
-
["artist", "character", "copyright", "lore", "species"],
|
121 |
-
)
|
122 |
-
remove_suffix_for_cats = {tag_category2id[c] for c in remove_suffix_for_cats}
|
123 |
artist_by_prefix = config.get("artist_by_prefix", True)
|
124 |
|
125 |
def map_output(tag, tid):
|
126 |
cat = tagid2cat[tid] if tid is not None else -1
|
127 |
-
if
|
128 |
-
without_suffix =
|
129 |
-
if
|
130 |
tag = without_suffix
|
131 |
if cat == cat_artist and artist_by_prefix and not tag.startswith("by_"):
|
132 |
tag_wby = f"by_{tag}"
|
@@ -403,7 +399,8 @@ def main():
|
|
403 |
help="Don't ask for confirmation for clobbering input files",
|
404 |
)
|
405 |
parser.add_argument(
|
406 |
-
"-b",
|
|
|
407 |
action="store_true",
|
408 |
help="Print the effective list of blacklisted tags",
|
409 |
)
|
|
|
115 |
tag_normalizer.remove_input_mappings(tag)
|
116 |
|
117 |
# Apply rule based output renames
|
118 |
+
remove_parens = config.get("remove_parens", True)
|
|
|
|
|
|
|
|
|
119 |
artist_by_prefix = config.get("artist_by_prefix", True)
|
120 |
|
121 |
def map_output(tag, tid):
|
122 |
cat = tagid2cat[tid] if tid is not None else -1
|
123 |
+
if remove_parens:
|
124 |
+
without_suffix = tag.removesuffix(f"_({tag_categories[cat]})")
|
125 |
+
if without_suffix != tag and tag2id.get(without_suffix) == tid:
|
126 |
tag = without_suffix
|
127 |
if cat == cat_artist and artist_by_prefix and not tag.startswith("by_"):
|
128 |
tag_wby = f"by_{tag}"
|
|
|
399 |
help="Don't ask for confirmation for clobbering input files",
|
400 |
)
|
401 |
parser.add_argument(
|
402 |
+
"-b",
|
403 |
+
"--print-blacklist",
|
404 |
action="store_true",
|
405 |
help="Print the effective list of blacklisted tags",
|
406 |
)
|