float formatting for stats
This commit is contained in:
parent
bf0ed35e00
commit
c0a22a4ef3
14
wani.py
14
wani.py
|
@ -1109,6 +1109,10 @@ class StatsFormatter(Formatter):
|
|||
self.jppb = None
|
||||
self.corew = None
|
||||
|
||||
@staticmethod
|
||||
def stat_str(num):
|
||||
return "{:.5f}".format(num) if isinstance(num, float) else str(num)
|
||||
|
||||
def set_structure(self, structure):
|
||||
jppb = []
|
||||
corew = []
|
||||
|
@ -1162,7 +1166,7 @@ class StatsFormatter(Formatter):
|
|||
word = words[idx]
|
||||
key = (sidx, idx, word.lemma)
|
||||
distribution = self.colocation_ids.dispersions[key]
|
||||
return [str(distribution)]
|
||||
return [self.stat_str(distribution)]
|
||||
|
||||
def content_right(self, freq):
|
||||
fx = self.stats['freq'][self.jppb[0]]
|
||||
|
@ -1173,9 +1177,11 @@ class StatsFormatter(Formatter):
|
|||
sum_fi = sum(self.stats['freq'][idx] for idx in self.corew)
|
||||
logdice_all = 14 + log2(len(self.corew) * freq / sum_fi)
|
||||
|
||||
dp12 = str(self.stats["delta_12"])
|
||||
dp21 = str(self.stats["delta_21"])
|
||||
return [dp12, dp21, str(logdice_core), str(logdice_all), str(self.stats['df'])]
|
||||
dp12 = self.stats["delta_12"]
|
||||
dp21 = self.stats["delta_21"]
|
||||
return [self.stat_str(x) for x in (
|
||||
dp12, dp21, logdice_core, logdice_all, self.stats['df']
|
||||
)]
|
||||
|
||||
def group(self):
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue
Block a user