Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: fix the bug in issue #823 #825

Merged
merged 1 commit into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion recbole/data/dataset/kg_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,20 @@ def _sort_remaped_entities(self, item_tokens):
layered_num.append(order_cnt[i])
layered_num = np.cumsum(np.array(layered_num))
new_id_token = item_ent_token_list[:layered_num[-2]]
new_token_id = {t: i for i, t in enumerate(new_id_token)}
for field in self.rec_level_ent_fields:
self._reset_ent_remapID(field, new_id_token)
self.field2id_token[field] = new_id_token
self.field2token_id[field] = new_token_id
new_id_token = item_ent_token_list[:layered_num[-1]]
new_id_token = [self.item2entity[_] if _ in self.item2entity else _ for _ in new_id_token]
new_token_id = {t: i for i, t in enumerate(new_id_token)}
for field in self.ent_level_ent_fields:
self._reset_ent_remapID(field, item_ent_token_list[:layered_num[-1]])
self.field2id_token[field] = new_id_token
self.field2id_token[self.entity_field] = item_ent_token_list[:layered_num[-1]]
self.field2token_id[field] = new_token_id
self.field2id_token[self.entity_field] = new_id_token
self.field2token_id[self.entity_field] = new_token_id

def _remap_ID_all(self):
"""Firstly, remap entities and items all together. Then sort entity tokens,
Expand All @@ -354,6 +359,7 @@ def _remap_ID_all(self):
item_tokens = self._get_rec_item_token()
super()._remap_ID_all()
self._sort_remaped_entities(item_tokens)
self.field2token_id[self.relation_field]['[UI-Relation]'] = len(self.field2id_token[self.relation_field])
self.field2id_token[self.relation_field] = np.append(self.field2id_token[self.relation_field], '[UI-Relation]')

@property
Expand Down