mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-18 20:22:25 +03:00
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:
parent
64a0bf4460
commit
1baa334b8a
|
@ -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:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user