From 4f4aa8ad5820e365c9100d213523a1ada5a213c9 Mon Sep 17 00:00:00 2001 From: luoruixuan <1500012842@pku.edu.cn> Date: Sat, 12 Jan 2019 20:42:15 +0800 Subject: [PATCH] fix bug on windows --- pkuseg/main.py | 1 + pkuseg/toolbox.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkuseg/main.py b/pkuseg/main.py index a58a8fe..7678ac3 100644 --- a/pkuseg/main.py +++ b/pkuseg/main.py @@ -207,6 +207,7 @@ def basicTrain(config, XTest, tb): config.diffList.append(config.diff) scoreList = tb.test(XTest, i) config.scoreListList.append(scoreList) + score = scoreList[0] logstr = "iter{} diff={} train-time(sec)={} {}={}%".format( config.glbIter, diff --git a/pkuseg/toolbox.py b/pkuseg/toolbox.py index ac1221b..5cd2005 100644 --- a/pkuseg/toolbox.py +++ b/pkuseg/toolbox.py @@ -259,7 +259,7 @@ def multiThreading(self, X, X2, dynamic=False): start = i * interval end = min(start + interval, len(X2)) proc = Process( - target=toolbox.taskRunner_test, args=(self, X2, start, end, Q) + target=toolbox.taskRunner_test, args=(self.Inf, self.Model, X2, start, end, Q) ) proc.start() procs.append(proc) @@ -271,11 +271,12 @@ def multiThreading(self, X, X2, dynamic=False): for proc in procs: proc.join() - def taskRunner_test(self, X2, start, end, Q): + @staticmethod + def taskRunner_test(Inf, Model, X2, start, end, Q): for k in range(start, end): x = X2[k] tags = [] - prob = self.Inf.decodeViterbi_fast(self.Model, x._x, tags) + prob = Inf.decodeViterbi_fast(Model, x._x, tags) Q.put((k, tags))