From 406e88ade83145d671954d8a781d814cce7f2f60 Mon Sep 17 00:00:00 2001 From: voje Date: Thu, 28 Feb 2019 21:49:49 +0100 Subject: [PATCH] added msd-not-found exception --- dockerfiles/python-java/Makefile | 4 ++-- tools/parse_all.py | 3 ++- tools/parser/msd/msdmap.py | 6 +++++- tools/tools.cfg | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dockerfiles/python-java/Makefile b/dockerfiles/python-java/Makefile index 74dae84..82b9f15 100644 --- a/dockerfiles/python-java/Makefile +++ b/dockerfiles/python-java/Makefile @@ -8,12 +8,12 @@ build: run: docker run \ - -it \ + -it \ -v /home/${USER}:/home/${USER} \ --user $(shell id -u):$(shell id -g) \ -v /etc/passwd:/etc/passwd \ -v /etc/group:/etc/group \ - -v $(shell pwd)/../../:/cjvt-srl-tagging \ + -v $(shell pwd)/../../:/cjvt-srl-tagging \ -w /cjvt-srl-tagging \ -v /home/kristjan/kres_mount:/kres_mount:ro \ python-java \ diff --git a/tools/parse_all.py b/tools/parse_all.py index 5d4410b..3b56a18 100644 --- a/tools/parse_all.py +++ b/tools/parse_all.py @@ -53,8 +53,9 @@ def handle_file(infile): kres_out_str = "" for _, sentence in res_dict.items(): kres_out_str += par.to_conll_2009_SRL(sentence) - except: + except Exception as exc: logging.info("Failed processing file: {}".format(str(kres_file))) + logging.error(exc) return False diff --git a/tools/parser/msd/msdmap.py b/tools/parser/msd/msdmap.py index 7ea1bd9..f319220 100644 --- a/tools/parser/msd/msdmap.py +++ b/tools/parser/msd/msdmap.py @@ -35,7 +35,11 @@ class Msdmap: def slo_msd_to_eng_long(self, slo_msd): # old, slow # return (self.msd_table[self.msd_table["slo_msd"] == slo_msd]["eng_long"]).values[0] - return self.msd_table.query("slo_msd == '{}'".format(slo_msd))["eng_long"].values[0] + # return self.msd_table.query("slo_msd == '{}'".format(slo_msd))["eng_long"].values[0] + query = self.msd_table.query("slo_msd == '{}'".format(slo_msd)) + if query.empty: + return "No-matching-msd-found" + return query["eng_long"].values[0] def slo_msd_to_eng_pos(self, slo_msd): # first letter in slo_msd == slo_pos diff --git a/tools/tools.cfg b/tools/tools.cfg index 2751d43..33373c1 100644 --- a/tools/tools.cfg +++ b/tools/tools.cfg @@ -1,5 +1,5 @@ [tools] -kres_orig = /kres_mount/kres_parsed/tei +kres_orig = ../data/kres_example kres_tsv = ../data/kres_out/1_tsv kres_srl = ../data/kres_out/2_srl kres_json = ../data/kres_out/final_json