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

Method find_pair

code/BertModel/utils.py:72–88  ·  view source on GitHub ↗
(self, tags, aspect_spans, opinion_spans, token_ranges)

Source from the content-addressed store, hash-verified

70 return spans
71
72 def find_pair(self, tags, aspect_spans, opinion_spans, token_ranges):
73 pairs = []
74 for al, ar in aspect_spans:
75 for pl, pr in opinion_spans:
76 tag_num = [0] * 4
77 for i in range(al, ar + 1):
78 for j in range(pl, pr + 1):
79 a_start = token_ranges[i][0]
80 o_start = token_ranges[j][0]
81 if al < pl:
82 tag_num[int(tags[a_start][o_start])] += 1
83 else:
84 tag_num[int(tags[o_start][a_start])] += 1
85 if tag_num[3] == 0: continue
86 sentiment = -1
87 pairs.append([al, ar, pl, pr, sentiment])
88 return pairs
89
90 def find_triplet(self, tags, aspect_spans, opinion_spans, token_ranges):
91 triplets = []

Callers 1

score_uniontagsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected