MCPcopy Create free account
hub / github.com/NJUNLP/GTS / get_spans

Function get_spans

code/BertModel/data.py:10–27  ·  view source on GitHub ↗

for BIO tag

(tags)

Source from the content-addressed store, hash-verified

8
9
10def get_spans(tags):
11 '''for BIO tag'''
12 tags = tags.strip().split()
13 length = len(tags)
14 spans = []
15 start = -1
16 for i in range(length):
17 if tags[i].endswith('B'):
18 if start != -1:
19 spans.append([start, i - 1])
20 start = i
21 elif tags[i].endswith('O'):
22 if start != -1:
23 spans.append([start, i - 1])
24 start = -1
25 if start != -1:
26 spans.append([start, length - 1])
27 return spans
28
29
30def get_evaluate_spans(tags, length, token_range):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected