Datasets:
Tasks:
Token Classification
Languages:
English
Size:
10K<n<100K
Tags:
Not-For-All-Audiences
License:
small logging change
Browse files- normalize_tags.py +5 -5
normalize_tags.py
CHANGED
@@ -24,6 +24,7 @@ except ImportError:
|
|
24 |
|
25 |
from e6db.utils import TagSetNormalizer, tag_categories, tag_category2id
|
26 |
|
|
|
27 |
DATA_DIR = Path(__file__).resolve().parent / "data"
|
28 |
RE_PARENS_SUFFIX = re.compile(r"_\([^)]+\)$")
|
29 |
|
@@ -138,7 +139,7 @@ def make_tagset_normalizer(config: dict) -> TagSetNormalizer:
|
|
138 |
if tag2id[old] == tag2id[new]:
|
139 |
tag_normalizer.rename_output(old, new)
|
140 |
else:
|
141 |
-
|
142 |
f"Cannot rename {old} -> {new}: old tag id={tag2id[old]} vs. new tag id={tag2id[new]})"
|
143 |
)
|
144 |
|
@@ -393,7 +394,7 @@ def main():
|
|
393 |
help="Restrict tag count printing to specific categories or 'unknown'",
|
394 |
)
|
395 |
args = parser.parse_args()
|
396 |
-
|
397 |
|
398 |
# Validate input/output directories
|
399 |
input_dir = args.input_dir.resolve()
|
@@ -454,7 +455,7 @@ def main():
|
|
454 |
logger.info("🔧 Initializing tag normalizer...")
|
455 |
start_time = time.time()
|
456 |
tagset_normalizer = make_tagset_normalizer(config)
|
457 |
-
|
458 |
|
459 |
logger.info("🚫 Creating blacklist...")
|
460 |
blacklist = make_blacklist(
|
@@ -515,7 +516,6 @@ CONFIG_NAME = "normalize.toml"
|
|
515 |
def setup_logger(verbose):
|
516 |
level = logging.DEBUG if verbose else logging.INFO
|
517 |
logging.basicConfig(level=level, format="%(asctime)s - %(levelname)s - %(message)s")
|
518 |
-
return logging.getLogger(__name__)
|
519 |
|
520 |
|
521 |
def ask_for_confirmation(prompt, default=False):
|
@@ -568,7 +568,7 @@ def is_clean_git_repo(directory):
|
|
568 |
if n_modified == 0:
|
569 |
return True
|
570 |
else:
|
571 |
-
|
572 |
return False
|
573 |
except (subprocess.CalledProcessError, FileNotFoundError):
|
574 |
return False
|
|
|
24 |
|
25 |
from e6db.utils import TagSetNormalizer, tag_categories, tag_category2id
|
26 |
|
27 |
+
logger = logging.getLogger(__name__)
|
28 |
DATA_DIR = Path(__file__).resolve().parent / "data"
|
29 |
RE_PARENS_SUFFIX = re.compile(r"_\([^)]+\)$")
|
30 |
|
|
|
139 |
if tag2id[old] == tag2id[new]:
|
140 |
tag_normalizer.rename_output(old, new)
|
141 |
else:
|
142 |
+
logger.warning(
|
143 |
f"Cannot rename {old} -> {new}: old tag id={tag2id[old]} vs. new tag id={tag2id[new]})"
|
144 |
)
|
145 |
|
|
|
394 |
help="Restrict tag count printing to specific categories or 'unknown'",
|
395 |
)
|
396 |
args = parser.parse_args()
|
397 |
+
setup_logger(args.verbose)
|
398 |
|
399 |
# Validate input/output directories
|
400 |
input_dir = args.input_dir.resolve()
|
|
|
455 |
logger.info("🔧 Initializing tag normalizer...")
|
456 |
start_time = time.time()
|
457 |
tagset_normalizer = make_tagset_normalizer(config)
|
458 |
+
logger.info(f"✅ Data loaded in {time.time() - start_time:.2f} seconds")
|
459 |
|
460 |
logger.info("🚫 Creating blacklist...")
|
461 |
blacklist = make_blacklist(
|
|
|
516 |
def setup_logger(verbose):
|
517 |
level = logging.DEBUG if verbose else logging.INFO
|
518 |
logging.basicConfig(level=level, format="%(asctime)s - %(levelname)s - %(message)s")
|
|
|
519 |
|
520 |
|
521 |
def ask_for_confirmation(prompt, default=False):
|
|
|
568 |
if n_modified == 0:
|
569 |
return True
|
570 |
else:
|
571 |
+
logger.warning("🚫 Found a git repo, but it's dirty.")
|
572 |
return False
|
573 |
except (subprocess.CalledProcessError, FileNotFoundError):
|
574 |
return False
|