Make get_clusters_from_doc return spans in order

There's no guarantee about the order in which SpanGroup keys will come
out, so access them in sorted order when doing comparisons.
This commit is contained in:
Paul O'Leary McCann 2022-07-12 14:07:40 +09:00
parent 64a0bf4460
commit 1baa334b8a

View File

@ -147,7 +147,9 @@ def get_clusters_from_doc(doc) -> List[List[Tuple[int, int]]]:
ints are char spans, to be tokenization independent. ints are char spans, to be tokenization independent.
""" """
out = [] out = []
for key, val in doc.spans.items(): keys = sorted(list(doc.spans.keys()))
for key in keys:
val = doc.spans[key]
cluster = [] cluster = []
for span in val: for span in val: