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

Function get_opinions

code/BertModel/utils.py:26–40  ·  view source on GitHub ↗
(tags, length, ignore_index=-1)

Source from the content-addressed store, hash-verified

24
25
26def get_opinions(tags, length, ignore_index=-1):
27 spans = []
28 start = -1
29 for i in range(length):
30 if tags[i][i] == ignore_index: continue
31 elif tags[i][i] == 2:
32 if start == -1:
33 start = i
34 elif tags[i][i] != 2:
35 if start != -1:
36 spans.append([start, i - 1])
37 start = -1
38 if start != -1:
39 spans.append([start, length-1])
40 return spans
41
42
43class Metric():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected