probability = None
if "probability" in row:
probability = float(row["probability"])
del row["probability"]
suspicions = {k: self.bool(v) for k, v in row.items() if self.bool(v)}
if not suspicions:
suspicions = None
After Change
hypothesis = tuple(k for k in row.keys() if k not in reserved_keys)
pairs = ((k, v) for k, v in row.items() if k in hypothesis)
filtered = filter(lambda x: self.bool(x[1]), pairs)
suspicions = dict((k, True) for k, v in filtered) or None
return dict(
document_id=document_id,