mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-10 19:57:17 +03:00
Simplify helper (see #3681) [ci skip]
This commit is contained in:
parent
f8fce6c03c
commit
dd153b2b33
|
@ -36,10 +36,10 @@ def main(model="en_core_web_sm"):
|
|||
print("{:<10}\t{}\t{}".format(r1.text, r2.ent_type_, r2.text))
|
||||
|
||||
|
||||
def filter_spans(spans, prefer_longest=True):
|
||||
def filter_spans(spans):
|
||||
# Filter a sequence of spans so they don't contain overlaps
|
||||
get_sort_key = lambda span: (span.end - span.start, span.start)
|
||||
sorted_spans = sorted(spans, key=get_sort_key, reverse=prefer_longest)
|
||||
sorted_spans = sorted(spans, key=get_sort_key, reverse=True)
|
||||
result = []
|
||||
seen_tokens = set()
|
||||
for span in sorted_spans:
|
||||
|
|
Loading…
Reference in New Issue
Block a user