Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aflueckiger committed Jun 4, 2020
1 parent 98eb7cb commit 0309a23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions clef_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,19 @@ def check_validity_of_arguments(args):
def main():
args = parse_args()

# log to file
logging.basicConfig(
filename=args.f_log,
filemode="w",
level=logging.DEBUG,
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:
Expand All @@ -353,8 +359,9 @@ def main():
args.outdir,
args.suffix,
)
except AssertionError as err:
print(err)
except AssertionError:
# don't interrupt the pipeline
pass


################################################################################
Expand Down
4 changes: 3 additions & 1 deletion ner_evaluation/ner_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0309a23

Please sign in to comment.