haitian-sun / GraftNet

BSD 2-Clause "Simplified" License
268 stars 56 forks source link

Some tuples in the subgraph in the Wikimovie dataset are empty. #18

Closed fcc357 closed 3 years ago

fcc357 commented 3 years ago

Hello, Dr. Sun I would like to ask you how to deal with the following problem. Some tuples in the subgraph in the Wikimovie dataset are empty. So in the code below, some variables are given null values, resulting in the error. I am looking forward to your guidance.

        if self.use_kb: 
            print(len(sample['subgraph']['tuples']))
            for i, tpl in enumerate(sample['subgraph']['tuples']):
                sbj, rel, obj = tpl
                if not self.use_inverse_relation:
                    entity2fact_e += [g2l[self.entity2id[sbj['text']]]]
                    entity2fact_f += [i]
                    fact2entity_f += [i]
                    fact2entity_e += [g2l[self.entity2id[obj['text']]]]
                    self.kb_fact_rels[next_id, i] = self.relation2id[rel['text']]
                else:
                    entity2fact_e += [g2l[self.entity2id[sbj['text']]], g2l[self.entity2id[obj['text']]]]
                    entity2fact_f += [2 * i, 2 * i + 1]#?
                    fact2entity_f += [2 * i, 2 * i + 1]
                    fact2entity_e += [g2l[self.entity2id[obj['text']]], g2l[self.entity2id[sbj['text']]]]
                    self.kb_fact_rels[next_id, 2 * i] = self.relation2id[rel['text']]
                    self.kb_fact_rels[next_id, 2 * i + 1] = self.relation2id[rel['text']] + len(self.relation2id)