nju-websoft / OpenEA

A Benchmarking Study of Embedding-based Entity Alignment for Knowledge Graphs, VLDB 2020
GNU General Public License v3.0
517 stars 80 forks source link

Add predict method #17

Closed sven-h closed 3 years ago

sven-h commented 3 years ago

Hi Zequn,

this pull request contains the predict method which I mentioned in the issue. It is based on your implementation of retrieve_topk_alignment. Please carefully check if I did everything right. I also added a new parameter which is called min_sim_value to further restrict the output to correspondence with a higher similarity value than the given one (this parameter is optional).

I have two more questions where I am not really sure. 1) How can the mapping_mat be incorporated? And is it necessary? Do any approaches use it? Currently I use embeds1 = np.matmul(embeds1, self.mapping_mat.eval(session=self.session)). Is this correct? 2) When using the self.kgs.kg1.entities_listto get all entities, I saw that it only contains entities from the relation triples. I think it makes sense to also add entities from the subject of attribute_triples (just in case an entity has no relation but just attributes),

Maybe you can check if the result looks as expected (no switches from the indices etc). Furthermore the output_path can also be removed and the result is always written to the out_folder as in the save method. Just let me kow what you think about it.

Best regards Sven

sunzequn commented 3 years ago

Thank you, Sven.

1) If you want to use the mapping mat, you should call the two functions '__define_mappingvariables()' and '__define_mappinggraph()' when creating your model. MTransE uses this mapping mat and you can refer to its code.

2) In our datasets, all entities have relation triples. I will update the code to support the case where an entity has no relations but only attributes.

Best regards Zequn