Skip to content
Snippets Groups Projects
Commit 5aad4ac4 authored by Franck Dary's avatar Franck Dary
Browse files

Fixed average

parent 264fc5bd
No related branches found
No related tags found
No related merge requests found
......@@ -292,6 +292,9 @@ class History() :
globalStats["backPrecision"] = 100.0*globalStats["backOnErr"] / globalStats["nbBack"]
if globalStats["backPrecision"] + globalStats["backRecall"] > 0.0 :
globalStats["backFScore"] = 2*(globalStats["backPrecision"] * globalStats["backRecall"])/(globalStats["backPrecision"] + globalStats["backRecall"])
if globalStats["nbRedoneErrErr"] :
globalStats["redoneErrErrAvgDistChange"] /= globalStats["nbRedoneErrErr"]
globalStats["redoneErrErrAvgIndexChange"] /= globalStats["nbRedoneErrErr"]
if globalStats["nbRedone"] :
globalStats["redoneAvgErrChange"] /= globalStats["nbRedone"]
globalStats["nbRedoneDiminishErr"] /= globalStats["nbRedone"] * (1/100)
......@@ -300,9 +303,7 @@ class History() :
globalStats["nbRedoneErrErr"] /= globalStats["nbRedone"] * (1/100)
globalStats["nbRedoneCorrectErr"] /= globalStats["nbRedone"] * (1/100)
globalStats["nbRedoneErrCorrect"] /= globalStats["nbRedone"] * (1/100)
if globalStats["nbRedoneErrErr"] :
globalStats["redoneErrErrAvgDistChange"] /= globalStats["nbRedoneErrErr"]
globalStats["redoneErrErrAvgIndexChange"] /= globalStats["nbRedoneErrErr"]
return globalStats
#-------------------------------------------------------------------------------
......@@ -324,9 +325,10 @@ class History() :
#-------------------------------------------------------------------------------
def readFromTrace(self, traceFile) :
curStep = Step()
started = False
for line in open(traceFile, "r") :
line = line.strip()
line = line.rstrip()
# End of sentence :
if len(line) == 0 :
......@@ -336,6 +338,11 @@ class History() :
self.sentences[-1].append([])
continue
if "-----" in line :
started = True
if not started :
continue
if "state :" in line :
curStep.state = int(line.split(':')[-1].strip())
elif "=>" in line :
......@@ -360,6 +367,8 @@ class History() :
curStep.scores = [a.replace("*","").split(':') for a in curStep.scores if not len(a.split(':')) == 1]
curStep.scores = [(float(a[0]), a[1]) for a in curStep.scores]
elif " " in line :
annotLine = " ".join(line.split(" ")[1:])
if "-" not in annotLine.split()[0] :
curId = int(annotLine.split()[0])
self.sentences[-1][0][curId] = annotLine
elif "Chosen action :" in line :
......@@ -381,7 +390,12 @@ class History() :
################################################################################
def prettyNumber(num) :
return ("%.2f"%num).rstrip(".0")
base = "%.2f"%num
splited = base.split('.')
striped = splited[1].rstrip('.0')
if len(striped) > 0 :
striped = "."+striped
return splited[0] + striped
################################################################################
################################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment