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

Method get_spans

code/BertModel/utils.py:54–70  ·  view source on GitHub ↗
(self, tags, length, token_range, type)

Source from the content-addressed store, hash-verified

52 self.data_num = len(self.predictions)
53
54 def get_spans(self, tags, length, token_range, type):
55 spans = []
56 start = -1
57 for i in range(length):
58 l, r = token_range[i]
59 if tags[l][l] == self.ignore_index:
60 continue
61 elif tags[l][l] == type:
62 if start == -1:
63 start = i
64 elif tags[l][l] != type:
65 if start != -1:
66 spans.append([start, i - 1])
67 start = -1
68 if start != -1:
69 spans.append([start, length - 1])
70 return spans
71
72 def find_pair(self, tags, aspect_spans, opinion_spans, token_ranges):
73 pairs = []

Callers 3

score_aspectMethod · 0.95
score_opinionMethod · 0.95
score_uniontagsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected