def get_document_batch(self, doc_id):
"""builds batch of all mention pairs in one document
Args:
doc_id: id of document
Returns:
feature representation of mentions and labels
"""
mentions = self.dl.get_all_mentions_from_doc(doc_id)
if len(mentions) == 0:
return None, None
A, B = [], []
for a in mentions:
for b in mentions:
A.append(a)
B.append(b)
A_f = [self._mention_to_features(m) for m in A]
B_f = [self._mention_to_features(m) for m in B]
AB_f = self._pair_features(A, B)
A = [self.dl.mention_features[m] for m in A]
B = [self.dl.mention_features[m] for m in B]
return np.vstack(A), np.stack(A_f), np.vstack(B), np.stack(B_f), np.stack(AB_f)
评论列表
文章目录