From 47bc22166213e50b4f5a2bc583752ff10babd188 Mon Sep 17 00:00:00 2001 From: gwdwyy Date: Wed, 10 Jul 2013 18:32:31 +0800 Subject: [PATCH] add scripts/check_dict.py --- scripts/check_dict.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/check_dict.py diff --git a/scripts/check_dict.py b/scripts/check_dict.py new file mode 100755 index 0000000..ac528f7 --- /dev/null +++ b/scripts/check_dict.py @@ -0,0 +1,29 @@ +#!/usr/bin/python + +import sys + +if len(sys.argv) == 1: + print "usage : %s dict_file1 dict_file2 ..." + exit(1) + +d = {} + +for fname in sys.argv[1:]: + with open(fname, "r") as fin: + for i, line in enumerate(fin): + try: + word, cnt, tag = line.strip().split(" ") + if word in d: + print "error file[%s] line[%s] : %s" %(fname, i, line) + exit(1) + else: + d[word] = True + + if 0 >= int(cnt) : + print "error file[%s] line[%s] : %s" %(fname, i, line) + exit(1) + except Exception as err: + print "error file[%s] line[%s] : %s" %(fname, i, line) + exit(1) + +print "OK"