diff --git a/clef_evaluation.py b/clef_evaluation.py index 9cdc509..b220960 100644 --- a/clef_evaluation.py +++ b/clef_evaluation.py @@ -323,6 +323,7 @@ def check_validity_of_arguments(args): def main(): args = parse_args() + # log to file logging.basicConfig( filename=args.f_log, filemode="w", @@ -330,6 +331,11 @@ def main(): format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", ) + # log errors also to console + handler = logging.StreamHandler(sys.stdout) + handler.setLevel(logging.ERROR) + logging.getLogger().addHandler(handler) + try: check_validity_of_arguments(args) except Exception as e: @@ -353,8 +359,9 @@ def main(): args.outdir, args.suffix, ) - except AssertionError as err: - print(err) + except AssertionError: + # don't interrupt the pipeline + pass ################################################################################ diff --git a/ner_evaluation/ner_eval.py b/ner_evaluation/ner_eval.py index 2a98f36..0242cf5 100644 --- a/ner_evaluation/ner_eval.py +++ b/ner_evaluation/ner_eval.py @@ -145,11 +145,13 @@ def reconstruct_segmentation(self): toks_pred = [tok.TOKEN for tok in sent_pred] toks_true = [tok.TOKEN for tok in doc_true] if toks_true != toks_pred: - raise AssertionError( + msg = ( f"The system response '{self.f_pred}' is not in line with the gold standard. " + "The attempt to reconstruct the segmentation failed. " + f"The mismatch occured in document {i_doc_true + 1} starting at token position {tok_pos_start +1} (Tokens: {toks_true}) wtr to the gold standard." ) + logging.error(msg) + raise AssertionError sents_pred.append(sent_pred) tok_pos_start += n_doc_sent_true