A mistake to read item to entity map
RichardHGL opened this issue · 0 comments
RichardHGL commented
When I run the code for jtransup model, I find that logger Find 0 aligned items and entities!
I have check it out, jTransUP.data.load_kg_rating_data import load_data
, this function has an error that matters,
def loadR2KgMap(filename):
i2kg_map = {}
kg2i_map = {}
with open(filename, 'r', encoding='utf-8') as fin:
for line in fin:
line_split = line.strip().split('\t')
if len(line_split) != 3 : continue
i_id = line_split[0]#int(line_split[0])
kg_uri = line_split[2]
i2kg_map[i_id] = kg_uri
kg2i_map[kg_uri] = i_id
print("successful load {} item and {} entity pairs!".format(len(i2kg_map), len(kg2i_map)))
return i2kg_map, kg2i_map
It's neccessary to use i_id = line_split[0]
, or 0 items will be aligned.
Have a look at it!