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

Function get_spans

code/NNModel/data.py:8–25  ·  view source on GitHub ↗

for BIO tag

(tags)

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected