1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-24 16:54:20 +00:00

Improve logging

This commit is contained in:
Steffo 2023-02-10 03:30:41 +01:00
parent 14dd8045e0
commit b4573d5eab
Signed by: steffo
GPG key ID: 2A24051445686895

View file

@ -35,11 +35,17 @@ def main():
for sample_func in [sample_reviews_varied, sample_reviews_polar]: for sample_func in [sample_reviews_varied, sample_reviews_polar]:
slog = logging.getLogger(f"{__name__}.{sample_func.__name__}")
slog.debug(f"Selected sample_func: %s", sample_func)
for SentimentAnalyzer in [ for SentimentAnalyzer in [
TensorflowSentimentAnalyzer, TensorflowSentimentAnalyzer,
NLTKSentimentAnalyzer NLTKSentimentAnalyzer
]: ]:
slog = logging.getLogger(f"{__name__}.{sample_func.__name__}.{SentimentAnalyzer.__name__}")
slog.debug(f"Selected SentimentAnalyzer: %s", SentimentAnalyzer)
for Tokenizer in [ for Tokenizer in [
PlainTokenizer, PlainTokenizer,
LowercaseTokenizer, LowercaseTokenizer,
@ -49,14 +55,15 @@ def main():
]: ]:
slog = logging.getLogger(f"{__name__}.{sample_func.__name__}.{SentimentAnalyzer.__name__}.{Tokenizer.__name__}") slog = logging.getLogger(f"{__name__}.{sample_func.__name__}.{SentimentAnalyzer.__name__}.{Tokenizer.__name__}")
slog.debug(f"Selected Tokenizer: %s", Tokenizer)
while True: while True:
try: try:
slog.debug("Creating sentiment analyzer...") slog.debug("Instantiating %s with %s...", SentimentAnalyzer, Tokenizer)
sa = SentimentAnalyzer(tokenizer=Tokenizer()) sa = SentimentAnalyzer(tokenizer=Tokenizer())
except TypeError: except TypeError:
slog.warning("%s does not support %s, skipping...", Tokenizer.__name__, SentimentAnalyzer.__name__) slog.warning("%s is not supported by %s, skipping run...", SentimentAnalyzer, Tokenizer)
break break
with Caches.from_database_samples(collection=reviews, sample_func=sample_func) as datasets: with Caches.from_database_samples(collection=reviews, sample_func=sample_func) as datasets: