add scripts/check_dict.py

This commit is contained in:
gwdwyy 2013-07-10 18:32:31 +08:00
parent c58e690fd1
commit 47bc221662

29
scripts/check_dict.py Executable file
View File

@ -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"