// TODO: Hack!!!
try:
self.contexts = list(set(c.context for c in self.candidates.union(self.gold)))
except:
self.contexts = list(set(c.span0.context for c in self.candidates.union(self.gold)))
After Change
// We get the sorted candidates and all contexts required, either from unary or binary candidates
self.gold = list(gold)
try:
self.candidates = sorted(list(candidates), key=lambda c : c.char_start)
self.contexts = list(set(c.context for c in self.candidates + self.gold))
except:
self.candidates = sorted(list(candidates), key=lambda c : c.span0.char_start)
self.contexts = list(set(c.span0.context for c in self.candidates + self.gold))