FIX problem with creation of hash, instead of merging the strings each string get's an own hash. Adding os.path.join.

pull/7/head^2
JKamlah 6 years ago
parent eb70510271
commit c36396302d

@ -44,13 +44,13 @@ def gen_diff_report(gt_things, ocr_things, css_prefix, joiner, none, align):
def delete_tempcache(): def delete_tempcache():
# Delete all tempfiles and the directory (if empty) # Delete all tempfiles and the directory (if empty)
tempdir = tempfile.gettempdir() + "/dinglehopper/" tempdir = os.path.join(tempfile.gettempdir() + "/dinglehopper/")
if os.path.exists(tempdir): if os.path.exists(tempdir):
tempfiles = glob.glob(tempdir+"*.np*") tempfiles = glob.glob(tempdir+"*.np*")
for tempfilename in tempfiles: for tempfilename in tempfiles:
os.remove(tempfilename) os.remove(tempfilename)
if not os.listdir(tempdir): if not os.listdir(tempdir):
shutil.rmtree(os.path.normpath(tempdir)) shutil.rmtree(tempdir)
def process(gt, ocr, report_prefix): def process(gt, ocr, report_prefix):

@ -23,11 +23,12 @@ def levenshtein_matrix(seq1, seq2, tempcache=True):
strings, e.g. lists of grapheme clusters or lists of word strings. strings, e.g. lists of grapheme clusters or lists of word strings.
""" """
if tempcache: if tempcache:
hashname = hashlib.sha1(("".join(seq1) + "".join(seq2)).encode("utf-8")).hexdigest() hashseq1 = hashlib.sha1(("".join(seq1)).encode("utf-8")).hexdigest()
tempdir = os.path.normpath(tempfile.gettempdir() + "/dinglehopper/") hashseq2 = hashlib.sha1(("".join(seq2)).encode("utf-8")).hexdigest()
tempdir = os.path.join(tempfile.gettempdir() + "/dinglehopper/")
if not os.path.exists(tempdir): if not os.path.exists(tempdir):
os.makedirs(tempdir + "/dinglehopper/") os.makedirs(tempdir + "/dinglehopper/")
tempfilename = os.path.normpath(tempdir + "/" + hashname + ".npy") tempfilename = os.path.join(tempdir + "/" + hashseq1 + "." + hashseq2 + ".npy")
if os.path.exists(tempfilename): if os.path.exists(tempfilename):
return np.load(tempfilename) return np.load(tempfilename)

Loading…
Cancel
Save