MCPcopy Create free account
hub / github.com/google-research/language / gen_one_pair_data

Method gen_one_pair_data

language/emql/data_loader.py:1190–1215  ·  view source on GitHub ↗

Generate one data point for set intersection. Args: name: 'intersection' or 'union' set1: a list of entities in set 1 set2: a list of entities in set 2 Returns: k hot vectors of set1, set2 and labels

(self, name, set1,
                        set2)

Source from the content-addressed store, hash-verified

1188 return padded_ent_ids, labels
1189
1190 def gen_one_pair_data(self, name, set1,
1191 set2):
1192 """Generate one data point for set intersection.
1193
1194 Args:
1195 name: 'intersection' or 'union'
1196 set1: a list of entities in set 1
1197 set2: a list of entities in set 2
1198
1199 Returns:
1200 k hot vectors of set1, set2 and labels
1201 """
1202 assert len(set1 & set2) >= 1
1203 candidate_set1 = np.zeros(self.num_entities)
1204 candidate_set1[[self.entity2id[e] for e in set1]] = 1.0
1205 candidate_set2 = np.zeros(self.num_entities)
1206 candidate_set2[[self.entity2id[e] for e in set2]] = 1.0
1207
1208 if name == 'union':
1209 return (candidate_set1, candidate_set2,
1210 np.maximum(candidate_set1, candidate_set2))
1211 elif name == 'intersection':
1212 return (candidate_set1, candidate_set2,
1213 np.minimum(candidate_set1, candidate_set2))
1214 else:
1215 raise ValueError('name not recognised: %s' % name)
1216
1217 def gen_one_follow_data(self, subj_factids,
1218 rel_factids):

Callers 2

mixture_generatorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected